Merge pull request #9747 from chrisroberts/e-hyper-v-checkpoints
Reference Hyper-V switch by ID instead of name
This commit is contained in:
commit
bf281a912c
|
@ -88,9 +88,9 @@ module VagrantPlugins
|
|||
switchToFind = opts[:bridge]
|
||||
|
||||
if switchToFind
|
||||
puts "Looking for switch with name: #{switchToFind}"
|
||||
switch = switches.find { |s| s["Name"].downcase == switchToFind.downcase }["Name"]
|
||||
puts "Found switch: #{switch}"
|
||||
@logger.debug("Looking for switch with name: #{switchToFind}")
|
||||
switch = switches.find { |s| s["Name"].downcase == switchToFind.downcase }["Id"]
|
||||
@logger.debug("Found switch: #{switch}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -110,9 +110,9 @@ module VagrantPlugins
|
|||
switch = switch.to_i - 1
|
||||
switch = nil if switch < 0 || switch >= switches.length
|
||||
end
|
||||
switch = switches[switch]["Name"]
|
||||
switch = switches[switch]["Id"]
|
||||
else
|
||||
switch = switches[0]["Name"]
|
||||
switch = switches[0]["Id"]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -8,5 +8,5 @@ $Dir = Split-Path $script:MyInvocation.MyCommand.Path
|
|||
. ([System.IO.Path]::Combine($Dir, "utils\write_messages.ps1"))
|
||||
|
||||
$Switches = @(Hyper-V\Get-VMSwitch `
|
||||
| Select-Object Name,SwitchType,NetAdapterInterfaceDescription)
|
||||
| Select-Object Name,SwitchType,NetAdapterInterfaceDescription,Id)
|
||||
Write-Output-Message $(ConvertTo-JSON $Switches)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
[Parameter(Mandatory=$true)]
|
||||
[string]$data_path,
|
||||
|
||||
[string]$switchname=$null,
|
||||
[string]$switchid=$null,
|
||||
[string]$memory=$null,
|
||||
[string]$maxmemory=$null,
|
||||
[string]$cpus=$null,
|
||||
|
@ -83,8 +83,10 @@ if (!$memory) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$switchname) {
|
||||
if (!$switchid) {
|
||||
$switchname = (Hyper-V\Get-VMNetworkAdapter -VM $vmConfig.VM).SwitchName
|
||||
} else {
|
||||
$switchname = $(Hyper-V\Get-VMSwitch -Id $switchid).Name
|
||||
}
|
||||
|
||||
# Enable nested virtualization if configured
|
||||
|
|
Loading…
Reference in New Issue