mirror of https://github.com/jumpserver/jumpserver
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.
32 lines
990 B
32 lines
990 B
12 months ago
|
from celery import shared_task
|
||
|
from django.utils.translation import gettext_noop, gettext_lazy as _
|
||
|
|
||
|
from accounts.const import AutomationTypes
|
||
|
from accounts.tasks.common import quickstart_automation_by_snapshot
|
||
|
from common.utils import get_logger
|
||
|
|
||
|
logger = get_logger(__file__)
|
||
|
|
||
|
__all__ = ['remove_accounts_task']
|
||
|
|
||
|
|
||
|
@shared_task(
|
||
|
queue="ansible", verbose_name=_('Remove accounts'),
|
||
|
activity_callback=lambda self, gather_account_ids, *args, **kwargs: (gather_account_ids, None)
|
||
|
)
|
||
|
def remove_accounts_task(gather_account_ids):
|
||
|
from accounts.models import GatheredAccount
|
||
|
|
||
|
gather_accounts = GatheredAccount.objects.filter(
|
||
|
id__in=gather_account_ids
|
||
|
)
|
||
|
task_name = gettext_noop("Remove accounts")
|
||
|
|
||
|
task_snapshot = {
|
||
|
'assets': [str(i.asset_id) for i in gather_accounts],
|
||
|
'gather_accounts': [str(i.id) for i in gather_accounts],
|
||
|
}
|
||
|
|
||
|
tp = AutomationTypes.remove_account
|
||
|
quickstart_automation_by_snapshot(task_name, tp, task_snapshot)
|