Skip to content

Commit

Permalink
Update hyperv.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SRIKKANTH committed Jan 4, 2025
1 parent e1ab6c6 commit 7099aba
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lisa/tools/hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,16 @@ def enable_device_passthrough(self, name: str, mmio_mb: int = 5120) -> None:
def get_default_switch(
self, switch_type: HypervSwitchType = HypervSwitchType.EXTERNAL
) -> Optional[VMSwitch]:
if switch_type in (HypervSwitchType.INTERNAL, HypervSwitchType.EXTERNAL):
switch_json = self.node.tools[PowerShell].run_cmdlet(
f'Get-VMSwitch | Where-Object {{$_.SwitchType -eq "{switch_type}"}}'
"| Select -First 1 | select Name | ConvertTo-Json",
force_run=True,
fail_on_error=False,
)
else:
if switch_type not in (HypervSwitchType.INTERNAL, HypervSwitchType.EXTERNAL):
raise LisaException(f"Unknown switch type {switch_type}")

# get default switch of type `switch_type` from hyperv
switch_json = self.node.tools[PowerShell].run_cmdlet(
f'Get-VMSwitch | Where-Object {{$_.SwitchType -eq "{switch_type}"}}'
"| Select -First 1 | select Name | ConvertTo-Json",
force_run=True,
)

if not switch_json:
raise LisaException(f"Could not find default switch of type {switch_type}")

Expand Down Expand Up @@ -435,8 +435,6 @@ def configure_dhcp(self, dhcp_scope_name: str = "DHCPInternalNAT") -> None:
def _install(self) -> bool:
assert isinstance(self.node.os, Windows)

service: Service = self.node.tools[Service]

# check if Hyper-V is already installed
if self._check_exists():
return True
Expand All @@ -447,9 +445,11 @@ def _install(self) -> bool:
# reboot node
self.node.reboot()

service: Service = self.node.tools[Service]
# wait for Hyper-V services to start
service.wait_for_service_start("vmms")
self.node.tools[Service].wait_for_service_start("vmms")
service.wait_for_service_start("vmcompute")

return self._check_exists()

def _run_hyperv_cmdlet(
Expand Down

0 comments on commit 7099aba

Please sign in to comment.