Merge branch 'pam' of github.com:jumpserver/jumpserver into pam

This commit is contained in:
ibuler 2025-03-06 10:23:26 +08:00
commit 56d0a6d0b0
7 changed files with 37 additions and 8 deletions

View File

@ -220,8 +220,6 @@ class CheckAccountManager(BaseManager):
def pre_run(self): def pre_run(self):
super().pre_run() super().pre_run()
self.assets = self.execution.get_all_assets() self.assets = self.execution.get_all_assets()
self.execution.date_start = timezone.now()
self.execution.save(update_fields=["date_start"])
def batch_check(self, handler): def batch_check(self, handler):
print("Engine: {}".format(handler.__class__.__name__)) print("Engine: {}".format(handler.__class__.__name__))

View File

@ -105,10 +105,16 @@ class BaseManager:
return self.execution.all_assets_group_by_platform() return self.execution.all_assets_group_by_platform()
def pre_run(self): def pre_run(self):
self.execution.date_start = timezone.now() date_start = timezone.now()
self.execution.date_start = date_start
self.execution.status = Status.running self.execution.status = Status.running
self.execution.save(update_fields=["date_start", "status"]) self.execution.save(update_fields=["date_start", "status"])
automation = self.execution.automation
if automation:
automation.last_execution_date = date_start
automation.save(update_fields=['last_execution_date'])
def update_execution(self): def update_execution(self):
self.duration = int(time.time() - self.time_start) self.duration = int(time.time() - self.time_start)
self.execution.date_finished = timezone.now() self.execution.date_finished = timezone.now()
@ -340,6 +346,7 @@ class PlaybookPrepareMixin:
if not platform.automation or not platform.automation.ansible_enabled: if not platform.automation or not platform.automation.ansible_enabled:
print(_(" - Platform {} ansible disabled").format(platform.name)) print(_(" - Platform {} ansible disabled").format(platform.name))
self.on_assets_not_ansible_enabled(assets) self.on_assets_not_ansible_enabled(assets)
return False
automation = platform.automation automation = platform.automation

View File

@ -0,0 +1,18 @@
# Generated by Django 4.1.13 on 2025-03-05 08:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assets', '0012_auto_20241204_1516'),
]
operations = [
migrations.AddField(
model_name='baseautomation',
name='last_execution_date',
field=models.DateTimeField(blank=True, null=True, verbose_name='Last execution date'),
),
]

View File

@ -27,6 +27,9 @@ class BaseAutomation(PeriodTaskModelMixin, JMSOrgBaseModel):
type = models.CharField(max_length=16, verbose_name=_("Type")) type = models.CharField(max_length=16, verbose_name=_("Type"))
is_active = models.BooleanField(default=True, verbose_name=_("Is active")) is_active = models.BooleanField(default=True, verbose_name=_("Is active"))
params = models.JSONField(default=dict, verbose_name=_("Parameters")) params = models.JSONField(default=dict, verbose_name=_("Parameters"))
last_execution_date = models.DateTimeField(
null=True, blank=True, verbose_name=_('Last execution date')
)
objects = BaseAutomationManager.from_queryset(models.QuerySet)() objects = BaseAutomationManager.from_queryset(models.QuerySet)()

View File

@ -23,7 +23,7 @@ class BaseAutomationSerializer(PeriodTaskSerializerMixin, BulkOrgResourceModelSe
class Meta: class Meta:
read_only_fields = [ read_only_fields = [
'date_created', 'date_updated', 'created_by', 'date_created', 'date_updated', 'created_by',
'periodic_display', 'executed_amount', 'type' 'periodic_display', 'executed_amount', 'type', 'last_execution_date'
] ]
mini_fields = [ mini_fields = [
'id', 'name', 'type', 'is_periodic', 'interval', 'id', 'name', 'type', 'is_periodic', 'interval',

View File

@ -1505,5 +1505,6 @@
"forceEnableMFAHelpText": "If force enable, user can not disable by themselves", "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",
"setVariable": "Set variable", "setVariable": "Set variable",
"IgnoreAlert": "Ignore alert" "IgnoreAlert": "Ignore alert",
"DeleteGatherAccountTitle": "Delete gather account"
} }

View File

@ -580,7 +580,7 @@
"Footer": "页脚", "Footer": "页脚",
"ForgotPasswordURL": "忘记密码链接", "ForgotPasswordURL": "忘记密码链接",
"FormatError": "格式错误", "FormatError": "格式错误",
"FoundAccountInAssetDeleteMsg": "删除从系统资产中发现的找好", "FoundAccountInAssetDeleteMsg": "删除从系统资产中发现的账号",
"Friday": "周五", "Friday": "周五",
"From": "从", "From": "从",
"FromTicket": "来自工单", "FromTicket": "来自工单",
@ -1026,7 +1026,7 @@
"RelevantCommand": "命令", "RelevantCommand": "命令",
"RelevantSystemUser": "系统用户", "RelevantSystemUser": "系统用户",
"RemoteAddr": "远端地址", "RemoteAddr": "远端地址",
"RemoteAssetFoundAccountDeleteMsg": "删除从远端资产中发现的找好", "RemoteAssetFoundAccountDeleteMsg": "删除从远端资产中发现的账号",
"Remove": "移除", "Remove": "移除",
"RemoveAssetFromNode": "从节点移除资产", "RemoveAssetFromNode": "从节点移除资产",
"RemoveSelected": "移除所选", "RemoveSelected": "移除所选",
@ -1504,5 +1504,7 @@
"forceEnableMFAHelpText": "如果强制启用,用户无法自行禁用", "forceEnableMFAHelpText": "如果强制启用,用户无法自行禁用",
"removeWarningMsg": "你确定要移除", "removeWarningMsg": "你确定要移除",
"setVariable": "设置参数", "setVariable": "设置参数",
"IgnoreAlert": "忽略警报" "IgnoreAlert": "忽略警报",
"DeleteGatherAccountTitle": "删除发现的账号"
} }