perf: change translate

pull/14345/head
ibuler 2024-10-16 15:02:44 +08:00
parent c2218a5bca
commit 4c3cfcbf23
16 changed files with 5255 additions and 5157 deletions

View File

@ -33,7 +33,7 @@ class ChangeSecretManager(AccountBasePlaybookManager):
'secret_strategy', SecretStrategy.custom
)
self.ssh_key_change_strategy = self.execution.snapshot.get(
'ssh_key_change_strategy', SSHKeyStrategy.add
'ssh_key_change_strategy', SSHKeyStrategy.set_jms
)
self.account_ids = self.execution.snapshot['accounts']
self.name_recorder_mapper = {} # 做个映射,方便后面处理

View File

@ -49,9 +49,9 @@ class SecretStrategy(models.TextChoices):
class SSHKeyStrategy(models.TextChoices):
add = 'add', _('Append SSH KEY')
set = 'set', _('Empty and append SSH KEY')
# add = 'add', _('Append SSH KEY')
set_jms = 'set_jms', _('Replace (Replace only keys pushed by JumpServer) ')
set = 'set', _('Empty and append SSH KEY')
class TriggerChoice(models.TextChoices, TreeChoices):

View File

@ -50,7 +50,15 @@ class Migration(migrations.Migration):
('secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='Secret')),
('secret_strategy', models.CharField(choices=[('specific', 'Specific secret'), ('random', 'Random generate')], default='specific', max_length=16, verbose_name='Secret strategy')),
('password_rules', models.JSONField(default=dict, verbose_name='Password rules')),
('ssh_key_change_strategy', models.CharField(choices=[('add', 'Append SSH KEY'), ('set', 'Empty and append SSH KEY'), ('set_jms', 'Replace (Replace only keys pushed by JumpServer) ')], default='add', max_length=16, verbose_name='SSH key change strategy')),
('ssh_key_change_strategy', models.CharField(
choices=[
("set_jms", "Replace (Replace only keys pushed by JumpServer) "),
("set", "Empty and append SSH KEY"),
],
default="set_jms",
max_length=16,
verbose_name="SSH key change strategy",
)),
],
options={
'verbose_name': 'Change secret automation',
@ -76,7 +84,15 @@ class Migration(migrations.Migration):
('secret', common.db.fields.EncryptTextField(blank=True, null=True, verbose_name='Secret')),
('secret_strategy', models.CharField(choices=[('specific', 'Specific secret'), ('random', 'Random generate')], default='specific', max_length=16, verbose_name='Secret strategy')),
('password_rules', models.JSONField(default=dict, verbose_name='Password rules')),
('ssh_key_change_strategy', models.CharField(choices=[('add', 'Append SSH KEY'), ('set', 'Empty and append SSH KEY'), ('set_jms', 'Replace (Replace only keys pushed by JumpServer) ')], default='add', max_length=16, verbose_name='SSH key change strategy')),
('ssh_key_change_strategy', models.CharField(
choices=[
("set_jms", "Replace (Replace only keys pushed by JumpServer) "),
("set", "Empty and append SSH KEY"),
],
default="set_jms",
max_length=16,
verbose_name="SSH key change strategy",
)),
('triggers', models.JSONField(default=list, max_length=16, verbose_name='Triggers')),
('username', models.CharField(max_length=128, verbose_name='Username')),
('action', models.CharField(max_length=16, verbose_name='Action')),

View File

@ -15,4 +15,14 @@ class Migration(migrations.Migration):
name="secret_reset",
field=models.BooleanField(default=True, verbose_name="Secret reset"),
),
migrations.AddField(
model_name="accountbackupautomation",
name="start_time",
field=models.DateTimeField(
blank=True,
help_text="Datetime when the schedule should begin triggering the task to run",
null=True,
verbose_name="Start Datetime",
),
),
]

View File

@ -57,6 +57,7 @@ class Account(AbsConnectivity, LabeledMixin, BaseAccount):
history = AccountHistoricalRecords(included_fields=['id', '_secret', 'secret_type', 'version'])
source = models.CharField(max_length=30, default=Source.LOCAL, verbose_name=_('Source'))
source_id = models.CharField(max_length=128, null=True, blank=True, verbose_name=_('Source ID'))
date_last_access = models.DateTimeField(null=True, blank=True, verbose_name=_('Date last access'))
class Meta:
verbose_name = _('Account')

View File

@ -51,7 +51,7 @@ class AutomationExecution(AssetAutomationExecution):
class ChangeSecretMixin(SecretWithRandomMixin):
ssh_key_change_strategy = models.CharField(
choices=SSHKeyStrategy.choices, max_length=16,
default=SSHKeyStrategy.add, verbose_name=_('SSH key change strategy')
default=SSHKeyStrategy.set_jms, verbose_name=_('SSH key change strategy')
)
get_all_assets: callable # get all assets

View File

@ -41,7 +41,8 @@ class ChangeSecretAutomationSerializer(AuthValidateMixin, BaseAutomationSerializ
choices=SecretStrategy.choices, required=True, label=_('Secret strategy')
)
ssh_key_change_strategy = LabeledChoiceField(
choices=SSHKeyStrategy.choices, required=False, label=_('SSH Key strategy')
choices=SSHKeyStrategy.choices, required=False, label=_('SSH Key strategy'),
default="set_jms"
)
password_rules = PasswordRulesSerializer(required=False, label=_('Password rules'))
secret_type = LabeledChoiceField(choices=get_secret_types(), required=True, label=_('Secret type'))
@ -51,13 +52,15 @@ class ChangeSecretAutomationSerializer(AuthValidateMixin, BaseAutomationSerializ
read_only_fields = BaseAutomationSerializer.Meta.read_only_fields
fields = BaseAutomationSerializer.Meta.fields + read_only_fields + [
'secret_type', 'secret_strategy', 'secret', 'password_rules',
'ssh_key_change_strategy', 'passphrase', 'recipients', 'params'
'ssh_key_change_strategy', 'passphrase', 'params',
'recipients',
]
extra_kwargs = {**BaseAutomationSerializer.Meta.extra_kwargs, **{
'accounts': {'required': True, 'help_text': _('Please enter your account username')},
'recipients': {'label': _('Recipient'), 'help_text': _(
"Currently only mail sending is supported"
)},
'pre_recipients': {'help_text': _("Notification before execution")},
'params': {'help_text': _(
"Secret parameter settings, currently only effective for assets of the host type."
)},

View File

@ -0,0 +1,23 @@
# Generated by Django 4.1.13 on 2024-10-15 02:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("assets", "0005_myasset"),
]
operations = [
migrations.AddField(
model_name="baseautomation",
name="start_time",
field=models.DateTimeField(
blank=True,
help_text="Datetime when the schedule should begin triggering the task to run",
null=True,
verbose_name="Start Datetime",
),
),
]

View File

@ -215,7 +215,7 @@ msgstr "移除账号"
#: accounts/const/automation.py:28
msgid "Gather accounts"
msgstr "收集账号"
msgstr "账号发现"
#: accounts/const/automation.py:29
msgid "Verify gateway account"
@ -528,11 +528,11 @@ msgstr "创建改密执行"
#: accounts/models/automations/base.py:38
msgid "Can view gather accounts execution"
msgstr "查看收集账号执行"
msgstr "查看账号发现执行"
#: accounts/models/automations/base.py:39
msgid "Can add gather accounts execution"
msgstr "创建收集账号执行"
msgstr "创建账号发现执行"
#: accounts/models/automations/base.py:41
msgid "Can view push account execution"
@ -637,7 +637,7 @@ msgstr "最后登录地址"
#: accounts/models/automations/gather_account.py:44
#: accounts/tasks/gather_accounts.py:30
msgid "Gather asset accounts"
msgstr "收集账号"
msgstr "账号发现"
#: accounts/models/automations/gather_account.py:56
msgid "Is sync account"
@ -645,7 +645,7 @@ msgstr "是否同步账号"
#: accounts/models/automations/gather_account.py:75
msgid "Gather account automation"
msgstr "自动化收集账号"
msgstr "自动化账号发现"
#: accounts/models/automations/push_account.py:14
msgid "Triggers"
@ -1233,7 +1233,7 @@ msgid ""
" "
msgstr ""
"\n"
"当在控制台-自动化-账号收集-收集的账号-点击同步删除会执行该任务"
"当在控制台-自动化-账号收集-发现的账号-点击同步删除会执行该任务"
#: accounts/tasks/remove_account.py:52
msgid "Clean historical accounts"
@ -2526,11 +2526,11 @@ msgstr "启用账号收集"
#: assets/serializers/platform.py:67
msgid "Enable account collection"
msgstr "自动化收集账号"
msgstr "自动化账号发现"
#: assets/serializers/platform.py:70
msgid "Gather accounts method"
msgstr "收集账号方式"
msgstr "账号发现方式"
#: assets/serializers/platform.py:76
msgid "Remove accounts enabled"
@ -5673,7 +5673,7 @@ msgstr "备份账号"
#: rbac/tree.py:51
msgid "Gather account"
msgstr "收集账号"
msgstr "账号发现"
#: rbac/tree.py:53
msgid "Account change secret"

View File

@ -2397,7 +2397,7 @@ msgstr "啟用帳號收集"
#: assets/serializers/platform.py:67
msgid "Enable account collection"
msgstr "自动收集账号"
msgstr "自动账号发现"
#: assets/serializers/platform.py:70
msgid "Gather accounts method"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -17,11 +17,11 @@
"AccountChangeSecretDetail": "账号改密详情",
"AccountDeleteConfirmMsg": "删除账号,是否继续?",
"AccountExportTips": "导出信息中包含账号密文涉及敏感信息导出的格式为一个加密的zip文件若没有设置加密密码请前往个人信息中设置文件加密密码。",
"AccountGatherDetail": "账号发现详情",
"AccountGatherList": "账号发现",
"AccountGatherTaskCreate": "创建账号发现任务",
"AccountGatherTaskList": "账号发现任务",
"AccountGatherTaskUpdate": "更新账号发现任务",
"AccountDiscoverDetail": "账号发现详情",
"AccountDiscoverList": "账号发现",
"AccountDiscoverTaskCreate": "创建账号发现任务",
"AccountDiscoverTaskList": "账号发现任务",
"AccountDiscoverTaskUpdate": "更新账号发现任务",
"AccountList": "账号",
"AccountPolicy": "账号策略",
"AccountPolicyHelpText": "创建时对于不符合要求的账号,如:密钥类型不合规,唯一键约束,可选择以上策略。",
@ -185,7 +185,7 @@
"BaseAccount": "账号",
"BaseAccountBackup": "账号备份",
"BaseAccountChangeSecret": "账号改密",
"BaseAccountGather": "账号采集",
"BaseAccountDiscover": "账号采集",
"BaseAccountPush": "账号推送",
"BaseAccountTemplate": "账号模版",
"BaseApplets": "应用",
@ -493,7 +493,7 @@
"Execute": "执行",
"ExecuteOnce": "执行一次",
"ExecutionDetail": "执行详情",
"ExecutionList": "执行列表",
"ExecutionList": "执行记录",
"ExistError": "这个元素已经存在",
"Existing": "已存在",
"ExpirationTimeout": "过期超时时间(秒)",
@ -546,9 +546,9 @@
"GatewayList": "网关列表",
"GatewayPlatformHelpText": "网关平台只能选择以 Gateway 开头的平台",
"GatewayUpdate": "更新网关",
"GatherAccounts": "账号发现",
"GatherAccountsHelpText": "收集资产上的账号信息。收集后的账号信息可以导入到系统中,方便统一管理",
"GatheredAccountList": "收集的账号",
"DiscoverAccounts": "账号发现",
"DiscoverAccountsHelpText": "收集资产上的账号信息。收集后的账号信息可以导入到系统中,方便统一管理",
"GatheredAccountList": "发现的账号",
"General": "基本",
"GeneralAccounts": "普通账号",
"GeneralSetting": "通用配置",
@ -639,7 +639,7 @@
"IsFinished": "完成",
"IsLocked": "是否暂停",
"IsSuccess": "成功",
"IsSyncAccountHelpText": "收集完成后会把收集的账号同步到资产",
"IsSyncAccountHelpText": "收集完成后会把发现的账号同步到资产",
"IsSyncAccountLabel": "同步到资产",
"JDCloud": "京东云",
"Job": "作业",

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
# Generated by Django 4.1.13 on 2024-10-15 02:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("ops", "0003_alter_adhoc_unique_together_and_more"),
]
operations = [
migrations.AddField(
model_name="historicaljob",
name="start_time",
field=models.DateTimeField(
blank=True,
help_text="Datetime when the schedule should begin triggering the task to run",
null=True,
verbose_name="Start Datetime",
),
),
migrations.AddField(
model_name="job",
name="start_time",
field=models.DateTimeField(
blank=True,
help_text="Datetime when the schedule should begin triggering the task to run",
null=True,
verbose_name="Start Datetime",
),
),
]

View File

@ -34,6 +34,14 @@ class PeriodTaskModelMixin(models.Model):
crontab = models.CharField(
blank=True, max_length=128, null=True, verbose_name=_("Crontab"),
)
start_time = models.DateTimeField(
blank=True, null=True,
verbose_name=_('Start Datetime'),
help_text=_(
'Datetime when the schedule should begin '
'triggering the task to run'
),
)
objects = PeriodTaskModelQuerySet.as_manager()
@abc.abstractmethod
@ -73,6 +81,7 @@ class PeriodTaskModelMixin(models.Model):
'args': args,
'kwargs': kwargs,
'enabled': True,
'start_time': self.start_time,
}
}
create_or_update_celery_periodic_tasks(tasks)
@ -113,13 +122,19 @@ class PeriodTaskSerializerMixin(serializers.Serializer):
allow_null=True, required=False, label=_('Crontab')
)
interval = serializers.IntegerField(
default=24, allow_null=True, required=False, label=_('Interval')
default=24, allow_null=True, required=False, label=_('Interval'),
max_value=65535, min_value=1,
)
start_time = serializers.DateTimeField(
allow_null=True, required=False,
label=_('Start Datetime'),
help_text=_(
'Datetime when the schedule should begin '
'triggering the task to run'
),
)
periodic_display = serializers.CharField(read_only=True, label=_('Run period'))
INTERVAL_MAX = 65535
INTERVAL_MIN = 1
def validate_crontab(self, crontab):
if not crontab:
return crontab
@ -131,9 +146,6 @@ class PeriodTaskSerializerMixin(serializers.Serializer):
def validate_interval(self, interval):
if not interval and not isinstance(interval, int):
return interval
msg = _("Range {} to {}").format(self.INTERVAL_MIN, self.INTERVAL_MAX)
if interval > self.INTERVAL_MAX or interval < self.INTERVAL_MIN:
raise serializers.ValidationError(msg)
return interval
def validate_is_periodic(self, ok):