mirror of https://github.com/jumpserver/jumpserver
perf: applet host accounts should be inactive by default
parent
5e52d04df3
commit
e69bb9f83e
|
@ -11,7 +11,6 @@ from common.db.models import JMSBaseModel
|
||||||
from common.utils import random_string
|
from common.utils import random_string
|
||||||
from assets.models import Host
|
from assets.models import Host
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['AppletHost', 'AppletHostDeployment']
|
__all__ = ['AppletHost', 'AppletHostDeployment']
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ class AppletHost(Host):
|
||||||
)
|
)
|
||||||
applets = models.ManyToManyField(
|
applets = models.ManyToManyField(
|
||||||
'Applet', verbose_name=_('Applet'),
|
'Applet', verbose_name=_('Applet'),
|
||||||
through='AppletPublication', through_fields=('host', 'applet'),
|
through='AppletPublication', through_fields=('host', 'applet'),
|
||||||
)
|
)
|
||||||
LOCKING_ORG = '00000000-0000-0000-0000-000000000004'
|
LOCKING_ORG = '00000000-0000-0000-0000-000000000004'
|
||||||
|
|
||||||
|
@ -70,8 +69,8 @@ class AppletHost(Host):
|
||||||
status_applets['published'].append(applet)
|
status_applets['published'].append(applet)
|
||||||
|
|
||||||
for status, applets in status_applets.items():
|
for status, applets in status_applets.items():
|
||||||
self.publications.filter(applet__in=applets)\
|
self.publications.filter(applet__in=applets) \
|
||||||
.exclude(status=status)\
|
.exclude(status=status) \
|
||||||
.update(status=status)
|
.update(status=status)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -95,7 +94,7 @@ class AppletHost(Host):
|
||||||
account = account_model(
|
account = account_model(
|
||||||
username=username, secret=password, name=username,
|
username=username, secret=password, name=username,
|
||||||
asset_id=self.id, secret_type='password', version=1,
|
asset_id=self.id, secret_type='password', version=1,
|
||||||
org_id=self.LOCKING_ORG
|
org_id=self.LOCKING_ORG, is_active=False,
|
||||||
)
|
)
|
||||||
accounts.append(account)
|
accounts.append(account)
|
||||||
bulk_create_with_history(accounts, account_model, batch_size=20)
|
bulk_create_with_history(accounts, account_model, batch_size=20)
|
||||||
|
|
Loading…
Reference in New Issue