Skip to content

Commit

Permalink
Add support for ephemeral_deploy and enable_hw_sync
Browse files Browse the repository at this point in the history
parameters to deploy().

Closes: canonical#300
  • Loading branch information
alanbach committed Apr 25, 2024
1 parent 18aad07 commit 17b9841
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
9 changes: 8 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 Down Expand Up @@ -513,6 +515,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 17b9841

Please sign in to comment.