mirror of https://github.com/jumpserver/jumpserver
perf: push dynamic user
parent
6593648554
commit
52541d1dad
|
@ -12,11 +12,14 @@ __all__ = [
|
||||||
|
|
||||||
|
|
||||||
@org_aware_func("assets")
|
@org_aware_func("assets")
|
||||||
def push_accounts_to_assets_util(accounts, assets):
|
def push_accounts_to_assets_util(accounts, assets, username=None):
|
||||||
from assets.models import PushAccountAutomation
|
from assets.models import PushAccountAutomation
|
||||||
task_name = gettext_noop("Push accounts to assets")
|
task_name = gettext_noop("Push accounts to assets")
|
||||||
task_name = PushAccountAutomation.generate_unique_name(task_name)
|
task_name = PushAccountAutomation.generate_unique_name(task_name)
|
||||||
account_usernames = list(accounts.values_list('username', flat=True))
|
if username is None:
|
||||||
|
account_usernames = list(accounts.values_list('username', flat=True))
|
||||||
|
else:
|
||||||
|
account_usernames = [username]
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'name': task_name,
|
'name': task_name,
|
||||||
|
@ -29,10 +32,10 @@ def push_accounts_to_assets_util(accounts, assets):
|
||||||
|
|
||||||
|
|
||||||
@shared_task(queue="ansible", verbose_name=_('Push accounts to assets'))
|
@shared_task(queue="ansible", verbose_name=_('Push accounts to assets'))
|
||||||
def push_accounts_to_assets(account_ids, asset_ids):
|
def push_accounts_to_assets(account_ids, asset_ids, username=None):
|
||||||
from assets.models import Asset, Account
|
from assets.models import Asset, Account
|
||||||
with tmp_to_root_org():
|
with tmp_to_root_org():
|
||||||
assets = Asset.objects.filter(id__in=asset_ids)
|
assets = Asset.objects.filter(id__in=asset_ids)
|
||||||
accounts = Account.objects.filter(id__in=account_ids)
|
accounts = Account.objects.filter(id__in=account_ids)
|
||||||
|
|
||||||
return push_accounts_to_assets_util(accounts, assets)
|
return push_accounts_to_assets_util(accounts, assets, username)
|
||||||
|
|
Loading…
Reference in New Issue