Skip to content

Commit

Permalink
Not sure why the original PR was checking for multiple adaptors (NIC …
Browse files Browse the repository at this point in the history
…teaming) and failing an update. Perhaps its a particular property.

Tested with:
New-VMSwitch -Name testeme -NetAdapterName "Ethernet 2", "Ethernet"
Rename-VMSwitch -Name testeme -NewName testme2
Set-VMSwitch -Name testme2 -AllowManagementOS:$false
  • Loading branch information
taliesins committed Jan 15, 2024
1 parent b863b55 commit 3d7fd31
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions api/hyperv-winrm/vm_switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package hyperv_winrm
import (
"context"
"encoding/json"
"fmt"
"text/template"

"github.com/taliesins/terraform-provider-hyperv/api"
Expand Down Expand Up @@ -189,10 +188,7 @@ $oldName = '{{.OldName}}'
$vmSwitch = '{{.VmSwitchJson}}' | ConvertFrom-Json
$minimumBandwidthMode = [Microsoft.HyperV.PowerShell.VMSwitchBandwidthMode]$vmSwitch.BandwidthReservationMode
$switchType = [Microsoft.HyperV.PowerShell.VMSwitchType]$vmSwitch.SwitchType
if ($vmSwitch.NetAdapterNames.length -gt 0) {
$NetAdapterNames = [string]$vmSwitch.NetAdapterNames[0]
}
$NetAdapterNames = @($vmSwitch.NetAdapterNames)
#when EnablePacketDirect=true it seems to throw an exception if EnableIov=true or EnableEmbeddedTeaming=true
Expand Down Expand Up @@ -260,10 +256,6 @@ func (c *ClientConfig) UpdateVMSwitch(
defaultQueueVmmqQueuePairs int32,
defaultQueueVrssEnabled bool,
) (err error) {
if len(netAdapterNames) > 1 {
return fmt.Errorf("[ERROR][hyperv] Can't update a switch with multiple net adapaters names (%v)", netAdapterNames)
}

vmSwitchJson, err := json.Marshal(api.VmSwitch{
Name: name,
Notes: notes,
Expand Down

0 comments on commit 3d7fd31

Please sign in to comment.