mirror of https://github.com/jumpserver/jumpserver
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
from ops.ansible.cleaner import WorkPostRunCleaner, cleanup_post_run
|
|
|
|
|
|
class BaseRunner(WorkPostRunCleaner):
|
|
|
|
def __init__(self, **kwargs):
|
|
self.runner_params = kwargs
|
|
self.clean_workspace = kwargs.pop("clean_workspace", True)
|
|
|
|
@classmethod
|
|
def kill_precess(cls, pid):
|
|
return NotImplementedError
|
|
|
|
@property
|
|
def clean_dir(self):
|
|
if not self.clean_workspace:
|
|
return None
|
|
return self.private_data_dir
|
|
|
|
@property
|
|
def private_data_dir(self):
|
|
return self.runner_params.get('private_data_dir', None)
|
|
|
|
def get_event_handler(self):
|
|
_event_handler = self.runner_params.pop("event_handler", None)
|
|
return _event_handler
|
|
|
|
def get_status_handler(self):
|
|
_status_handler = self.runner_params.pop("status_handler", None)
|
|
|
|
if not _status_handler:
|
|
return
|
|
|
|
def _handler(data, **kwargs):
|
|
if self.private_data_dir:
|
|
data["private_data_dir"] = self.private_data_dir
|
|
_status_handler(data, **kwargs)
|
|
|
|
return _handler
|
|
|
|
def run(self):
|
|
raise NotImplementedError()
|