Skip to content

Commit

Permalink
test-framework: update power cycle plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Gierszewski <[email protected]>
  • Loading branch information
Kamil Gierszewski committed Dec 10, 2024
1 parent faa649a commit 8ffb7a1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal_plugins/power_control_libvirt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ def post_setup(self):
def teardown(self):
pass

def power_cycle(self):
self.executor.run_expect_success(f"sudo virsh reset {TestRun.dut.virsh['vm_name']}")
def power_cycle(self, wait_for_connection: bool = False, delay_until_reboot: int = 0) -> None:
self.executor.run_expect_success(f"sudo virsh destroy {TestRun.dut.virsh['vm_name']}")
TestRun.executor.disconnect()
TestRun.executor.wait_for_connection(timedelta(seconds=TestRun.dut.virsh["reboot_timeout"]))
self.executor.run_expect_success(
f"(sleep {delay_until_reboot} && " f"sudo virsh start {TestRun.dut.virsh['vm_name']}) &"
)
if wait_for_connection:
TestRun.executor.wait_for_connection(
timedelta(seconds=TestRun.dut.virsh["reboot_timeout"])
)

def check_if_vm_exists(self, vm_name) -> bool:
return self.executor.run(f"sudo virsh list|grep -w {vm_name}").exit_code == 0
Expand Down

0 comments on commit 8ffb7a1

Please sign in to comment.