From 3d7fd3110008297dcc6e0fad16189499d226d338 Mon Sep 17 00:00:00 2001 From: Taliesin Sisson Date: Mon, 15 Jan 2024 00:32:33 +0000 Subject: [PATCH] Not sure why the original PR was checking for multiple adaptors (NIC 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 --- api/hyperv-winrm/vm_switch.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/api/hyperv-winrm/vm_switch.go b/api/hyperv-winrm/vm_switch.go index ba3e707..40a6dc6 100644 --- a/api/hyperv-winrm/vm_switch.go +++ b/api/hyperv-winrm/vm_switch.go @@ -3,7 +3,6 @@ package hyperv_winrm import ( "context" "encoding/json" - "fmt" "text/template" "github.com/taliesins/terraform-provider-hyperv/api" @@ -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 @@ -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,