Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR-300a #302

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading