From 7897b9d2b234b05466f8dfcfa54f4696302d6055 Mon Sep 17 00:00:00 2001 From: Alan Baghumian Date: Thu, 25 Apr 2024 16:05:05 -0700 Subject: [PATCH] Add support for ephemeral_deploy and enable_hw_sync parameters to deploy(). closes: 300 --- maas/client/viscera/machines.py | 11 +++++- maas/client/viscera/tests/test_machines.py | 40 ++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/maas/client/viscera/machines.py b/maas/client/viscera/machines.py index db42cc2..f9ac96d 100644 --- a/maas/client/viscera/machines.py +++ b/maas/client/viscera/machines.py @@ -480,7 +480,9 @@ async def deploy( comment: str = None, wait: bool = False, install_kvm: bool = False, - wait_interval: int = 5 + wait_interval: int = 5, + ephemeral_deploy: bool = False, + enable_hw_sync: bool = False ): """Deploy this machine. @@ -494,6 +496,8 @@ async def deploy( :param comment: A comment for the event log. :param wait: If specified, wait until the deploy is complete. :param wait_interval: How often to poll, defaults to 5 seconds + :param ephemeral_deploy: Deploy a machine in Ephemeral mode + :param enable_hw_sync: Enables periodic hardware sync """ params = {"system_id": self.system_id} @@ -513,6 +517,11 @@ async def deploy( params["hwe_kernel"] = hwe_kernel if comment is not None: params["comment"] = comment + if ephemeral_deploy: + params["ephemeral_deploy"] = ephemeral_deploy + if enable_hw_sync: + params["enable_hw_sync"] = enable_hw_sync + self._reset(await self._handler.deploy(**params)) if not wait: return self diff --git a/maas/client/viscera/tests/test_machines.py b/maas/client/viscera/tests/test_machines.py index 939afcc..62d97ad 100644 --- a/maas/client/viscera/tests/test_machines.py +++ b/maas/client/viscera/tests/test_machines.py @@ -259,6 +259,46 @@ def test__deploy_with_kvm_install(self): system_id=machine.system_id, install_kvm=True ) + def test__deploy_with_ephemeral_deploy(self): + system_id = make_name_without_spaces("system-id") + hostname = make_name_without_spaces("hostname") + data = { + "system_id": system_id, + "hostname": hostname, + "status": NodeStatus.READY, + } + deploying_data = { + "system_id": system_id, + "hostname": hostname, + "status": NodeStatus.DEPLOYING, + } + machine = make_machines_origin().Machine(data) + machine._handler.deploy.return_value = deploying_data + machine.deploy(ephemeral_deploy=True, wait=False) + machine._handler.deploy.assert_called_once_with( + system_id=machine.system_id, ephemeral_deploy=True + ) + + def test__deploy_with_enable_hw_sync(self): + system_id = make_name_without_spaces("system-id") + hostname = make_name_without_spaces("hostname") + data = { + "system_id": system_id, + "hostname": hostname, + "status": NodeStatus.READY, + } + deploying_data = { + "system_id": system_id, + "hostname": hostname, + "status": NodeStatus.DEPLOYING, + } + machine = make_machines_origin().Machine(data) + machine._handler.deploy.return_value = deploying_data + machine.deploy(enable_hw_sync=True, wait=False) + machine._handler.deploy.assert_called_once_with( + system_id=machine.system_id, enable_hw_sync=True + ) + def test__deploy_with_wait_failed(self): system_id = make_name_without_spaces("system-id") hostname = make_name_without_spaces("hostname")