Skip to content

Commit

Permalink
Use switch ID to match default switch
Browse files Browse the repository at this point in the history
Signed-off-by: Zhongcheng Lao <[email protected]>
  • Loading branch information
laozc authored and gbraad committed Sep 10, 2019
1 parent 2438fc9 commit 21bd2f5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/hyperv/hyperv.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
defaultCPU = 1
defaultVLanID = 0
defaultDisableDynamicMemory = false
defaultSwitch = "Default Switch"
defaultSwitchID = "c08cb7b8-9b3c-408e-8e30-5e16a3aeb444"
)

// NewDriver creates a new Hyper-v driver with default settings.
Expand Down Expand Up @@ -299,7 +299,7 @@ func (d *Driver) chooseVirtualSwitch() (string, error) {

if d.VSwitch == "" {
// prefer Default Switch over external switches
switches, err := getHyperVSwitches([]string{fmt.Sprintf("Where-Object {($_.SwitchType -eq 'External') -or ($_.Name -eq '%s')}", defaultSwitch), "Sort-Object -Property SwitchType"})
switches, err := getHyperVSwitches([]string{fmt.Sprintf("Where-Object {($_.SwitchType -eq 'External') -or ($_.Id -eq '%s')}", defaultSwitchID), "Sort-Object -Property SwitchType"})
if err != nil {
return "", fmt.Errorf("unable to get available hyperv switches")
}
Expand Down

0 comments on commit 21bd2f5

Please sign in to comment.