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 2, 2025
1 parent 8114903 commit beb7580
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lisa/tools/hyperv.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ def create_virtual_disk(self, name: str, pool_name: str, columns: int = 2) -> No
def configure_dhcp(self, dhcp_scope_name: str = "DHCPInternalNAT") -> None:
powershell = self.node.tools[PowerShell]
service: Service = self.node.tools[Service]

# Install DHCP server
self.node.tools[WindowsFeatureManagement].install_feature("DHCP")

# Restart the DHCP server to make it available
Expand All @@ -416,25 +418,31 @@ def configure_dhcp(self, dhcp_scope_name: str = "DHCPInternalNAT") -> None:
)
if output:
return
# Configure the DHCP server

# Configure the DHCP server to use the internal NAT network
powershell.run_cmdlet(
f'Add-DhcpServerV4Scope -Name "{dhcp_scope_name}" -StartRange 192.168.0.50 -EndRange 192.168.0.100 -SubnetMask 255.255.255.0', # noqa: E501
force_run=True,
)

# Set the DHCP server options
powershell.run_cmdlet(
"Set-DhcpServerV4OptionValue -Router 192.168.0.1 -DnsServer 168.63.129.16",
force_run=True,
)

# Restart the DHCP server to apply the changes
service.restart_service("dhcpserver")

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

# enable hyper-v
self.node.tools[WindowsFeatureManagement].install_feature("Hyper-V")

Expand Down

0 comments on commit beb7580

Please sign in to comment.