perf: update applet host deployment

pull/9075/head
Eric 2022-11-11 18:16:11 +08:00
parent 3abf2592d1
commit 8b351f49e5
2 changed files with 8 additions and 10 deletions

View File

@ -177,6 +177,6 @@
delay: 5
- name: Sync all remote applets
ansible.windows.win_shell: >
echo "TODO: Sync all remote applets"
when: Initial
ansible.windows.win_shell:
"tinkerd install all"

View File

@ -2,14 +2,14 @@ import os
from collections import defaultdict
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from rest_framework.exceptions import ValidationError
from simple_history.utils import bulk_create_with_history
from assets.models import Host
from common.db.models import JMSBaseModel
from common.utils import random_string
from assets.models import Host
__all__ = ['AppletHost', 'AppletHostDeployment']
@ -44,13 +44,11 @@ class AppletHost(Host):
raise ValidationError('Request user has no terminal')
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.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):
applets = self.applets.all()