You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jumpserver/apps/accounts/tasks/common.py

19 lines
564 B

import uuid
from assets.tasks.common import generate_automation_execution_data
from common.const.choices import Trigger
def quickstart_automation_by_snapshot(task_name, tp, task_snapshot=None):
from accounts.models import AutomationExecution
data = generate_automation_execution_data(task_name, tp, task_snapshot)
pk = data['id']
if AutomationExecution.objects.filter(id=pk).exists():
data['id'] = str(uuid.uuid4())
execution = AutomationExecution.objects.create(
trigger=Trigger.manual, **data
)
execution.start()