diff --git a/apps/terminal/api/applet/host.py b/apps/terminal/api/applet/host.py index a2016255a..69ed5e0da 100644 --- a/apps/terminal/api/applet/host.py +++ b/apps/terminal/api/applet/host.py @@ -59,15 +59,18 @@ class AppletHostDeploymentViewSet(viewsets.ModelViewSet): ) @staticmethod - def start_deploy(instance): - task = run_applet_host_deployment.apply_async((instance.id,), task_id=str(instance.id)) + def start_deploy(instance, install_applets): + task = run_applet_host_deployment.apply_async((instance.id, install_applets,), + task_id=str(instance.id)) def create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) + validated_data = serializer.validated_data + install_applets = validated_data.pop('install_applets', True) instance = serializer.save() instance.save_task(instance.id) - transaction.on_commit(lambda: self.start_deploy(instance)) + transaction.on_commit(lambda: self.start_deploy(instance, install_applets)) return Response({'task': str(instance.id)}, status=201) @action(methods=['post'], detail=False) diff --git a/apps/terminal/automations/deploy_applet_host/__init__.py b/apps/terminal/automations/deploy_applet_host/__init__.py index c8e4d9e27..d1d76870e 100644 --- a/apps/terminal/automations/deploy_applet_host/__init__.py +++ b/apps/terminal/automations/deploy_applet_host/__init__.py @@ -17,10 +17,12 @@ CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) class DeployAppletHostManager: - def __init__(self, deployment: AppletHostDeployment, applet: Applet = None): + def __init__(self, deployment: AppletHostDeployment, applet: Applet = None, + install_applets: bool = True, **kwargs): self.deployment = deployment self.applet = applet self.run_dir = self.get_run_dir() + self.install_applets = bool(install_applets) @staticmethod def get_run_dir(): @@ -70,6 +72,7 @@ class DeployAppletHostManager: play["vars"]["BOOTSTRAP_TOKEN"] = bootstrap_token play["vars"]["HOST_ID"] = host_id play["vars"]["HOST_NAME"] = hostname + play["vars"]["INSTALL_APPLETS"] = self.install_applets return plays return self._generate_playbook("playbook.yml", handler) diff --git a/apps/terminal/automations/deploy_applet_host/playbook.yml b/apps/terminal/automations/deploy_applet_host/playbook.yml index 45289cd30..c517c9f2c 100644 --- a/apps/terminal/automations/deploy_applet_host/playbook.yml +++ b/apps/terminal/automations/deploy_applet_host/playbook.yml @@ -15,6 +15,7 @@ RDS_MaxDisconnectionTime: 60000 RDS_RemoteAppLogoffTimeLimit: 0 TinkerInstaller: Tinker_Installer.exe + INSTALL_APPLETS: true tasks: - name: Install RDS-RD-Server (RDS) @@ -273,3 +274,4 @@ ansible.windows.win_powershell: script: | tinkerd install all + when: INSTALL_APPLETS diff --git a/apps/terminal/models/applet/host.py b/apps/terminal/models/applet/host.py index 118cb05a9..0a1eab0f5 100644 --- a/apps/terminal/models/applet/host.py +++ b/apps/terminal/models/applet/host.py @@ -155,8 +155,8 @@ class AppletHostDeployment(JMSBaseModel): self.host.save() terminal.delete() from ...automations.deploy_applet_host import DeployAppletHostManager - manager = DeployAppletHostManager(self) - manager.run(**kwargs) + manager = DeployAppletHostManager(self, **kwargs) + manager.run() def install_applet(self, applet_id, **kwargs): from ...automations.deploy_applet_host import DeployAppletHostManager diff --git a/apps/terminal/serializers/applet_host.py b/apps/terminal/serializers/applet_host.py index 146cfd3bc..1e2b0bd16 100644 --- a/apps/terminal/serializers/applet_host.py +++ b/apps/terminal/serializers/applet_host.py @@ -134,6 +134,7 @@ class HostAppletSerializer(AppletSerializer): class AppletHostDeploymentSerializer(serializers.ModelSerializer): status = LabeledChoiceField(choices=Status.choices, label=_('Status'), default=Status.pending) + install_applets = serializers.BooleanField(default=True, label=_('Install applets'), write_only=True) class Meta: model = AppletHostDeployment @@ -142,7 +143,8 @@ class AppletHostDeploymentSerializer(serializers.ModelSerializer): 'status', 'date_created', 'date_updated', 'date_start', 'date_finished' ] - fields = fields_mini + ['comment'] + read_only_fields + write_only_fields = ['install_applets',] + fields = fields_mini + ['comment'] + read_only_fields + write_only_fields class AppletHostAccountSerializer(serializers.ModelSerializer): diff --git a/apps/terminal/tasks.py b/apps/terminal/tasks.py index 38ca1941a..71bb2aba7 100644 --- a/apps/terminal/tasks.py +++ b/apps/terminal/tasks.py @@ -91,10 +91,10 @@ def upload_session_replay_to_external_storage(session_id): verbose_name=_('Run applet host deployment'), activity_callback=lambda self, did, *args, **kwargs: ([did],) ) -def run_applet_host_deployment(did): +def run_applet_host_deployment(did, install_applets): with tmp_to_builtin_org(system=1): deployment = AppletHostDeployment.objects.get(id=did) - deployment.start() + deployment.start(install_applets=install_applets) @shared_task(