From 1417abecfb2dd4ecf541a5ef61c7f174aedd0129 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:54:33 +0800 Subject: [PATCH] perf: Add task description (#14033) Co-authored-by: ZhaoJiSen <97007455+ZhaoJiSen@users.noreply.github.com> --- apps/accounts/tasks/automation.py | 28 +- apps/accounts/tasks/backup_account.py | 10 +- apps/accounts/tasks/gather_accounts.py | 6 +- apps/accounts/tasks/push_account.py | 10 +- apps/accounts/tasks/remove_account.py | 23 +- apps/accounts/tasks/template.py | 8 +- apps/accounts/tasks/vault.py | 10 +- apps/accounts/tasks/verify_account.py | 10 +- apps/assets/tasks/automation.py | 6 +- apps/assets/tasks/gather_facts.py | 11 +- apps/assets/tasks/nodes_amount.py | 21 +- apps/assets/tasks/ping.py | 11 +- apps/assets/tasks/ping_gateway.py | 14 +- apps/audits/tasks.py | 26 +- apps/authentication/tasks.py | 10 +- apps/common/tasks.py | 31 +- apps/common/utils/verify_code.py | 10 +- apps/i18n/core/zh/LC_MESSAGES/django.po | 754 +++++++++++++++++++++--- apps/i18n/lina/en.json | 3 +- apps/i18n/lina/zh.json | 3 +- apps/notifications/notifications.py | 10 +- apps/ops/models/celery.py | 1 + apps/ops/tasks.py | 79 ++- apps/orgs/tasks.py | 5 +- apps/perms/tasks.py | 24 +- apps/settings/tasks/ldap.py | 19 +- apps/terminal/tasks.py | 68 ++- apps/users/signal_handlers.py | 10 +- apps/users/tasks.py | 56 +- 29 files changed, 1129 insertions(+), 148 deletions(-) diff --git a/apps/accounts/tasks/automation.py b/apps/accounts/tasks/automation.py index c03e4cf97..6e086aaf5 100644 --- a/apps/accounts/tasks/automation.py +++ b/apps/accounts/tasks/automation.py @@ -28,8 +28,16 @@ def task_activity_callback(self, pid, trigger, tp, *args, **kwargs): @shared_task( - queue='ansible', verbose_name=_('Account execute automation'), - activity_callback=task_activity_callback + queue='ansible', + verbose_name=_('Account execute automation'), + activity_callback=task_activity_callback, + description=_( + """ + Unified execution entry for account automation tasks: when the system performs tasks + such as account push, password change, account verification, account collection, + and gateway account verification, all tasks are executed through this unified entry + """ + ) ) def execute_account_automation_task(pid, trigger, tp): model = AutomationTypes.get_type_model(tp) @@ -54,8 +62,14 @@ def record_task_activity_callback(self, record_ids, *args, **kwargs): @shared_task( - queue='ansible', verbose_name=_('Execute automation record'), - activity_callback=record_task_activity_callback + queue='ansible', + verbose_name=_('Execute automation record'), + activity_callback=record_task_activity_callback, + description=_( + """ + When manually executing password change records, this task is used + """ + ) ) def execute_automation_record_task(record_ids, tp): from accounts.models import ChangeSecretRecord @@ -84,7 +98,11 @@ def execute_automation_record_task(record_ids, tp): @shared_task( verbose_name=_('Clean change secret and push record period'), - description=_('Clean change secret and push record period description') + description=_( + """ + Clean change secret and push record period description + """ + ) ) @register_as_period_task(crontab=CRONTAB_AT_AM_THREE) def clean_change_secret_and_push_record_period(): diff --git a/apps/accounts/tasks/backup_account.py b/apps/accounts/tasks/backup_account.py index c9b881b4d..d491c78f5 100644 --- a/apps/accounts/tasks/backup_account.py +++ b/apps/accounts/tasks/backup_account.py @@ -22,7 +22,15 @@ def task_activity_callback(self, pid, trigger, *args, **kwargs): return resource_ids, org_id -@shared_task(verbose_name=_('Execute account backup plan'), activity_callback=task_activity_callback) +@shared_task( + verbose_name=_('Execute account backup plan'), + activity_callback=task_activity_callback, + description=_( + """ + When performing scheduled or manual account backups, this task is used + """ + ) +) def execute_account_backup_task(pid, trigger, **kwargs): from accounts.models import AccountBackupAutomation with tmp_to_root_org(): diff --git a/apps/accounts/tasks/gather_accounts.py b/apps/accounts/tasks/gather_accounts.py index 42f8641bb..831a9fdf6 100644 --- a/apps/accounts/tasks/gather_accounts.py +++ b/apps/accounts/tasks/gather_accounts.py @@ -26,8 +26,10 @@ def gather_asset_accounts_util(nodes, task_name): @shared_task( - queue="ansible", verbose_name=_('Gather asset accounts'), - activity_callback=lambda self, node_ids, task_name=None, *args, **kwargs: (node_ids, None) + queue="ansible", + verbose_name=_('Gather asset accounts'), + activity_callback=lambda self, node_ids, task_name=None, *args, **kwargs: (node_ids, None), + description=_("Unused") ) def gather_asset_accounts_task(node_ids, task_name=None): if task_name is None: diff --git a/apps/accounts/tasks/push_account.py b/apps/accounts/tasks/push_account.py index 0e0608999..280d9b3a3 100644 --- a/apps/accounts/tasks/push_account.py +++ b/apps/accounts/tasks/push_account.py @@ -12,8 +12,14 @@ __all__ = [ @shared_task( - queue="ansible", verbose_name=_('Push accounts to assets'), - activity_callback=lambda self, account_ids, *args, **kwargs: (account_ids, None) + queue="ansible", + verbose_name=_('Push accounts to assets'), + activity_callback=lambda self, account_ids, *args, **kwargs: (account_ids, None), + description=_( + """ + When creating or modifying an account requires account push, this task is executed + """ + ) ) def push_accounts_to_assets_task(account_ids, params=None): from accounts.models import PushAccountAutomation diff --git a/apps/accounts/tasks/remove_account.py b/apps/accounts/tasks/remove_account.py index 44bb9a840..60fe82327 100644 --- a/apps/accounts/tasks/remove_account.py +++ b/apps/accounts/tasks/remove_account.py @@ -21,8 +21,15 @@ __all__ = ['remove_accounts_task'] @shared_task( - queue="ansible", verbose_name=_('Remove account'), - activity_callback=lambda self, gather_account_ids, *args, **kwargs: (gather_account_ids, None) + queue="ansible", + verbose_name=_('Remove account'), + activity_callback=lambda self, gather_account_ids, *args, **kwargs: (gather_account_ids, None), + description=_( + """ + When clicking "Sync deletion" in 'Console - Gather Account - Gathered accounts' this + task will be executed + """ + ) ) def remove_accounts_task(gather_account_ids): from accounts.models import GatheredAccount @@ -41,7 +48,17 @@ def remove_accounts_task(gather_account_ids): quickstart_automation_by_snapshot(task_name, tp, task_snapshot) -@shared_task(verbose_name=_('Clean historical accounts')) +@shared_task( + verbose_name=_('Clean historical accounts'), + description=_( + """ + Each time an asset account is updated, a historical account is generated, so it is + necessary to clean up the asset account history. The system will clean up excess account + records at 2 a.m. daily based on the configuration in the "System settings - Features - + Account storage - Record limit + """ + ) +) @register_as_period_task(crontab=CRONTAB_AT_AM_TWO) @tmp_to_root_org() def clean_historical_accounts(): diff --git a/apps/accounts/tasks/template.py b/apps/accounts/tasks/template.py index bc5416b9f..c4c781557 100644 --- a/apps/accounts/tasks/template.py +++ b/apps/accounts/tasks/template.py @@ -9,7 +9,13 @@ from orgs.utils import tmp_to_root_org, tmp_to_org @shared_task( verbose_name=_('Template sync info to related accounts'), - activity_callback=lambda self, template_id, *args, **kwargs: (template_id, None) + activity_callback=lambda self, template_id, *args, **kwargs: (template_id, None), + description=_( + """ + When clicking 'Sync new secret to accounts' in 'Console - Account - Templates - + Accounts' this task will be executed + """ + ) ) def template_sync_related_accounts(template_id, user_id=None): from accounts.models import Account, AccountTemplate diff --git a/apps/accounts/tasks/vault.py b/apps/accounts/tasks/vault.py index 6429b7133..2ef1f742c 100644 --- a/apps/accounts/tasks/vault.py +++ b/apps/accounts/tasks/vault.py @@ -28,7 +28,15 @@ def sync_instance(instance): return "succeeded", msg -@shared_task(verbose_name=_('Sync secret to vault')) +@shared_task( + verbose_name=_('Sync secret to vault'), + description=_( + """ + When clicking 'Sync' in 'System Settings - Features - Account Storage' this task will + be executed + """ + ) +) def sync_secret_to_vault(): if not vault_client.enabled: # 这里不能判断 settings.VAULT_ENABLED, 必须判断当前 vault_client 的类型 diff --git a/apps/accounts/tasks/verify_account.py b/apps/accounts/tasks/verify_account.py index 523e7f3d2..88fd31049 100644 --- a/apps/accounts/tasks/verify_account.py +++ b/apps/accounts/tasks/verify_account.py @@ -46,8 +46,14 @@ def verify_accounts_connectivity_util(accounts, task_name): @shared_task( - queue="ansible", verbose_name=_('Verify asset account availability'), - activity_callback=lambda self, account_ids, *args, **kwargs: (account_ids, None) + queue="ansible", + verbose_name=_('Verify asset account availability'), + activity_callback=lambda self, account_ids, *args, **kwargs: (account_ids, None), + description=_( + """ + When clicking 'Test' in 'Console - Asset details - Accounts' this task will be executed + """ + ) ) def verify_accounts_connectivity_task(account_ids): from accounts.models import Account, VerifyAccountAutomation diff --git a/apps/assets/tasks/automation.py b/apps/assets/tasks/automation.py index 20426451c..6fa4e2df2 100644 --- a/apps/assets/tasks/automation.py +++ b/apps/assets/tasks/automation.py @@ -21,8 +21,10 @@ def task_activity_callback(self, pid, trigger, tp, *args, **kwargs): @shared_task( - queue='ansible', verbose_name=_('Asset execute automation'), - activity_callback=task_activity_callback + queue='ansible', + verbose_name=_('Asset execute automation'), + activity_callback=task_activity_callback, + description=_("Unused") ) def execute_asset_automation_task(pid, trigger, tp): model = AutomationTypes.get_type_model(tp) diff --git a/apps/assets/tasks/gather_facts.py b/apps/assets/tasks/gather_facts.py index b541bde69..499c58995 100644 --- a/apps/assets/tasks/gather_facts.py +++ b/apps/assets/tasks/gather_facts.py @@ -18,8 +18,15 @@ __all__ = [ @shared_task( - queue="ansible", verbose_name=_('Gather assets facts'), - activity_callback=lambda self, asset_ids, org_id, *args, **kwargs: (asset_ids, org_id) + queue="ansible", + verbose_name=_('Gather assets facts'), + activity_callback=lambda self, asset_ids, org_id, *args, **kwargs: (asset_ids, org_id), + description=_( + """ + When clicking 'Refresh hardware info' in 'Console - Asset Details - Basic' this task + will be executed + """ + ) ) def gather_assets_facts_task(asset_ids, org_id, task_name=None): from assets.models import GatherFactsAutomation diff --git a/apps/assets/tasks/nodes_amount.py b/apps/assets/tasks/nodes_amount.py index 58344aa11..c660c314e 100644 --- a/apps/assets/tasks/nodes_amount.py +++ b/apps/assets/tasks/nodes_amount.py @@ -13,7 +13,16 @@ from common.const.crontab import CRONTAB_AT_AM_TWO logger = get_logger(__file__) -@shared_task(verbose_name=_('Check the amount of assets under the node')) +@shared_task( + verbose_name=_('Check the amount of assets under the node'), + description=_( + """ + Manually verifying asset quantities updates the asset count for nodes under the + current organization. This task will be called in the following two cases: when updating + nodes and when the number of nodes exceeds 100 + """ + ) +) def check_node_assets_amount_task(org_id=None): if org_id is None: orgs = Organization.objects.all() @@ -30,7 +39,15 @@ def check_node_assets_amount_task(org_id=None): logger.error(error) -@shared_task(verbose_name=_('Periodic check the amount of assets under the node')) +@shared_task( + verbose_name=_('Periodic check the amount of assets under the node'), + description=_( + """ + Schedule the check_node_assets_amount_task to periodically update the asset count of + all nodes under all organizations + """ + ) +) @register_as_period_task(crontab=CRONTAB_AT_AM_TWO) def check_node_assets_amount_period_task(): check_node_assets_amount_task() diff --git a/apps/assets/tasks/ping.py b/apps/assets/tasks/ping.py index 3882fe0b3..e441a63a0 100644 --- a/apps/assets/tasks/ping.py +++ b/apps/assets/tasks/ping.py @@ -17,8 +17,15 @@ __all__ = [ @shared_task( - verbose_name=_('Test assets connectivity'), queue='ansible', - activity_callback=lambda self, asset_ids, org_id, *args, **kwargs: (asset_ids, org_id) + verbose_name=_('Test assets connectivity'), + queue='ansible', + activity_callback=lambda self, asset_ids, org_id, *args, **kwargs: (asset_ids, org_id), + description=_( + """ + When clicking 'Test Asset Connectivity' in 'Asset Details - Basic Settings' this task + will be executed + """ + ) ) def test_assets_connectivity_task(asset_ids, org_id, task_name=None): from assets.models import PingAutomation diff --git a/apps/assets/tasks/ping_gateway.py b/apps/assets/tasks/ping_gateway.py index 05ab7fb0c..dad7a6a6e 100644 --- a/apps/assets/tasks/ping_gateway.py +++ b/apps/assets/tasks/ping_gateway.py @@ -16,8 +16,15 @@ __all__ = [ @shared_task( - verbose_name=_('Test gateways connectivity'), queue='ansible', - activity_callback=lambda self, asset_ids, org_id, *args, **kwargs: (asset_ids, org_id) + verbose_name=_('Test gateways connectivity'), + queue='ansible', + activity_callback=lambda self, asset_ids, org_id, *args, **kwargs: (asset_ids, org_id), + description=_( + """ + When clicking 'Test Connection' in 'Domain Details - Gateway' this task will be + executed + """ + ) ) def test_gateways_connectivity_task(asset_ids, org_id, local_port, task_name=None): from assets.models import PingAutomation @@ -33,4 +40,5 @@ def test_gateways_connectivity_task(asset_ids, org_id, local_port, task_name=Non def test_gateways_connectivity_manual(gateway_ids, local_port): task_name = gettext_noop("Test gateways connectivity") gateway_ids = [str(i) for i in gateway_ids] - return test_gateways_connectivity_task.delay(gateway_ids, str(current_org.id), local_port, task_name) + return test_gateways_connectivity_task.delay(gateway_ids, str(current_org.id), local_port, + task_name) diff --git a/apps/audits/tasks.py b/apps/audits/tasks.py index f59d515ee..8daaca79d 100644 --- a/apps/audits/tasks.py +++ b/apps/audits/tasks.py @@ -128,7 +128,21 @@ def clean_expired_session_period(): logger.info("Clean session replay done") -@shared_task(verbose_name=_('Clean audits session task log')) +@shared_task( + verbose_name=_('Clean audits session task log'), + description=_( + """ + Since the system generates login logs, operation logs, file upload logs, activity + logs, Celery execution logs, session recordings, and command records, as well as password + change logs, it will clean up these records based on the periodic cleanup configuration + in "System Settings - Tasks" The system will clean up login logs, task logs, operation + logs, password change logs, upload and download logs, session logs, activity records, + job center execution history logs, and cloud synchronization records that exceed the set + time limit every day at 2 a.m., according to the periodic cleanup configuration in + 'System Settings - Tasks' + """ + ) +) @register_as_period_task(crontab=CRONTAB_AT_AM_TWO) def clean_audits_log_period(): print("Start clean audit session task log") @@ -142,7 +156,15 @@ def clean_audits_log_period(): clean_password_change_log_period() -@shared_task(verbose_name=_('Upload FTP file to external storage')) +@shared_task( + verbose_name=_('Upload FTP file to external storage'), + description=_( + """ + If SERVER_REPLAY_STORAGE is configured, files uploaded through file management will be + synchronized to external storage + """ + ) +) def upload_ftp_file_to_external_storage(ftp_log_id, file_name): logger.info(f'Start upload FTP file record to external storage: {ftp_log_id} - {file_name}') ftp_log = FTPLog.objects.filter(id=ftp_log_id).first() diff --git a/apps/authentication/tasks.py b/apps/authentication/tasks.py index f731d6670..db7c9124a 100644 --- a/apps/authentication/tasks.py +++ b/apps/authentication/tasks.py @@ -8,7 +8,15 @@ from django.utils import timezone from django.utils.translation import gettext_lazy as _ -@shared_task(verbose_name=_('Clean expired session')) +@shared_task( + verbose_name=_('Clean expired session'), + description=_( + """ + Since user logins create sessions, the system will clean up expired sessions every 24 + hours + """ + ) +) @register_as_period_task(interval=3600 * 24) def clean_django_sessions(): Session.objects.filter(expire_date__lt=timezone.now()).delete() diff --git a/apps/common/tasks.py b/apps/common/tasks.py index 5bffe07f4..dd2645c9a 100644 --- a/apps/common/tasks.py +++ b/apps/common/tasks.py @@ -28,7 +28,15 @@ def task_activity_callback(self, subject, message, recipient_list, *args, **kwar return resource_ids, -@shared_task(verbose_name=_("Send email"), activity_callback=task_activity_callback) +@shared_task( + verbose_name=_("Send email"), + activity_callback=task_activity_callback, + description=_( + """ + This task will be executed when sending email notifications + """ + ) +) def send_mail_async(*args, **kwargs): """ Using celery to send email async @@ -55,7 +63,16 @@ def send_mail_async(*args, **kwargs): logger.error("Sending mail error: {}".format(e)) -@shared_task(verbose_name=_("Send email attachment"), activity_callback=task_activity_callback) +@shared_task( + verbose_name=_("Send email attachment"), + activity_callback=task_activity_callback, + description=_( + """ + When an account password is changed or an account backup generates attachments, + this task needs to be executed for sending emails and handling attachments + """ + ) +) def send_mail_attachment_async(subject, message, recipient_list, attachment_list=None): if attachment_list is None: attachment_list = [] @@ -77,7 +94,15 @@ def send_mail_attachment_async(subject, message, recipient_list, attachment_list logger.error("Sending mail attachment error: {}".format(e)) -@shared_task(verbose_name=_('Upload session replay to external storage')) +@shared_task( + verbose_name=_('Upload account backup to external storage'), + description=_( + """ + When performing an account backup, this task needs to be executed to external storage + (SFTP) + """ + ) +) def upload_backup_to_obj_storage(recipient, upload_file): logger.info(f'Start upload file : {upload_file}') remote_path = os.path.join('account_backup', os.path.basename(upload_file)) diff --git a/apps/common/utils/verify_code.py b/apps/common/utils/verify_code.py index dea844768..8dc575d6c 100644 --- a/apps/common/utils/verify_code.py +++ b/apps/common/utils/verify_code.py @@ -13,7 +13,15 @@ from common.utils.random import random_string logger = get_logger(__file__) -@shared_task(verbose_name=_('Send SMS code')) +@shared_task( + verbose_name=_('Send SMS code'), + description=_( + """ + When resetting a password, forgetting a password, or verifying MFA, this task needs to + be executed to send SMS messages + """ + ) +) def send_sms_async(target, code): SMS().send_verify_code(target, code) diff --git a/apps/i18n/core/zh/LC_MESSAGES/django.po b/apps/i18n/core/zh/LC_MESSAGES/django.po index eaa0643e6..50dde09ba 100644 --- a/apps/i18n/core/zh/LC_MESSAGES/django.po +++ b/apps/i18n/core/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: 2024-09-09 14:22+0800\n" +"POT-Creation-Date: 2024-09-09 18:29+0800\n" "PO-Revision-Date: 2021-05-20 10:54+0800\n" "Last-Translator: ibuler \n" "Language-Team: JumpServer team\n" @@ -207,8 +207,8 @@ msgstr "更改密码" msgid "Verify account" msgstr "验证账号" -#: accounts/const/automation.py:27 accounts/tasks/remove_account.py:24 -#: accounts/tasks/remove_account.py:33 +#: accounts/const/automation.py:27 accounts/tasks/remove_account.py:25 +#: accounts/tasks/remove_account.py:40 msgid "Remove account" msgstr "移除账号" @@ -458,7 +458,7 @@ msgstr "账号备份计划" #: accounts/models/automations/backup_account.py:120 #: assets/models/automations/base.py:115 audits/models.py:65 -#: ops/models/base.py:55 ops/models/celery.py:88 ops/models/job.py:242 +#: ops/models/base.py:55 ops/models/celery.py:89 ops/models/job.py:242 #: ops/templates/ops/celery_task_log.html:101 #: perms/models/asset_permission.py:78 settings/serializers/feature.py:25 #: settings/templates/ldap/_msg_import_ldap_user.html:5 @@ -470,7 +470,7 @@ msgstr "开始日期" #: accounts/models/automations/backup_account.py:123 #: authentication/templates/authentication/_msg_oauth_bind.html:11 -#: notifications/notifications.py:194 +#: notifications/notifications.py:202 #: settings/templates/ldap/_msg_import_ldap_user.html:3 msgid "Time" msgstr "时间" @@ -571,7 +571,7 @@ msgstr "开始日期" #: accounts/models/automations/change_secret.py:42 #: assets/models/automations/base.py:116 ops/models/base.py:56 -#: ops/models/celery.py:89 ops/models/job.py:243 +#: ops/models/celery.py:90 ops/models/job.py:243 #: terminal/models/applet/host.py:142 msgid "Date finished" msgstr "结束日期" @@ -633,7 +633,7 @@ msgid "Address login" msgstr "最后登录地址" #: accounts/models/automations/gather_account.py:44 -#: accounts/tasks/gather_accounts.py:29 +#: accounts/tasks/gather_accounts.py:30 msgid "Gather asset accounts" msgstr "收集账号" @@ -708,7 +708,7 @@ msgstr "密码规则" #: authentication/serializers/connect_token_secret.py:113 #: authentication/serializers/connect_token_secret.py:169 labels/models.py:11 #: ops/mixin.py:21 ops/models/adhoc.py:20 ops/models/celery.py:15 -#: ops/models/celery.py:80 ops/models/job.py:142 ops/models/playbook.py:28 +#: ops/models/celery.py:81 ops/models/job.py:142 ops/models/playbook.py:28 #: ops/serializers/job.py:18 orgs/models.py:82 #: perms/models/asset_permission.py:61 rbac/models/role.py:29 #: rbac/serializers/role.py:28 settings/models.py:35 settings/models.py:184 @@ -887,7 +887,7 @@ msgstr "资产不存在" msgid "Has secret" msgstr "已托管密码" -#: accounts/serializers/account/account.py:272 ops/models/celery.py:83 +#: accounts/serializers/account/account.py:272 ops/models/celery.py:84 #: tickets/models/comment.py:13 tickets/models/ticket/general.py:49 #: tickets/models/ticket/general.py:280 tickets/serializers/super_ticket.py:14 msgid "State" @@ -1122,44 +1122,124 @@ msgstr "添加账号: %s" msgid "Delete account: %s" msgstr "删除账号: %s" -#: accounts/tasks/automation.py:31 +#: accounts/tasks/automation.py:32 msgid "Account execute automation" msgstr "账号执行自动化" -#: accounts/tasks/automation.py:57 accounts/tasks/automation.py:62 +#: accounts/tasks/automation.py:35 +msgid "" +"\n" +" Unified execution entry for account automation tasks: when the " +"system performs tasks \n" +" such as account push, password change, account verification, account " +"collection, \n" +" and gateway account verification, all tasks are executed through " +"this unified entry\n" +" " +msgstr "" +"\n" +"账号自动化任务统一执行入口,当系统执行账号推送,更改密码,验证账号,收集账" +"号,验证网关账号任务时,统一通过当前任务执行" + +#: accounts/tasks/automation.py:66 accounts/tasks/automation.py:76 msgid "Execute automation record" msgstr "自动化执行记录" -#: accounts/tasks/automation.py:86 +#: accounts/tasks/automation.py:69 +msgid "" +"\n" +" When manually executing password change records, this task is used\n" +" " +msgstr "" +"\n" +"当手动执行改密记录时,通过该任务执行" + +#: accounts/tasks/automation.py:100 msgid "Clean change secret and push record period" msgstr "周期清理改密记录和推送记录" -#: accounts/tasks/automation.py:87 -msgid "Clean change secret and push record period description" +#: accounts/tasks/automation.py:102 +msgid "" +"\n" +" Clean change secret and push record period description\n" +" " msgstr "" +"\n" "系统会定期清理不再需要的改密记录和推送记录,包括那些关联的改密任务、执行记" "录、资产和账号。当这些关联项中的任意一个被删除时,对应的改密和推送记录将变为" "无效。因此,为了保持数据库的整洁和高效运行,系统默认每180天自动清理这些无效记" "录。这种定期清理机制不仅有助于释放存储空间,还能提高数据管理的安全性和整体性" "能。" -#: accounts/tasks/backup_account.py:25 +#: accounts/tasks/backup_account.py:26 msgid "Execute account backup plan" msgstr "执行账号备份计划" -#: accounts/tasks/gather_accounts.py:34 +#: accounts/tasks/backup_account.py:29 +msgid "" +"\n" +" When performing scheduled or manual account backups, this task is " +"used\n" +" " +msgstr "" +"\n" +"定时或手动执行账号备份时,通过该任务执行" + +#: accounts/tasks/gather_accounts.py:32 assets/tasks/automation.py:27 +#: orgs/tasks.py:11 terminal/tasks.py:33 +msgid "Unused" +msgstr "未使用" + +#: accounts/tasks/gather_accounts.py:36 msgid "Gather assets accounts" msgstr "收集资产上的账号" -#: accounts/tasks/push_account.py:15 accounts/tasks/push_account.py:23 +#: accounts/tasks/push_account.py:16 accounts/tasks/push_account.py:29 msgid "Push accounts to assets" msgstr "推送账号到资产" -#: accounts/tasks/remove_account.py:44 +#: accounts/tasks/push_account.py:19 +msgid "" +"\n" +" When creating or modifying an account requires account push, this " +"task is executed\n" +" " +msgstr "" +"\n" +"当创建账号,修改账号时,需要账号推送时执行该任务" + +#: accounts/tasks/remove_account.py:28 +msgid "" +"\n" +" When clicking \"Sync deletion\" in 'Console - Gather Account - " +"Gathered accounts' this \n" +" task will be executed\n" +" " +msgstr "" +"\n" +"当在控制台-自动化-账号收集-收集的账号-点击同步删除会执行该任务" + +#: accounts/tasks/remove_account.py:52 msgid "Clean historical accounts" msgstr "清理历史账号" -#: accounts/tasks/remove_account.py:76 +#: accounts/tasks/remove_account.py:54 +msgid "" +"\n" +" Each time an asset account is updated, a historical account is " +"generated, so it is \n" +" necessary to clean up the asset account history. The system will " +"clean up excess account \n" +" records at 2 a.m. daily based on the configuration in the \"System " +"settings - Features - \n" +" Account storage - Record limit\n" +" " +msgstr "" +"\n" +"由于每次更新资产账号,都会生成历史账号,所以需要清理资产账号的历史。系统会根" +"据账号存储-记录限制的配置,每天凌晨2点对于超出的数量的账号记录进行清理" + +#: accounts/tasks/remove_account.py:93 msgid "Remove historical accounts that are out of range." msgstr "删除超出范围的历史帐户。" @@ -1167,15 +1247,47 @@ msgstr "删除超出范围的历史帐户。" msgid "Template sync info to related accounts" msgstr "同步信息到关联的账号" -#: accounts/tasks/vault.py:31 +#: accounts/tasks/template.py:14 +msgid "" +"\n" +" When clicking 'Sync new secret to accounts' in 'Console - Account - " +"Templates - \n" +" Accounts' this task will be executed\n" +" " +msgstr "" +"\n" +"当在控制台-账号模板-账号-同步更新账号信息点击同步时,执行该任务" + +#: accounts/tasks/vault.py:32 msgid "Sync secret to vault" msgstr "同步密文到 vault" -#: accounts/tasks/verify_account.py:49 +#: accounts/tasks/vault.py:34 +msgid "" +"\n" +" When clicking 'Sync' in 'System Settings - Features - Account " +"Storage' this task will \n" +" be executed\n" +" " +msgstr "" +"\n" +"在系统设置-功能设置-账号存储点击同步时,执行该任务" + +#: accounts/tasks/verify_account.py:50 msgid "Verify asset account availability" msgstr "验证资产账号可用性" -#: accounts/tasks/verify_account.py:55 +#: accounts/tasks/verify_account.py:53 +msgid "" +"\n" +" When clicking 'Test' in 'Console - Asset details - Accounts' this " +"task will be executed\n" +" " +msgstr "" +"\n" +"当在控制台-资产详情-账号点击测试执行该任务" + +#: accounts/tasks/verify_account.py:61 msgid "Verify accounts connectivity" msgstr "测试账号可连接性" @@ -2467,7 +2579,7 @@ msgstr "类型 该字段是必填项。" msgid "Protocols is required" msgstr "协议是必填的" -#: assets/signal_handlers/asset.py:26 assets/tasks/ping.py:35 +#: assets/signal_handlers/asset.py:26 assets/tasks/ping.py:42 msgid "Test assets connectivity " msgstr "测试资产可连接性" @@ -2475,48 +2587,106 @@ msgstr "测试资产可连接性" msgid "Gather asset hardware info" msgstr "收集资产硬件信息" -#: assets/tasks/automation.py:24 +#: assets/tasks/automation.py:25 msgid "Asset execute automation" msgstr "资产执行自动化" -#: assets/tasks/gather_facts.py:21 assets/tasks/gather_facts.py:27 +#: assets/tasks/gather_facts.py:22 assets/tasks/gather_facts.py:34 msgid "Gather assets facts" msgstr "收集资产信息" -#: assets/tasks/gather_facts.py:39 +#: assets/tasks/gather_facts.py:25 +msgid "" +"\n" +" When clicking 'Refresh hardware info' in 'Console - Asset Details - " +"Basic' this task \n" +" will be executed\n" +" " +msgstr "" +"\n" +"当在控制台资产详情-基本设置点击更新硬件信息执行该任务" + +#: assets/tasks/gather_facts.py:46 msgid "Update assets hardware info: " msgstr "更新资产硬件信息" -#: assets/tasks/gather_facts.py:47 +#: assets/tasks/gather_facts.py:54 msgid "Update node asset hardware information: " msgstr "更新节点资产硬件信息: " -#: assets/tasks/nodes_amount.py:16 +#: assets/tasks/nodes_amount.py:17 msgid "Check the amount of assets under the node" msgstr "检查节点下资产数量" -#: assets/tasks/nodes_amount.py:28 +#: assets/tasks/nodes_amount.py:19 +msgid "" +"\n" +" Manually verifying asset quantities updates the asset count for " +"nodes under the \n" +" current organization. This task will be called in the following two " +"cases: when updating \n" +" nodes and when the number of nodes exceeds 100\n" +" " +msgstr "" +"\n" +"手动校对资产数量更新当前组织下的节点资产数量;更新节点,当节点数大于100这两种" +"情况会调用该任务" + +#: assets/tasks/nodes_amount.py:37 msgid "" "The task of self-checking is already running and cannot be started repeatedly" msgstr "自检程序已经在运行,不能重复启动" -#: assets/tasks/nodes_amount.py:33 +#: assets/tasks/nodes_amount.py:43 msgid "Periodic check the amount of assets under the node" msgstr "周期性检查节点下资产数量" -#: assets/tasks/ping.py:20 assets/tasks/ping.py:26 +#: assets/tasks/nodes_amount.py:45 +msgid "" +"\n" +" Schedule the check_node_assets_amount_task to periodically update " +"the asset count of \n" +" all nodes under all organizations\n" +" " +msgstr "" +"\n" +"定时调用check_node_assets_amount_task任务,更新所有组织下所有节点的资产数量" + +#: assets/tasks/ping.py:20 assets/tasks/ping.py:33 msgid "Test assets connectivity" msgstr "测试资产可连接性" -#: assets/tasks/ping.py:42 +#: assets/tasks/ping.py:24 +msgid "" +"\n" +" When clicking 'Test Asset Connectivity' in 'Asset Details - Basic " +"Settings' this task \n" +" will be executed\n" +" " +msgstr "" +"\n" +"当资产详情-基本设置点击测试资产可连接性 执行该任务" + +#: assets/tasks/ping.py:49 msgid "Test if the assets under the node are connectable " msgstr "测试节点下资产是否可连接" -#: assets/tasks/ping_gateway.py:19 assets/tasks/ping_gateway.py:25 -#: assets/tasks/ping_gateway.py:34 +#: assets/tasks/ping_gateway.py:19 assets/tasks/ping_gateway.py:32 +#: assets/tasks/ping_gateway.py:41 msgid "Test gateways connectivity" msgstr "测试网关可连接性" +#: assets/tasks/ping_gateway.py:23 +msgid "" +"\n" +" When clicking 'Test Connection' in 'Domain Details - Gateway' this " +"task will be \n" +" executed\n" +" " +msgstr "" +"\n" +"当在网域详情-网关-测试连接时执行该任务" + #: assets/tasks/utils.py:16 msgid "Asset has been disabled, skipped: {}" msgstr "资产已经被禁用, 跳过: {}" @@ -2623,7 +2793,7 @@ msgstr "同意" msgid "Close" msgstr "关闭" -#: audits/const.py:41 ops/models/celery.py:84 +#: audits/const.py:41 ops/models/celery.py:85 #: terminal/models/session/sharing.py:128 tickets/const.py:25 #: xpack/plugins/cloud/const.py:67 msgid "Finished" @@ -2785,7 +2955,7 @@ msgid "Offline user session" msgstr "下线用户会话" #: audits/serializers.py:33 ops/models/adhoc.py:25 ops/models/base.py:16 -#: ops/models/base.py:53 ops/models/celery.py:86 ops/models/job.py:151 +#: ops/models/base.py:53 ops/models/celery.py:87 ops/models/job.py:151 #: ops/models/job.py:240 ops/models/playbook.py:30 #: terminal/models/session/sharing.py:25 msgid "Creator" @@ -2878,14 +3048,52 @@ msgstr "临时密码" msgid "Passkey" msgstr "Passkey" -#: audits/tasks.py:131 +#: audits/tasks.py:132 msgid "Clean audits session task log" msgstr "清理资产审计会话任务日志" -#: audits/tasks.py:145 +#: audits/tasks.py:134 +msgid "" +"\n" +" Since the system generates login logs, operation logs, file upload " +"logs, activity \n" +" logs, Celery execution logs, session recordings, and command " +"records, as well as password \n" +" change logs, it will clean up these records based on the periodic " +"cleanup configuration \n" +" in \"System Settings - Tasks\" The system will clean up login logs, " +"task logs, operation \n" +" logs, password change logs, upload and download logs, session logs, " +"activity records, \n" +" job center execution history logs, and cloud synchronization records " +"that exceed the set \n" +" time limit every day at 2 a.m., according to the periodic cleanup " +"configuration in \n" +" 'System Settings - Tasks'\n" +" " +msgstr "" +"\n" +"由于系统会产生登录日志,操作日志,文件上传日志,活动日志,celery执行日志,会" +"话录像和命令记录,改密日志,所以系统会根据系统设置-任务列表-定期清理配置对这" +"些记录进行清理。系统会根据系统设置-任务列表-定期清理的配置,对于超出时间的登" +"录日志、任务日志、操作日志、改密日志、上传下载日志、会话日志、活动记录、作业" +"中心执行历史日志、云同步记录日志于每天凌晨2点进行清理" + +#: audits/tasks.py:160 msgid "Upload FTP file to external storage" msgstr "上传 FTP 文件到外部存储" +#: audits/tasks.py:162 +msgid "" +"\n" +" If SERVER_REPLAY_STORAGE is configured, files uploaded through file " +"management will be \n" +" synchronized to external storage\n" +" " +msgstr "" +"\n" +"如果设置了SERVER_REPLAY_STORAGE,将通过文件管理上传的文件同步到外部存储" + #: authentication/api/access_key.py:39 msgid "Access keys can be created at most 10" msgstr "最多可以创建10个访问密钥" @@ -3526,10 +3734,21 @@ msgstr "IP 白名单" msgid "Is valid" msgstr "是否有效" -#: authentication/tasks.py:11 +#: authentication/tasks.py:12 msgid "Clean expired session" msgstr "清除过期会话" +#: authentication/tasks.py:14 +msgid "" +"\n" +" Since user logins create sessions, the system will clean up expired " +"sessions every 24 \n" +" hours\n" +" " +msgstr "" +"\n" +"由于用户登录系统会产生会话,系统会每24小时清理已经过期的会话" + #: authentication/templates/authentication/_access_key_modal.html:6 msgid "API key list" msgstr "API Key列表" @@ -4265,18 +4484,50 @@ msgstr "标签" # msgid "Labels" # msgstr "标签管理" -#: common/tasks.py:31 +#: common/tasks.py:32 msgid "Send email" msgstr "发件邮件" -#: common/tasks.py:58 +#: common/tasks.py:35 +msgid "" +"\n" +" This task will be executed when sending email notifications\n" +" " +msgstr "" +"\n" +"发送邮件消息时执行该任务" + +#: common/tasks.py:67 msgid "Send email attachment" msgstr "发送邮件附件" -#: common/tasks.py:80 terminal/tasks.py:58 -msgid "Upload session replay to external storage" +#: common/tasks.py:70 +msgid "" +"\n" +" When an account password is changed or an account backup generates " +"attachments, \n" +" this task needs to be executed for sending emails and handling " +"attachments\n" +" " +msgstr "" +"\n" +"当账号改密,账号备份产生附件,需要对发送邮件及附件,执行该任务" + +#: common/tasks.py:98 +msgid "Upload account backup to external storage" msgstr "上传会话录像到外部存储" +#: common/tasks.py:100 +msgid "" +"\n" +" When performing an account backup, this task needs to be executed to " +"external storage \n" +" (SFTP)\n" +" " +msgstr "" +"\n" +"当执行账号备份,需要到外部存储(sftp),执行该任务" + #: common/utils/ip/geoip/utils.py:26 msgid "Invalid ip" msgstr "无效 IP" @@ -4290,10 +4541,21 @@ msgstr "无效地址" msgid "Hello %s" msgstr "你好 %s" -#: common/utils/verify_code.py:16 +#: common/utils/verify_code.py:17 msgid "Send SMS code" msgstr "发送短信验证码" +#: common/utils/verify_code.py:19 +msgid "" +"\n" +" When resetting a password, forgetting a password, or verifying MFA, " +"this task needs to \n" +" be executed to send SMS messages\n" +" " +msgstr "" +"\n" +"当重置密码,忘记密码,验证mfa时,需要发送短信时执行该任务" + #: common/validators.py:16 msgid "Special char not allowed" msgstr "不能包含特殊字符" @@ -4406,10 +4668,21 @@ msgstr "{} 订阅" msgid "System message" msgstr "系统信息" -#: notifications/notifications.py:46 +#: notifications/notifications.py:47 msgid "Publish the station message" msgstr "发布站内消息" +#: notifications/notifications.py:49 +msgid "" +"\n" +" This task needs to be executed for sending internal messages for " +"system alerts, \n" +" work orders, and other notifications\n" +" " +msgstr "" +"\n" +"系统一些告警,工单等需要发送站内信时执行该任务" + #: ops/ansible/inventory.py:106 ops/models/job.py:65 msgid "No account available" msgstr "无可用账号" @@ -4640,7 +4913,7 @@ msgstr "模式" msgid "Module" msgstr "模块" -#: ops/models/adhoc.py:24 ops/models/celery.py:81 ops/models/job.py:144 +#: ops/models/adhoc.py:24 ops/models/celery.py:82 ops/models/job.py:144 #: terminal/models/component/task.py:14 msgid "Args" msgstr "参数" @@ -4671,23 +4944,23 @@ msgstr "汇总" msgid "Date last publish" msgstr "发布日期" -#: ops/models/celery.py:70 +#: ops/models/celery.py:71 msgid "Celery Task" msgstr "Celery 任务" -#: ops/models/celery.py:73 +#: ops/models/celery.py:74 msgid "Can view task monitor" msgstr "可以查看任务监控" -#: ops/models/celery.py:82 terminal/models/component/task.py:15 +#: ops/models/celery.py:83 terminal/models/component/task.py:15 msgid "Kwargs" msgstr "其它参数" -#: ops/models/celery.py:87 +#: ops/models/celery.py:88 msgid "Date published" msgstr "发布日期" -#: ops/models/celery.py:112 +#: ops/models/celery.py:113 msgid "Celery Task Execution" msgstr "Celery 任务执行" @@ -4800,34 +5073,121 @@ msgstr "任务 ID" msgid "You do not have permission for the current job." msgstr "你没有当前作业的权限。" -#: ops/tasks.py:50 +#: ops/tasks.py:52 msgid "Run ansible task" msgstr "运行 Ansible 任务" -#: ops/tasks.py:76 +#: ops/tasks.py:55 +msgid "" +"\n" +" Execute scheduled adhoc and playbooks, periodically invoking the " +"task for execution\n" +" " +msgstr "" +"\n" +"当执行定时的快捷命令,playbook,定时调用该任务执行" + +#: ops/tasks.py:85 msgid "Run ansible task execution" msgstr "开始执行 Ansible 任务" -#: ops/tasks.py:89 +#: ops/tasks.py:88 +msgid "" +"\n" +" Execute the task when manually adhoc or playbooks\n" +" " +msgstr "" +"\n" +"手动执行快捷命令,playbook时执行该任务" + +#: ops/tasks.py:104 msgid "Clear celery periodic tasks" msgstr "清理周期任务" -#: ops/tasks.py:110 +#: ops/tasks.py:106 +msgid "" +"\n" +" At system startup, clean up celery tasks that no longer exist\n" +" " +msgstr "" +"\n" +"系统启动时,清理已经不存在的celery任务" + +#: ops/tasks.py:132 msgid "Create or update periodic tasks" msgstr "创建或更新周期任务" -#: ops/tasks.py:118 +#: ops/tasks.py:134 +msgid "" +"\n" +" With version iterations, new tasks may be added, or task names and " +"execution times may \n" +" be modified. Therefore, upon system startup, tasks will be " +"registered or the parameters \n" +" of scheduled tasks will be updated\n" +" " +msgstr "" +"\n" +"随着版本迭代,可能会新增任务或者修改任务的名称,执行时间,所以在系统启动" +"时,,将会注册任务或者更新定时任务参数" + +#: ops/tasks.py:149 msgid "Periodic check service performance" msgstr "周期检测服务性能" -#: ops/tasks.py:124 +#: ops/tasks.py:151 +msgid "" +"\n" +" Check every hour whether each component is offline and whether the " +"CPU, memory, \n" +" and disk usage exceed the thresholds, and send an alert message to " +"the administrator\n" +" " +msgstr "" +"\n" +"每小时检测各组件是否离线,cpu,内存,硬盘使用率是否超过阈值,向管理员发送消息" +"预警" + +#: ops/tasks.py:163 msgid "Clean up unexpected jobs" msgstr "清理异常作业" -#: ops/tasks.py:131 +#: ops/tasks.py:165 +msgid "" +"\n" +" Due to exceptions caused by executing adhoc and playbooks in the Job " +"Center, \n" +" which result in the task status not being updated, the system will " +"clean up abnormal jobs \n" +" that have not been completed for more than 3 hours every hour and " +"mark these tasks as \n" +" failed\n" +" " +msgstr "" +"\n" +"由于作业中心执行快捷命令,playbook会产生异常,任务状态未更新完成,系统将每小" +"时执行清理超3小时未完成的异常作业,并将任务标记失败" + +#: ops/tasks.py:180 msgid "Clean job_execution db record" msgstr "清理作业中心执行历史" +#: ops/tasks.py:182 +msgid "" +"\n" +" Due to the execution of adhoc and playbooks in the Job Center, " +"execution records will \n" +" be generated. The system will clean up records that exceed the " +"retention period every day \n" +" at 2 a.m., based on the configuration of 'System Settings - Tasks - " +"Regular clean-up - \n" +" Job execution retention days'\n" +" " +msgstr "" +"\n" +"由于作业中心执行快捷命令,playbook,会产生j执行记录,系统会根据系统设置-任务" +"列表-定期清理-作业中心执行历史配置,每天凌晨2点对超出保存时间的记录进行清理" + #: ops/templates/ops/celery_task_log.html:4 msgid "Task log" msgstr "任务列表" @@ -4953,7 +5313,7 @@ msgstr "网关数量" msgid "Asset permissions amount" msgstr "资产授权数量" -#: orgs/tasks.py:9 +#: orgs/tasks.py:10 msgid "Refresh organization cache" msgstr "刷新组织缓存" @@ -5074,14 +5434,48 @@ msgstr "用户组" msgid "Groups amount" msgstr "用户组数量" -#: perms/tasks.py:27 +#: perms/tasks.py:28 msgid "Check asset permission expired" msgstr "校验资产授权规则已过期" -#: perms/tasks.py:40 +#: perms/tasks.py:30 +msgid "" +"\n" +" The cache of organizational collections, which have completed user " +"authorization tree \n" +" construction, will expire. Therefore, expired collections need to be " +"cleared from the \n" +" cache, and this task will be executed periodically based on the time " +"interval specified \n" +" by PERM_EXPIRED_CHECK_PERIODIC in the system configuration file " +"config.txt\n" +" " +msgstr "" +"\n" +"用户授权树已经构建完成的组织集合缓存会过期,所以需要将过期的集合从缓存中清理" +"掉,根据系统配置文件 config.txt 中 PERM_EXPIRED_CHECK_PERIODIC 的时间间隔定时" +"执行该任务" + +#: perms/tasks.py:51 msgid "Send asset permission expired notification" msgstr "发送资产权限过期通知" +#: perms/tasks.py:53 +msgid "" +"\n" +" Check every day at 10 a.m. and send a notification message to users " +"associated with \n" +" assets whose authorization is about to expire, as well as to the " +"organization's \n" +" administrators, 3 days in advance, to remind them that the asset " +"authorization will \n" +" expire in a few days\n" +" " +msgstr "" +"\n" +"每天上午10点检查,对资产授权即将过期的所关联的用户及该组织管理员提前三天发送" +"消息通知,提示资产还有几天即将过期" + #: perms/templates/perms/_msg_item_permissions_expire.html:7 #: perms/templates/perms/_msg_permed_items_expire.html:7 #, python-format @@ -6681,14 +7075,36 @@ msgid "" "in the workbench" msgstr "*! 如果启用,具有 RBAC 权限的用户将能够使用工作台中的所有工具" -#: settings/tasks/ldap.py:28 +#: settings/tasks/ldap.py:29 msgid "Periodic import ldap user" msgstr "周期导入 LDAP 用户" -#: settings/tasks/ldap.py:66 +#: settings/tasks/ldap.py:31 +msgid "" +"\n" +" When LDAP auto-sync is configured, this task will be invoked to " +"synchronize users\n" +" " +msgstr "" +"\n" +"当设置了LDAP自动同步,将调用该任务进行用户同步" + +#: settings/tasks/ldap.py:74 msgid "Registration periodic import ldap user task" msgstr "注册周期导入 LDAP 用户 任务" +#: settings/tasks/ldap.py:76 +msgid "" +"\n" +" When LDAP auto-sync parameters change, such as Crontab parameters, " +"the LDAP sync task \n" +" will be re-registered or updated, and this task will be invoked\n" +" " +msgstr "" +"\n" +"当设置了LDAP自动同步参数发生变化时,比如Crontab参数,重新注册或更新ldap同步任" +"务调用该任务" + #: settings/templates/ldap/_msg_import_ldap_user.html:2 msgid "Sync task finish" msgstr "同步任务完成" @@ -7038,7 +7454,7 @@ msgstr "命令存储" msgid "Invalid" msgstr "无效" -#: terminal/api/component/storage.py:132 terminal/tasks.py:149 +#: terminal/api/component/storage.py:132 terminal/tasks.py:201 msgid "Test failure: {}" msgstr "测试失败: {}" @@ -7552,7 +7968,7 @@ msgstr "级别" msgid "Command and replay storage" msgstr "命令及录像存储" -#: terminal/notifications.py:240 terminal/tasks.py:153 +#: terminal/notifications.py:240 terminal/tasks.py:205 #: xpack/plugins/cloud/api.py:160 #: xpack/plugins/cloud/serializers/account.py:121 #: xpack/plugins/cloud/serializers/account.py:123 @@ -7593,6 +8009,7 @@ msgid "" " eg: https://172.16.10.110 or https://dev.jumpserver.com\n" " " msgstr "" +" \n" "提示:应用发布机和 Core 服务进行通信使用,如果发布机和 Core 服务在同一网段," "建议填写内网地址,否则填写当前站点 URL
例如:https://172.16.10.110 or " "https://dev.jumpserver.com" @@ -8017,34 +8434,120 @@ msgstr "授权已过期" msgid "storage is null" msgstr "存储为空" -#: terminal/tasks.py:31 +#: terminal/tasks.py:32 msgid "Periodic delete terminal status" msgstr "周期清理终端状态" -#: terminal/tasks.py:39 +#: terminal/tasks.py:43 msgid "Clean orphan session" msgstr "清除离线会话" -#: terminal/tasks.py:87 +#: terminal/tasks.py:45 +msgid "" +"\n" +" Check every 10 minutes for asset connection sessions that have been " +"inactive for 3 \n" +" minutes and mark these sessions as completed\n" +" " +msgstr "" +"\n" +"每10分钟检查3分钟未活跃的资产连接会话,将这些会话标记未已完成" + +#: terminal/tasks.py:70 +msgid "Upload session replay to external storage" +msgstr "上传会话录像到外部存储" + +#: terminal/tasks.py:72 +msgid "" +"\n" +" If SERVER_REPLAY_STORAGE is configured in the config.txt, session " +"commands and \n" +" recordings will be uploaded to external storage\n" +" " +msgstr "" +"\n" +"如果设置了SERVER_REPLAY_STORAGE,将通过文件管理上传的文件同步到外部存储" + +#: terminal/tasks.py:106 msgid "Run applet host deployment" msgstr "运行应用机部署" -#: terminal/tasks.py:97 +#: terminal/tasks.py:109 +msgid "" +"\n" +" When deploying from the remote application publisher details page, " +"and the 'Deploy' \n" +" button is clicked, this task will be executed\n" +" " +msgstr "" +"\n" +"发布机部署,点击部署时,执行该任务" + +#: terminal/tasks.py:122 msgid "Install applet" msgstr "安装应用" -#: terminal/tasks.py:108 +#: terminal/tasks.py:125 +msgid "" +"\n" +" When the 'Deploy' button is clicked in the 'Remote Application' " +"section of the remote \n" +" application publisher details page, this task will be executed\n" +" " +msgstr "" +"\n" +"当远程应用发布机详情-远程应用,点击部署时,执行该任务" + +#: terminal/tasks.py:139 msgid "Uninstall applet" msgstr "卸载应用" -#: terminal/tasks.py:119 +#: terminal/tasks.py:142 +msgid "" +"\n" +" When the 'Uninstall' button is clicked in the 'Remote Application' " +"section of the \n" +" remote application publisher details page, this task will be " +"executed\n" +" " +msgstr "" +"\n" +"当远程应用发布机详情-远程应用,点击卸载时,执行该任务" + +#: terminal/tasks.py:156 msgid "Generate applet host accounts" msgstr "收集远程应用上的账号" -#: terminal/tasks.py:131 +#: terminal/tasks.py:159 +msgid "" +"\n" +" When a remote publishing server is created and an account needs to " +"be created \n" +" automatically, this task will be executed\n" +" " +msgstr "" +"\n" +"当创建远程发布机后,需要自动创建账号时,执行该任务" + +#: terminal/tasks.py:175 msgid "Check command replay storage connectivity" msgstr "检查命令及录像存储可连接性 " +#: terminal/tasks.py:177 +msgid "" +"\n" +" Check every day at midnight whether the external storage for " +"commands and recordings \n" +" is accessible. If it is not accessible, send a notification to the " +"recipients specified \n" +" in 'System Settings - Notifications - Subscription - Storage - " +"Connectivity'\n" +" " +msgstr "" +"\n" +"每天凌晨0点检查命令及录像外部存储是否可连接,不可连接发送给:系统设置-通知设" +"置-消息订阅-命令及录像存储设置的接收人" + #: terminal/templates/terminal/_msg_command_alert.html:10 msgid "view" msgstr "查看" @@ -8853,31 +9356,106 @@ msgid "" msgstr "" "管理员已开启'仅允许已存在用户登录',当前用户不在用户列表中,请联系管理员。" -#: users/signal_handlers.py:193 +#: users/signal_handlers.py:194 msgid "Clean up expired user sessions" msgstr "清除过期的用户会话" -#: users/tasks.py:25 +#: users/signal_handlers.py:196 +msgid "" +"\n" +" After logging in via the web, a user session record is created. At 2 " +"a.m. every day, \n" +" the system cleans up inactive user devices\n" +" " +msgstr "" +"\n" +"使用web登录后,会产生用户会话在线记录,每天凌晨2点,清理未在线的用户设备" + +#: users/tasks.py:26 msgid "Check password expired" msgstr "校验密码已过期" -#: users/tasks.py:39 +#: users/tasks.py:28 +msgid "" +"\n" +" Check every day at 10 AM whether the passwords of users in the " +"system are expired, \n" +" and send a notification 5 days in advance\n" +" " +msgstr "" +"\n" +"每天上午10点检查,系统中用户的密码是否过期,提前5天发送通知" + +#: users/tasks.py:48 msgid "Periodic check password expired" msgstr "周期校验密码过期" -#: users/tasks.py:53 +#: users/tasks.py:50 +msgid "" +"\n" +" With version iterations, new tasks may be added, or task names and " +"execution times may \n" +" be modified. Therefore, upon system startup, it is necessary to " +"register or update the \n" +" parameters of the task that checks if passwords have expired\n" +" " +msgstr "" +"\n" +"随着版本迭代,可能会新增任务或者修改任务的名称,执行时间,所以在系统启动时," +"注册或者更新校验密码已过期任务的参数" + +#: users/tasks.py:71 msgid "Check user expired" msgstr "校验用户已过期" -#: users/tasks.py:70 +#: users/tasks.py:73 +msgid "" +"\n" +" Check every day at 10 AM whether the users in the system are " +"expired, and send a \n" +" notification 5 days in advance\n" +" " +msgstr "" +"\n" +"每天上午10点检查,系统中的用户是否过期,提前5天发送通知" + +#: users/tasks.py:96 msgid "Periodic check user expired" msgstr "周期检测用户过期" -#: users/tasks.py:84 +#: users/tasks.py:98 +msgid "" +"\n" +" With version iterations, new tasks may be added, or task names and " +"execution times may \n" +" be modified. Therefore, upon system startup, it is necessary to " +"register or update the \n" +" parameters of the task that checks if users have expired\n" +" " +msgstr "" +"\n" +"随着版本迭代,可能会新增任务或者修改任务的名称,执行时间,所以在系统启动时," +"注册或者更新校验用户已过期任务的参数" + +#: users/tasks.py:119 msgid "Check unused users" msgstr "检查未使用的用户" -#: users/tasks.py:123 +#: users/tasks.py:121 +msgid "" +"\n" +" At 2 a.m. every day, according to the configuration in \"System " +"Settings - Security - \n" +" Auth security - Auto disable threshold\" users who have not logged " +"in or whose API keys \n" +" have not been used for a long time will be disabled\n" +" " +msgstr "" +"\n" +"每天凌晨2点,根据系统配置-安全设置-不活跃用户自动禁用配置,对长时间不登录或" +"api_key不使用的用户进行禁用" + +#: users/tasks.py:167 msgid "The user has not logged in recently and has been disabled." msgstr "该用户最近未登录,已被禁用。" @@ -9841,10 +10419,26 @@ msgstr "执行次数" msgid "Instance count" msgstr "实例个数" -#: xpack/plugins/cloud/tasks.py:44 +#: xpack/plugins/cloud/tasks.py:32 +msgid "" +"Execute this task when manually or scheduled cloud synchronization tasks are " +"performed" +msgstr "手动,定时执行云同步任务时执行该任务" + +#: xpack/plugins/cloud/tasks.py:46 msgid "Period clean sync instance task execution" msgstr "定期清除同步实例任务执行记录" +#: xpack/plugins/cloud/tasks.py:46 +msgid "" +"Every day, according to the \n" +"configuration in \"System Settings - Tasks - Regular clean-up - Cloud sync " +"task history retention days\" the system \n" +"will clean up the execution records generated by cloud synchronization" +msgstr "" +"每天根据系统设置-任务列表-定期清理配置-云同步记录配置,对云同步产生的执行记录" +"进行清理" + #: xpack/plugins/interface/api.py:52 msgid "Restore default successfully." msgstr "恢复默认成功!" diff --git a/apps/i18n/lina/en.json b/apps/i18n/lina/en.json index f641680c0..26fe94167 100644 --- a/apps/i18n/lina/en.json +++ b/apps/i18n/lina/en.json @@ -1396,5 +1396,6 @@ "ZoneUpdate": "Update the zone", "disallowSelfUpdateFields": "Not allowed to modify the current fields yourself", "forceEnableMFAHelpText": "If force enable, user can not disable by themselves", - "removeWarningMsg": "Are you sure you want to remove" + "removeWarningMsg": "Are you sure you want to remove", + "TaskPath": "Task path" } \ No newline at end of file diff --git a/apps/i18n/lina/zh.json b/apps/i18n/lina/zh.json index 309b2ff90..4df1b71c8 100644 --- a/apps/i18n/lina/zh.json +++ b/apps/i18n/lina/zh.json @@ -1399,5 +1399,6 @@ "ZoneUpdate": "更新网域", "disallowSelfUpdateFields": "不允许自己修改当前字段", "forceEnableMFAHelpText": "如果强制启用,用户无法自行禁用", - "removeWarningMsg": "你确定要移除" + "removeWarningMsg": "你确定要移除", + "TaskPath": "任务路径" } \ No newline at end of file diff --git a/apps/notifications/notifications.py b/apps/notifications/notifications.py index 11db34f98..abde60768 100644 --- a/apps/notifications/notifications.py +++ b/apps/notifications/notifications.py @@ -43,7 +43,15 @@ class MessageType(type): return clz -@shared_task(verbose_name=_('Publish the station message')) +@shared_task( + verbose_name=_('Publish the station message'), + description=_( + """ + This task needs to be executed for sending internal messages for system alerts, + work orders, and other notifications + """ + ) +) def publish_task(receive_user_ids, backends_msg_mapper): Message.send_msg(receive_user_ids, backends_msg_mapper) diff --git a/apps/ops/models/celery.py b/apps/ops/models/celery.py index 9e40cd921..f92317eeb 100644 --- a/apps/ops/models/celery.py +++ b/apps/ops/models/celery.py @@ -23,6 +23,7 @@ class CeleryTask(models.Model): task = app.tasks.get(self.name, None) return { "comment": getattr(task, 'verbose_name', None), + "description": getattr(task, 'description', None), "queue": getattr(task, 'queue', 'default') } diff --git a/apps/ops/tasks.py b/apps/ops/tasks.py index 2d6bcb375..3ec35a042 100644 --- a/apps/ops/tasks.py +++ b/apps/ops/tasks.py @@ -47,8 +47,15 @@ def _run_ops_job_execution(execution): @shared_task( - soft_time_limit=60, queue="ansible", verbose_name=_("Run ansible task"), - activity_callback=job_task_activity_callback + soft_time_limit=60, + queue="ansible", + verbose_name=_("Run ansible task"), + activity_callback=job_task_activity_callback, + description=_( + """ + Execute scheduled adhoc and playbooks, periodically invoking the task for execution + """ + ) ) def run_ops_job(job_id): with tmp_to_root_org(): @@ -73,8 +80,15 @@ def job_execution_task_activity_callback(self, execution_id, *args, **kwargs): @shared_task( - soft_time_limit=60, queue="ansible", verbose_name=_("Run ansible task execution"), - activity_callback=job_execution_task_activity_callback + soft_time_limit=60, + queue="ansible", + verbose_name=_("Run ansible task execution"), + activity_callback=job_execution_task_activity_callback, + description=_( + """ + Execute the task when manually adhoc or playbooks + """ + ) ) def run_ops_job_execution(execution_id, **kwargs): with tmp_to_root_org(): @@ -86,7 +100,14 @@ def run_ops_job_execution(execution_id, **kwargs): _run_ops_job_execution(execution) -@shared_task(verbose_name=_('Clear celery periodic tasks')) +@shared_task( + verbose_name=_('Clear celery periodic tasks'), + description=_( + """ + At system startup, clean up celery tasks that no longer exist + """ + ) +) @after_app_ready_start def clean_celery_periodic_tasks(): """清除celery定时任务""" @@ -107,7 +128,16 @@ def clean_celery_periodic_tasks(): logger.info('Clean task failure: {}'.format(task)) -@shared_task(verbose_name=_('Create or update periodic tasks')) +@shared_task( + verbose_name=_('Create or update periodic tasks'), + description=_( + """ + With version iterations, new tasks may be added, or task names and execution times may + be modified. Therefore, upon system startup, tasks will be registered or the parameters + of scheduled tasks will be updated + """ + ) +) @after_app_ready_start def create_or_update_registered_periodic_tasks(): from .celery.decorator import get_register_period_tasks @@ -115,20 +145,48 @@ def create_or_update_registered_periodic_tasks(): create_or_update_celery_periodic_tasks(task) -@shared_task(verbose_name=_("Periodic check service performance")) +@shared_task( + verbose_name=_("Periodic check service performance"), + description=_( + """ + Check every hour whether each component is offline and whether the CPU, memory, + and disk usage exceed the thresholds, and send an alert message to the administrator + """ + ) +) @register_as_period_task(interval=3600) def check_server_performance_period(): ServerPerformanceCheckUtil().check_and_publish() -@shared_task(verbose_name=_("Clean up unexpected jobs")) +@shared_task( + verbose_name=_("Clean up unexpected jobs"), + description=_( + """ + Due to exceptions caused by executing adhoc and playbooks in the Job Center, + which result in the task status not being updated, the system will clean up abnormal jobs + that have not been completed for more than 3 hours every hour and mark these tasks as + failed + """ + ) +) @register_as_period_task(interval=3600) def clean_up_unexpected_jobs(): with tmp_to_root_org(): JobExecution.clean_unexpected_execution() -@shared_task(verbose_name=_('Clean job_execution db record')) +@shared_task( + verbose_name=_('Clean job_execution db record'), + description=_( + """ + Due to the execution of adhoc and playbooks in the Job Center, execution records will + be generated. The system will clean up records that exceed the retention period every day + at 2 a.m., based on the configuration of 'System Settings - Tasks - Regular clean-up - + Job execution retention days' + """ + ) +) @register_as_period_task(crontab=CRONTAB_AT_AM_TWO) def clean_job_execution_period(): logger.info("Start clean job_execution db record") @@ -137,7 +195,8 @@ def clean_job_execution_period(): expired_day = now - datetime.timedelta(days=days) with tmp_to_root_org(): del_res = JobExecution.objects.filter(date_created__lt=expired_day).delete() - logger.info(f"clean job_execution db record success! delete {days} days {del_res[0]} records") + logger.info( + f"clean job_execution db record success! delete {days} days {del_res[0]} records") # 测试使用,注释隐藏 # @shared_task diff --git a/apps/orgs/tasks.py b/apps/orgs/tasks.py index 7e02a64a2..a23185362 100644 --- a/apps/orgs/tasks.py +++ b/apps/orgs/tasks.py @@ -6,7 +6,10 @@ from common.utils import get_logger logger = get_logger(__file__) -@shared_task(verbose_name=_("Refresh organization cache")) +@shared_task( + verbose_name=_("Refresh organization cache"), + description=_("Unused") +) def refresh_org_cache_task(*fields): from .caches import OrgResourceStatisticsCache OrgResourceStatisticsCache.refresh(*fields) diff --git a/apps/perms/tasks.py b/apps/perms/tasks.py index 82f97bf8c..d9e45a9f1 100644 --- a/apps/perms/tasks.py +++ b/apps/perms/tasks.py @@ -24,7 +24,17 @@ from perms.utils import UserPermTreeExpireUtil logger = get_logger(__file__) -@shared_task(verbose_name=_('Check asset permission expired')) +@shared_task( + verbose_name=_('Check asset permission expired'), + description=_( + """ + The cache of organizational collections, which have completed user authorization tree + construction, will expire. Therefore, expired collections need to be cleared from the + cache, and this task will be executed periodically based on the time interval specified + by PERM_EXPIRED_CHECK_PERIODIC in the system configuration file config.txt + """ + ) +) @register_as_period_task(interval=settings.PERM_EXPIRED_CHECK_PERIODIC) @atomic() @tmp_to_root_org() @@ -37,7 +47,17 @@ def check_asset_permission_expired(): UserPermTreeExpireUtil().expire_perm_tree_for_perms(perm_ids) -@shared_task(verbose_name=_('Send asset permission expired notification')) +@shared_task( + verbose_name=_('Send asset permission expired notification'), + description=_( + """ + Check every day at 10 a.m. and send a notification message to users associated with + assets whose authorization is about to expire, as well as to the organization's + administrators, 3 days in advance, to remind them that the asset authorization will + expire in a few days + """ + ) +) @register_as_period_task(crontab=CRONTAB_AT_AM_TEN) @atomic() @tmp_to_root_org() diff --git a/apps/settings/tasks/ldap.py b/apps/settings/tasks/ldap.py index 1882bf37b..86faa47cb 100644 --- a/apps/settings/tasks/ldap.py +++ b/apps/settings/tasks/ldap.py @@ -25,7 +25,14 @@ def sync_ldap_user(): LDAPSyncUtil().perform_sync() -@shared_task(verbose_name=_('Periodic import ldap user')) +@shared_task( + verbose_name=_('Periodic import ldap user'), + description=_( + """ + When LDAP auto-sync is configured, this task will be invoked to synchronize users + """ + ) +) def import_ldap_user(): start_time = time.time() time_start_display = local_now_display() @@ -63,7 +70,15 @@ def import_ldap_user(): LDAPImportMessage(user, extra_kwargs).publish() -@shared_task(verbose_name=_('Registration periodic import ldap user task')) +@shared_task( + verbose_name=_('Registration periodic import ldap user task'), + description=_( + """ + When LDAP auto-sync parameters change, such as Crontab parameters, the LDAP sync task + will be re-registered or updated, and this task will be invoked + """ + ) +) @after_app_ready_start def import_ldap_user_periodic(**kwargs): task_name = 'import_ldap_user_periodic' diff --git a/apps/terminal/tasks.py b/apps/terminal/tasks.py index 0892aeac5..4ed25b0f0 100644 --- a/apps/terminal/tasks.py +++ b/apps/terminal/tasks.py @@ -28,7 +28,10 @@ RUNNING = False logger = get_task_logger(__name__) -@shared_task(verbose_name=_('Periodic delete terminal status')) +@shared_task( + verbose_name=_('Periodic delete terminal status'), + description=_("Unused") +) @register_as_period_task(interval=3600) @after_app_ready_start def delete_terminal_status_period(): @@ -36,7 +39,15 @@ def delete_terminal_status_period(): Status.objects.filter(date_created__lt=yesterday).delete() -@shared_task(verbose_name=_('Clean orphan session')) +@shared_task( + verbose_name=_('Clean orphan session'), + description=_( + """ + Check every 10 minutes for asset connection sessions that have been inactive for 3 + minutes and mark these sessions as completed + """ + ) +) @register_as_period_task(interval=600) @after_app_ready_start @tmp_to_root_org() @@ -55,7 +66,15 @@ def clean_orphan_session(): session.save() -@shared_task(verbose_name=_('Upload session replay to external storage')) +@shared_task( + verbose_name=_('Upload session replay to external storage'), + description=_( + """ + If SERVER_REPLAY_STORAGE is configured in the config.txt, session commands and + recordings will be uploaded to external storage + """ + ) +) def upload_session_replay_to_external_storage(session_id): logger.info(f'Start upload session to external storage: {session_id}') session = Session.objects.filter(id=session_id).first() @@ -85,7 +104,13 @@ def upload_session_replay_to_external_storage(session_id): @shared_task( verbose_name=_('Run applet host deployment'), - activity_callback=lambda self, did, *args, **kwargs: ([did],) + activity_callback=lambda self, did, *args, **kwargs: ([did],), + description=_( + """ + When deploying from the remote application publisher details page, and the 'Deploy' + button is clicked, this task will be executed + """ + ) ) def run_applet_host_deployment(did, install_applets): with tmp_to_builtin_org(system=1): @@ -95,7 +120,13 @@ def run_applet_host_deployment(did, install_applets): @shared_task( verbose_name=_('Install applet'), - activity_callback=lambda self, ids, applet_id, *args, **kwargs: (ids,) + activity_callback=lambda self, ids, applet_id, *args, **kwargs: (ids,), + description=_( + """ + When the 'Deploy' button is clicked in the 'Remote Application' section of the remote + application publisher details page, this task will be executed + """ + ) ) def run_applet_host_deployment_install_applet(ids, applet_id): with tmp_to_builtin_org(system=1): @@ -106,7 +137,13 @@ def run_applet_host_deployment_install_applet(ids, applet_id): @shared_task( verbose_name=_('Uninstall applet'), - activity_callback=lambda self, ids, applet_id, *args, **kwargs: (ids,) + activity_callback=lambda self, ids, applet_id, *args, **kwargs: (ids,), + description=_( + """ + When the 'Uninstall' button is clicked in the 'Remote Application' section of the + remote application publisher details page, this task will be executed + """ + ) ) def run_applet_host_deployment_uninstall_applet(ids, applet_id): with tmp_to_builtin_org(system=1): @@ -117,7 +154,13 @@ def run_applet_host_deployment_uninstall_applet(ids, applet_id): @shared_task( verbose_name=_('Generate applet host accounts'), - activity_callback=lambda self, host_id, *args, **kwargs: ([host_id],) + activity_callback=lambda self, host_id, *args, **kwargs: ([host_id],), + description=_( + """ + When a remote publishing server is created and an account needs to be created + automatically, this task will be executed + """ + ) ) def applet_host_generate_accounts(host_id): applet_host = AppletHost.objects.filter(id=host_id).first() @@ -128,7 +171,16 @@ def applet_host_generate_accounts(host_id): applet_host.generate_accounts() -@shared_task(verbose_name=_('Check command replay storage connectivity')) +@shared_task( + verbose_name=_('Check command replay storage connectivity'), + description=_( + """ + Check every day at midnight whether the external storage for commands and recordings + is accessible. If it is not accessible, send a notification to the recipients specified + in 'System Settings - Notifications - Subscription - Storage - Connectivity' + """ + ) +) @register_as_period_task(crontab='0 0 * * *') @tmp_to_root_org() def check_command_replay_storage_connectivity(): diff --git a/apps/users/signal_handlers.py b/apps/users/signal_handlers.py index c7be331aa..27c629efc 100644 --- a/apps/users/signal_handlers.py +++ b/apps/users/signal_handlers.py @@ -190,7 +190,15 @@ def on_ldap_create_user(sender, user, ldap_user, **kwargs): user.save() -@shared_task(verbose_name=_('Clean up expired user sessions')) +@shared_task( + verbose_name=_('Clean up expired user sessions'), + description=_( + """ + After logging in via the web, a user session record is created. At 2 a.m. every day, + the system cleans up inactive user devices + """ + ) +) @register_as_period_task(crontab=CRONTAB_AT_AM_TWO) def clean_expired_user_session_period(): UserSession.clear_expired_sessions() diff --git a/apps/users/tasks.py b/apps/users/tasks.py index 7fd707ac7..a9ba74a4d 100644 --- a/apps/users/tasks.py +++ b/apps/users/tasks.py @@ -22,7 +22,15 @@ from .models import User logger = get_logger(__file__) -@shared_task(verbose_name=_('Check password expired')) +@shared_task( + verbose_name=_('Check password expired'), + description=_( + """ + Check every day at 10 AM whether the passwords of users in the system are expired, + and send a notification 5 days in advance + """ + ) +) def check_password_expired(): users = User.get_nature_users().filter(source=User.Source.local) for user in users: @@ -36,7 +44,16 @@ def check_password_expired(): PasswordExpirationReminderMsg(user).publish_async() -@shared_task(verbose_name=_('Periodic check password expired')) +@shared_task( + verbose_name=_('Periodic check password expired'), + description=_( + """ + With version iterations, new tasks may be added, or task names and execution times may + be modified. Therefore, upon system startup, it is necessary to register or update the + parameters of the task that checks if passwords have expired + """ + ) +) @after_app_ready_start def check_password_expired_periodic(): tasks = { @@ -50,7 +67,15 @@ def check_password_expired_periodic(): create_or_update_celery_periodic_tasks(tasks) -@shared_task(verbose_name=_('Check user expired')) +@shared_task( + verbose_name=_('Check user expired'), + description=_( + """ + Check every day at 10 AM whether the users in the system are expired, and send a + notification 5 days in advance + """ + ) +) def check_user_expired(): date_expired_lt = timezone.now() + timezone.timedelta(days=User.DATE_EXPIRED_WARNING_DAYS) users = User.get_nature_users() \ @@ -67,7 +92,16 @@ def check_user_expired(): UserExpirationReminderMsg(user).publish_async() -@shared_task(verbose_name=_('Periodic check user expired')) +@shared_task( + verbose_name=_('Periodic check user expired'), + description=_( + """ + With version iterations, new tasks may be added, or task names and execution times may + be modified. Therefore, upon system startup, it is necessary to register or update the + parameters of the task that checks if users have expired + """ + ) +) @after_app_ready_start def check_user_expired_periodic(): tasks = { @@ -81,7 +115,16 @@ def check_user_expired_periodic(): create_or_update_celery_periodic_tasks(tasks) -@shared_task(verbose_name=_('Check unused users')) +@shared_task( + verbose_name=_('Check unused users'), + description=_( + """ + At 2 a.m. every day, according to the configuration in "System Settings - Security - + Auth security - Auto disable threshold" users who have not logged in or whose API keys + have not been used for a long time will be disabled + """ + ) +) @register_as_period_task(crontab=CRONTAB_AT_PM_TWO) @tmp_to_root_org() def check_unused_users(): @@ -96,7 +139,8 @@ def check_unused_users(): seconds_to_subtract = uncommon_users_ttl * 24 * 60 * 60 t = timezone.now() - timedelta(seconds=seconds_to_subtract) last_login_q = Q(last_login__lte=t) | (Q(last_login__isnull=True) & Q(date_joined__lte=t)) - api_key_q = Q(date_api_key_last_used__lte=t) | (Q(date_api_key_last_used__isnull=True) & Q(date_joined__lte=t)) + api_key_q = Q(date_api_key_last_used__lte=t) | ( + Q(date_api_key_last_used__isnull=True) & Q(date_joined__lte=t)) users = User.objects \ .filter(date_joined__lt=t) \