mirror of https://github.com/jumpserver/jumpserver
perf: update applet host deployment
parent
3abf2592d1
commit
8b351f49e5
|
@ -177,6 +177,6 @@
|
||||||
delay: 5
|
delay: 5
|
||||||
|
|
||||||
- name: Sync all remote applets
|
- name: Sync all remote applets
|
||||||
ansible.windows.win_shell: >
|
ansible.windows.win_shell:
|
||||||
echo "TODO: Sync all remote applets"
|
"tinkerd install all"
|
||||||
when: Initial
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ import os
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext_lazy as _
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
from django.utils.translation import gettext_lazy as _
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
from simple_history.utils import bulk_create_with_history
|
from simple_history.utils import bulk_create_with_history
|
||||||
|
|
||||||
|
from assets.models import Host
|
||||||
from common.db.models import JMSBaseModel
|
from common.db.models import JMSBaseModel
|
||||||
from common.utils import random_string
|
from common.utils import random_string
|
||||||
from assets.models import Host
|
|
||||||
|
|
||||||
__all__ = ['AppletHost', 'AppletHostDeployment']
|
__all__ = ['AppletHost', 'AppletHostDeployment']
|
||||||
|
|
||||||
|
@ -44,13 +44,11 @@ class AppletHost(Host):
|
||||||
raise ValidationError('Request user has no terminal')
|
raise ValidationError('Request user has no terminal')
|
||||||
|
|
||||||
self.date_synced = timezone.now()
|
self.date_synced = timezone.now()
|
||||||
if not self.terminal:
|
if self.terminal == request_terminal:
|
||||||
|
self.save(update_fields=['date_synced'])
|
||||||
|
else:
|
||||||
self.terminal = request_terminal
|
self.terminal = request_terminal
|
||||||
self.save(update_fields=['terminal', 'date_synced'])
|
self.save(update_fields=['terminal', 'date_synced'])
|
||||||
elif self.terminal and self.terminal != request_terminal:
|
|
||||||
raise ValidationError('Terminal has been set')
|
|
||||||
else:
|
|
||||||
self.save(update_fields=['date_synced'])
|
|
||||||
|
|
||||||
def check_applets_state(self, applets_value_list):
|
def check_applets_state(self, applets_value_list):
|
||||||
applets = self.applets.all()
|
applets = self.applets.all()
|
||||||
|
|
Loading…
Reference in New Issue