jumpserver/apps/assets/automations/endpoint.py

29 lines
1.1 KiB
Python
Raw Normal View History

2022-10-13 09:47:29 +00:00
from .change_secret.manager import ChangeSecretManager
2022-10-17 03:22:21 +00:00
from .gather_facts.manager import GatherFactsManager
2022-10-27 10:53:10 +00:00
from .gather_accounts.manager import GatherAccountsManager
2022-10-28 10:28:41 +00:00
from .verify_account.manager import VerifyAccountManager
from .push_account.manager import PushAccountManager
from .backup_account.manager import AccountBackupManager
from .ping.manager import PingManager
2022-10-19 09:05:21 +00:00
from ..const import AutomationTypes
2022-10-10 05:56:42 +00:00
2022-10-09 12:54:11 +00:00
class ExecutionManager:
2022-10-10 05:56:42 +00:00
manager_type_mapper = {
AutomationTypes.ping: PingManager,
AutomationTypes.push_account: PushAccountManager,
2022-10-19 09:05:21 +00:00
AutomationTypes.gather_facts: GatherFactsManager,
AutomationTypes.change_secret: ChangeSecretManager,
2022-10-28 10:28:41 +00:00
AutomationTypes.verify_account: VerifyAccountManager,
AutomationTypes.gather_accounts: GatherAccountsManager,
# TODO 后期迁移到自动化策略中
'backup_account': AccountBackupManager,
2022-10-09 12:54:11 +00:00
}
2022-10-10 05:56:42 +00:00
def __init__(self, execution):
self.execution = execution
2022-10-19 09:05:21 +00:00
self._runner = self.manager_type_mapper[execution.manager_type](execution)
2022-10-10 05:56:42 +00:00
2022-10-19 09:05:21 +00:00
def run(self, *args, **kwargs):
return self._runner.run(*args, **kwargs)