Skip to content
Open
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
29 changes: 25 additions & 4 deletions utilities/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
TIMEOUT_12MIN,
TIMEOUT_25MIN,
TIMEOUT_30MIN,
TIMEOUT_30SEC,
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
SiboWang1997 marked this conversation as resolved.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment thread
SiboWang1997 marked this conversation as resolved.
VIRT_HANDLER,
VIRT_LAUNCHER,
VIRTCTL,
Expand Down Expand Up @@ -2759,19 +2760,39 @@ def guest_reboot(vm: VirtualMachineForTests, os_type: str) -> None:
}

LOGGER.info("Stopping user agent")
run_os_command(vm=vm, command=commands["stop-user-agent"][os_type])
run_os_command(
vm=vm,
command=commands["stop-user-agent"][os_type],
ssh_timeout=TIMEOUT_30SEC if os_type == OS_FLAVOR_WINDOWS else TIMEOUT_5SEC,
)
wait_for_user_agent_down(vm=vm, timeout=TIMEOUT_2MIN)

LOGGER.info(f"Rebooting {vm.name} from guest")
run_os_command(vm=vm, command=commands["reboot"][os_type])
run_os_command(
vm=vm,
command=commands["reboot"][os_type],
ssh_timeout=TIMEOUT_30SEC if os_type == OS_FLAVOR_WINDOWS else TIMEOUT_5SEC,
)


def run_os_command(vm: VirtualMachineForTests, command: str, ssh_timeout: int = TIMEOUT_5SEC) -> Optional[str]:
"""Run a command over VM SSH.

def run_os_command(vm: VirtualMachineForTests, command: str) -> Optional[str]:
Args:
vm (VirtualMachineForTests): Target VM.
command (str): Command to execute remotely.
ssh_timeout (int): SSH command timeout in seconds.

Returns:
str: Command output.
None: When command contains "reboot" and ProxyCommandFailure occurs
(expected behavior as SSH disconnects during reboot).
"""
try:
return run_ssh_commands(
host=vm.ssh_exec,
commands=shlex.split(command),
timeout=5,
timeout=ssh_timeout,
tcp_timeout=TCP_TIMEOUT_30SEC,
)[0]
except ProxyCommandFailure:
Expand Down
Loading