mirror of https://github.com/jumpserver/jumpserver
perf: account task timing not triggered (#9564)
Co-authored-by: feng <1304903146@qq.com>pull/9565/head
parent
4109f2cb1c
commit
4ac214e91d
|
@ -1,6 +1,6 @@
|
|||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from accounts.tasks import execute_automation
|
||||
from assets.models.automations import (
|
||||
BaseAutomation as AssetBaseAutomation,
|
||||
AutomationExecution as AssetAutomationExecution
|
||||
|
@ -14,6 +14,10 @@ class AccountBaseAutomation(AssetBaseAutomation):
|
|||
proxy = True
|
||||
verbose_name = _("Account automation task")
|
||||
|
||||
@property
|
||||
def execute_task(self):
|
||||
return execute_automation
|
||||
|
||||
@property
|
||||
def execution_model(self):
|
||||
return AutomationExecution
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
from celery import shared_task
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from accounts.models import AccountBackupAutomation
|
||||
from common.utils import get_object_or_none, get_logger
|
||||
from orgs.utils import tmp_to_org, tmp_to_root_org
|
||||
|
||||
|
@ -12,6 +11,7 @@ logger = get_logger(__file__)
|
|||
|
||||
@shared_task(verbose_name=_('Execute account backup plan'))
|
||||
def execute_account_backup_plan(pid, trigger):
|
||||
from accounts.models import AccountBackupAutomation
|
||||
with tmp_to_root_org():
|
||||
plan = get_object_or_none(AccountBackupAutomation, pk=pid)
|
||||
if not plan:
|
||||
|
|
|
@ -4,12 +4,12 @@ from celery import current_task
|
|||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from assets.models.node import Node
|
||||
from assets.models.asset import Asset
|
||||
from assets.models.node import Node
|
||||
from assets.tasks import execute_automation
|
||||
from ops.mixin import PeriodTaskModelMixin
|
||||
from common.const.choices import Trigger
|
||||
from common.db.fields import EncryptJsonDictTextField
|
||||
from ops.mixin import PeriodTaskModelMixin
|
||||
from orgs.mixins.models import OrgModelMixin, JMSOrgBaseModel
|
||||
|
||||
|
||||
|
@ -47,9 +47,13 @@ class BaseAutomation(PeriodTaskModelMixin, JMSOrgBaseModel):
|
|||
assets = self.get_all_assets().prefetch_related('platform')
|
||||
return assets.group_by_platform()
|
||||
|
||||
@property
|
||||
def execute_task(self):
|
||||
return execute_automation
|
||||
|
||||
def get_register_task(self):
|
||||
name = f"automation_{self.type}_strategy_period_{str(self.id)[:8]}"
|
||||
task = execute_automation.name
|
||||
task = self.execute_task.name
|
||||
args = (str(self.id), Trigger.timing, self.type)
|
||||
kwargs = {}
|
||||
return name, task, args, kwargs
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
import abc
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework import serializers
|
||||
|
||||
from .celery.utils import (
|
||||
|
|
Loading…
Reference in New Issue