Skip to content

Commit

Permalink
Add support for ephemeral_deploy and enable_hw_sync parameters to dep…
Browse files Browse the repository at this point in the history
…loy() (#302)
  • Loading branch information
alanbach authored May 27, 2024
1 parent 18aad07 commit 5eac0fe
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
11 changes: 10 additions & 1 deletion maas/client/viscera/machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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}

Expand All @@ -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
Expand Down
40 changes: 40 additions & 0 deletions maas/client/viscera/tests/test_machines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 5eac0fe

Please sign in to comment.