diff --git a/apps/accounts/automations/push_account/manager.py b/apps/accounts/automations/push_account/manager.py index 9944f12ed..791a281ca 100644 --- a/apps/accounts/automations/push_account/manager.py +++ b/apps/accounts/automations/push_account/manager.py @@ -80,7 +80,7 @@ class PushAccountManager(ChangeSecretManager, AccountBasePlaybookManager): pass def on_runner_failed(self, runner, e): - logger.error("Pust account error: ", e) + logger.error("Pust account error: {}".format(e)) def run(self, *args, **kwargs): if self.secret_type and not self.check_secret(): diff --git a/apps/accounts/signal_handlers.py b/apps/accounts/signal_handlers.py index 6aba9cee4..d086a049c 100644 --- a/apps/accounts/signal_handlers.py +++ b/apps/accounts/signal_handlers.py @@ -50,11 +50,25 @@ def push_accounts_if_need(accounts=()): logger.debug("Push accounts to source: %s, task: %s", source_id, task) +def create_accounts_activities(account, action='create'): + if action == 'create': + detail = i18n_fmt(gettext_noop('Add account: %s'), str(account)) + else: + detail = i18n_fmt(gettext_noop('Delete account: %s'), str(account)) + create_activities([account.asset_id], detail, None, ActivityChoices.operate_log, account.org_id) + + @receiver(post_save, sender=Account) def on_account_create_by_template(sender, instance, created=False, **kwargs): if not created or instance.source != 'template': return push_accounts_if_need(accounts=(instance,)) + create_accounts_activities(instance, action='create') + + +@receiver(post_delete, sender=Account) +def on_account_delete(sender, instance, **kwargs): + create_accounts_activities(instance, action='delete') class VaultSignalHandler(object): diff --git a/apps/assets/automations/base/manager.py b/apps/assets/automations/base/manager.py index 4d35c9121..a035dc700 100644 --- a/apps/assets/automations/base/manager.py +++ b/apps/assets/automations/base/manager.py @@ -175,7 +175,7 @@ class BasePlaybookManager: method = self.method_id_meta_mapper.get(method_id) if not method: logger.error("Method not found: {}".format(method_id)) - return method + return method_playbook_dir_path = method['dir'] sub_playbook_path = os.path.join(sub_playbook_dir, 'project', 'main.yml') shutil.copytree(method_playbook_dir_path, os.path.dirname(sub_playbook_path)) @@ -196,6 +196,11 @@ class BasePlaybookManager: print(msg) runners = [] for platform, assets in assets_group_by_platform.items(): + if not assets: + continue + if not platform.automation or not platform.automation.ansible_enabled: + print(_(" - Platform {} ansible disabled").format(platform.name)) + continue assets_bulked = [assets[i:i + self.bulk_size] for i in range(0, len(assets), self.bulk_size)] for i, _assets in enumerate(assets_bulked, start=1): @@ -204,6 +209,8 @@ class BasePlaybookManager: inventory_path = os.path.join(self.runtime_dir, sub_dir, 'hosts.json') self.generate_inventory(_assets, inventory_path) playbook_path = self.generate_playbook(_assets, platform, playbook_dir) + if not playbook_path: + continue runer = PlaybookRunner( inventory_path, @@ -309,6 +316,7 @@ class BasePlaybookManager: shutil.rmtree(self.runtime_dir) def run(self, *args, **kwargs): + print(">>> 任务准备阶段\n") runners = self.get_runners() if len(runners) > 1: print("### 分次执行任务, 总共 {}\n".format(len(runners))) diff --git a/apps/common/utils/verify_code.py b/apps/common/utils/verify_code.py index acd547296..b21e43b26 100644 --- a/apps/common/utils/verify_code.py +++ b/apps/common/utils/verify_code.py @@ -90,4 +90,4 @@ class SendAndVerifyCodeUtil(object): self.__send_with_email() cache.set(self.key, self.code, self.timeout) - logger.info(f'Send verify code to {self.target}: {code}') + logger.debug(f'Send verify code to {self.target}') diff --git a/apps/locale/ja/LC_MESSAGES/django.mo b/apps/locale/ja/LC_MESSAGES/django.mo index a172ed89b..e12251412 100644 --- a/apps/locale/ja/LC_MESSAGES/django.mo +++ b/apps/locale/ja/LC_MESSAGES/django.mo @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e272cbf5e09c7c2c5e2ca3215dc57b7835de698d1f02092c893ce81de472d8ad -size 160195 +oid sha256:2ffdd50c364a510b4f5cfe7922a5f1a604e8bc7b03aa43ece1dff0250ccde6d6 +size 160575 diff --git a/apps/locale/ja/LC_MESSAGES/django.po b/apps/locale/ja/LC_MESSAGES/django.po index 9a24a17a8..aa30a95b7 100644 --- a/apps/locale/ja/LC_MESSAGES/django.po +++ b/apps/locale/ja/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-19 15:26+0800\n" +"POT-Creation-Date: 2023-09-19 15:41+0800\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -907,6 +907,16 @@ msgstr "成功" msgid "Push related accounts to assets: %s, by system" msgstr "関連するアカウントをアセットにプッシュ: %s, by system" +#: accounts/signal_handlers.py:55 +#, python-format +msgid "Add account: %s" +msgstr "アカウントを追加: %s" + +#: accounts/signal_handlers.py:57 +#, python-format +msgid "Delete account: %s" +msgstr "アカウントを削除: %s" + #: accounts/tasks/automation.py:24 msgid "Account execute automation" msgstr "アカウント実行の自動化" @@ -1193,6 +1203,10 @@ msgstr "アプリ資産" msgid "{} disabled" msgstr "{} 無効" +#: assets/automations/base/manager.py:202 +msgid " - Platform {} ansible disabled" +msgstr " - プラットフォーム {} ansible 無効" + #: assets/automations/ping_gateway/manager.py:33 #: authentication/models/connection_token.py:128 msgid "No account" diff --git a/apps/locale/zh/LC_MESSAGES/django.mo b/apps/locale/zh/LC_MESSAGES/django.mo index 49ba1548d..3f9d48c80 100644 --- a/apps/locale/zh/LC_MESSAGES/django.mo +++ b/apps/locale/zh/LC_MESSAGES/django.mo @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2492fc51a9dfef6fbeccd0ee4a8612d1c4e8bf3897fe518a6500c6bda4828f1a -size 130875 +oid sha256:78fa10c674b853ebde73bbdef255beeb794a7a7b4bf5483ac1464c282aab0819 +size 131200 diff --git a/apps/locale/zh/LC_MESSAGES/django.po b/apps/locale/zh/LC_MESSAGES/django.po index 819882112..d6b011d9d 100644 --- a/apps/locale/zh/LC_MESSAGES/django.po +++ b/apps/locale/zh/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: JumpServer 0.3.3\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-09-19 15:26+0800\n" +"POT-Creation-Date: 2023-09-19 10:39+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -904,6 +904,16 @@ msgstr "成功" msgid "Push related accounts to assets: %s, by system" msgstr "推送账号到资产: %s, 由系统执行" +#: accounts/signal_handlers.py:55 +#, python-format +msgid "Add account: %s" +msgstr "添加账号: %s" + +#: accounts/signal_handlers.py:57 +#, python-format +msgid "Delete account: %s" +msgstr "删除账号: %s" + #: accounts/tasks/automation.py:24 msgid "Account execute automation" msgstr "账号执行自动化" @@ -1187,6 +1197,10 @@ msgstr "资产管理" msgid "{} disabled" msgstr "{} 已禁用" +#: assets/automations/base/manager.py:202 +msgid " - Platform {} ansible disabled" +msgstr " - 平台 {} Ansible 已禁用, 无法执行任务" + #: assets/automations/ping_gateway/manager.py:33 #: authentication/models/connection_token.py:128 msgid "No account"