mirror of https://github.com/jumpserver/jumpserver
perf: 修改任务检查 (#11609)
* perf: 修改任务检查 * perf: 修改翻译 --------- Co-authored-by: ibuler <ibuler@qq.com>pull/11631/head
parent
ea3ff1ebcb
commit
90131db55a
|
@ -80,7 +80,7 @@ class PushAccountManager(ChangeSecretManager, AccountBasePlaybookManager):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def on_runner_failed(self, runner, e):
|
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):
|
def run(self, *args, **kwargs):
|
||||||
if self.secret_type and not self.check_secret():
|
if self.secret_type and not self.check_secret():
|
||||||
|
|
|
@ -50,11 +50,25 @@ def push_accounts_if_need(accounts=()):
|
||||||
logger.debug("Push accounts to source: %s, task: %s", source_id, task)
|
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)
|
@receiver(post_save, sender=Account)
|
||||||
def on_account_create_by_template(sender, instance, created=False, **kwargs):
|
def on_account_create_by_template(sender, instance, created=False, **kwargs):
|
||||||
if not created or instance.source != 'template':
|
if not created or instance.source != 'template':
|
||||||
return
|
return
|
||||||
push_accounts_if_need(accounts=(instance,))
|
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):
|
class VaultSignalHandler(object):
|
||||||
|
|
|
@ -175,7 +175,7 @@ class BasePlaybookManager:
|
||||||
method = self.method_id_meta_mapper.get(method_id)
|
method = self.method_id_meta_mapper.get(method_id)
|
||||||
if not method:
|
if not method:
|
||||||
logger.error("Method not found: {}".format(method_id))
|
logger.error("Method not found: {}".format(method_id))
|
||||||
return method
|
return
|
||||||
method_playbook_dir_path = method['dir']
|
method_playbook_dir_path = method['dir']
|
||||||
sub_playbook_path = os.path.join(sub_playbook_dir, 'project', 'main.yml')
|
sub_playbook_path = os.path.join(sub_playbook_dir, 'project', 'main.yml')
|
||||||
shutil.copytree(method_playbook_dir_path, os.path.dirname(sub_playbook_path))
|
shutil.copytree(method_playbook_dir_path, os.path.dirname(sub_playbook_path))
|
||||||
|
@ -196,6 +196,11 @@ class BasePlaybookManager:
|
||||||
print(msg)
|
print(msg)
|
||||||
runners = []
|
runners = []
|
||||||
for platform, assets in assets_group_by_platform.items():
|
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)]
|
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):
|
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')
|
inventory_path = os.path.join(self.runtime_dir, sub_dir, 'hosts.json')
|
||||||
self.generate_inventory(_assets, inventory_path)
|
self.generate_inventory(_assets, inventory_path)
|
||||||
playbook_path = self.generate_playbook(_assets, platform, playbook_dir)
|
playbook_path = self.generate_playbook(_assets, platform, playbook_dir)
|
||||||
|
if not playbook_path:
|
||||||
|
continue
|
||||||
|
|
||||||
runer = PlaybookRunner(
|
runer = PlaybookRunner(
|
||||||
inventory_path,
|
inventory_path,
|
||||||
|
@ -309,6 +316,7 @@ class BasePlaybookManager:
|
||||||
shutil.rmtree(self.runtime_dir)
|
shutil.rmtree(self.runtime_dir)
|
||||||
|
|
||||||
def run(self, *args, **kwargs):
|
def run(self, *args, **kwargs):
|
||||||
|
print(">>> 任务准备阶段\n")
|
||||||
runners = self.get_runners()
|
runners = self.get_runners()
|
||||||
if len(runners) > 1:
|
if len(runners) > 1:
|
||||||
print("### 分次执行任务, 总共 {}\n".format(len(runners)))
|
print("### 分次执行任务, 总共 {}\n".format(len(runners)))
|
||||||
|
|
|
@ -90,4 +90,4 @@ class SendAndVerifyCodeUtil(object):
|
||||||
self.__send_with_email()
|
self.__send_with_email()
|
||||||
|
|
||||||
cache.set(self.key, self.code, self.timeout)
|
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}')
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:e272cbf5e09c7c2c5e2ca3215dc57b7835de698d1f02092c893ce81de472d8ad
|
oid sha256:2ffdd50c364a510b4f5cfe7922a5f1a604e8bc7b03aa43ece1dff0250ccde6d6
|
||||||
size 160195
|
size 160575
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -907,6 +907,16 @@ msgstr "成功"
|
||||||
msgid "Push related accounts to assets: %s, by system"
|
msgid "Push related accounts to assets: %s, by system"
|
||||||
msgstr "関連するアカウントをアセットにプッシュ: %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
|
#: accounts/tasks/automation.py:24
|
||||||
msgid "Account execute automation"
|
msgid "Account execute automation"
|
||||||
msgstr "アカウント実行の自動化"
|
msgstr "アカウント実行の自動化"
|
||||||
|
@ -1193,6 +1203,10 @@ msgstr "アプリ資産"
|
||||||
msgid "{} disabled"
|
msgid "{} disabled"
|
||||||
msgstr "{} 無効"
|
msgstr "{} 無効"
|
||||||
|
|
||||||
|
#: assets/automations/base/manager.py:202
|
||||||
|
msgid " - Platform {} ansible disabled"
|
||||||
|
msgstr " - プラットフォーム {} ansible 無効"
|
||||||
|
|
||||||
#: assets/automations/ping_gateway/manager.py:33
|
#: assets/automations/ping_gateway/manager.py:33
|
||||||
#: authentication/models/connection_token.py:128
|
#: authentication/models/connection_token.py:128
|
||||||
msgid "No account"
|
msgid "No account"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:2492fc51a9dfef6fbeccd0ee4a8612d1c4e8bf3897fe518a6500c6bda4828f1a
|
oid sha256:78fa10c674b853ebde73bbdef255beeb794a7a7b4bf5483ac1464c282aab0819
|
||||||
size 130875
|
size 131200
|
||||||
|
|
|
@ -7,7 +7,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: JumpServer 0.3.3\n"
|
"Project-Id-Version: JumpServer 0.3.3\n"
|
||||||
"Report-Msgid-Bugs-To: \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"
|
"PO-Revision-Date: 2021-05-20 10:54+0800\n"
|
||||||
"Last-Translator: ibuler <ibuler@qq.com>\n"
|
"Last-Translator: ibuler <ibuler@qq.com>\n"
|
||||||
"Language-Team: JumpServer team<ibuler@qq.com>\n"
|
"Language-Team: JumpServer team<ibuler@qq.com>\n"
|
||||||
|
@ -904,6 +904,16 @@ msgstr "成功"
|
||||||
msgid "Push related accounts to assets: %s, by system"
|
msgid "Push related accounts to assets: %s, by system"
|
||||||
msgstr "推送账号到资产: %s, 由系统执行"
|
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
|
#: accounts/tasks/automation.py:24
|
||||||
msgid "Account execute automation"
|
msgid "Account execute automation"
|
||||||
msgstr "账号执行自动化"
|
msgstr "账号执行自动化"
|
||||||
|
@ -1187,6 +1197,10 @@ msgstr "资产管理"
|
||||||
msgid "{} disabled"
|
msgid "{} disabled"
|
||||||
msgstr "{} 已禁用"
|
msgstr "{} 已禁用"
|
||||||
|
|
||||||
|
#: assets/automations/base/manager.py:202
|
||||||
|
msgid " - Platform {} ansible disabled"
|
||||||
|
msgstr " - 平台 {} Ansible 已禁用, 无法执行任务"
|
||||||
|
|
||||||
#: assets/automations/ping_gateway/manager.py:33
|
#: assets/automations/ping_gateway/manager.py:33
|
||||||
#: authentication/models/connection_token.py:128
|
#: authentication/models/connection_token.py:128
|
||||||
msgid "No account"
|
msgid "No account"
|
||||||
|
|
Loading…
Reference in New Issue