feat: 同步删除远程机器账号

This commit is contained in:
feng
2023-12-06 18:48:35 +08:00
committed by 老广
parent 8f82ca9856
commit eca50874f0
28 changed files with 424 additions and 24 deletions

View File

@@ -0,0 +1,31 @@
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)