From ed64f341195ef999bd1e9f074dd300517f949ab8 Mon Sep 17 00:00:00 2001 From: Sreyas Natarajan Date: Tue, 7 Nov 2023 16:50:52 -0800 Subject: [PATCH] Remove updates to DeviceGroups This change removes the update of deviceGroups in the UpdateVM path. We don't currently support this workflow on Update and DeviceGroups are already covered in the CreatePath. This code for this currently incomplete to support deviceGroups on update and will be prioritized when we support Resizing VMs in VM operator. --- .../vsphere/session/session_vm_update.go | 14 ----- .../vsphere/session/session_vm_update_test.go | 53 ------------------- .../vsphere2/session/session_vm_update.go | 14 ----- .../session/session_vm_update_test.go | 53 ------------------- 4 files changed, 134 deletions(-) diff --git a/pkg/vmprovider/providers/vsphere/session/session_vm_update.go b/pkg/vmprovider/providers/vsphere/session/session_vm_update.go index ba385f717..7138128f7 100644 --- a/pkg/vmprovider/providers/vsphere/session/session_vm_update.go +++ b/pkg/vmprovider/providers/vsphere/session/session_vm_update.go @@ -440,19 +440,6 @@ func UpdateConfigSpecFirmware( } } -// UpdateConfigSpecDeviceGroups sets the desired config spec device groups to reconcile by differencing the -// current VM config and the class config spec device groups. -func UpdateConfigSpecDeviceGroups( - config *vimTypes.VirtualMachineConfigInfo, - configSpec, classConfigSpec *vimTypes.VirtualMachineConfigSpec) { - - if classConfigSpec.DeviceGroups != nil { - if config.DeviceGroups == nil || !reflect.DeepEqual(classConfigSpec.DeviceGroups.DeviceGroup, config.DeviceGroups.DeviceGroup) { - configSpec.DeviceGroups = classConfigSpec.DeviceGroups - } - } -} - // updateConfigSpec overlays the VM Class spec with the provided ConfigSpec to form a desired // ConfigSpec that will be used to reconfigure the VM. func updateConfigSpec( @@ -480,7 +467,6 @@ func updateConfigSpec( vmCtx.VM, updateArgs.ExtraConfig, updateArgs.VirtualMachineImageV1Alpha1Compatible) UpdateConfigSpecChangeBlockTracking(config, configSpec, updateArgs.ConfigSpec, vmCtx.VM.Spec) UpdateConfigSpecFirmware(config, configSpec, vmCtx.VM) - UpdateConfigSpecDeviceGroups(config, configSpec, updateArgs.ConfigSpec) return configSpec } diff --git a/pkg/vmprovider/providers/vsphere/session/session_vm_update_test.go b/pkg/vmprovider/providers/vsphere/session/session_vm_update_test.go index 116f3687d..2c3e0d078 100644 --- a/pkg/vmprovider/providers/vsphere/session/session_vm_update_test.go +++ b/pkg/vmprovider/providers/vsphere/session/session_vm_update_test.go @@ -807,59 +807,6 @@ var _ = Describe("Update ConfigSpec", func() { }) - Context("DeviceGroups", func() { - var classConfigSpec *vimTypes.VirtualMachineConfigSpec - - BeforeEach(func() { - classConfigSpec = &vimTypes.VirtualMachineConfigSpec{} - }) - - It("No DeviceGroups set in class config spec", func() { - session.UpdateConfigSpecDeviceGroups(config, configSpec, classConfigSpec) - Expect(configSpec.DeviceGroups).To(BeNil()) - }) - - It("DeviceGroups set in class config spec", func() { - classConfigSpec.DeviceGroups = &vimTypes.VirtualMachineVirtualDeviceGroups{ - DeviceGroup: []vimTypes.BaseVirtualMachineVirtualDeviceGroupsDeviceGroup{ - &vimTypes.VirtualMachineVirtualDeviceGroupsDeviceGroup{ - GroupInstanceKey: int32(400), - }, - }, - } - - session.UpdateConfigSpecDeviceGroups(config, configSpec, classConfigSpec) - Expect(configSpec.DeviceGroups).NotTo(BeNil()) - Expect(configSpec.DeviceGroups.DeviceGroup).To(HaveLen(1)) - deviceGroup := configSpec.DeviceGroups.DeviceGroup[0].GetVirtualMachineVirtualDeviceGroupsDeviceGroup() - Expect(deviceGroup.GroupInstanceKey).To(Equal(int32(400))) - }) - - It("configInfo DeviceGroups set with vals different than the class config spec", func() { - classConfigSpec.DeviceGroups = &vimTypes.VirtualMachineVirtualDeviceGroups{ - DeviceGroup: []vimTypes.BaseVirtualMachineVirtualDeviceGroupsDeviceGroup{ - &vimTypes.VirtualMachineVirtualDeviceGroupsDeviceGroup{ - GroupInstanceKey: int32(400), - }, - }, - } - - config.DeviceGroups = &vimTypes.VirtualMachineVirtualDeviceGroups{ - DeviceGroup: []vimTypes.BaseVirtualMachineVirtualDeviceGroupsDeviceGroup{ - &vimTypes.VirtualMachineVirtualDeviceGroupsDeviceGroup{ - GroupInstanceKey: int32(500), - }, - }, - } - - session.UpdateConfigSpecDeviceGroups(config, configSpec, classConfigSpec) - Expect(configSpec.DeviceGroups).NotTo(BeNil()) - Expect(configSpec.DeviceGroups.DeviceGroup).To(HaveLen(1)) - deviceGroup := configSpec.DeviceGroups.DeviceGroup[0].GetVirtualMachineVirtualDeviceGroupsDeviceGroup() - Expect(deviceGroup.GroupInstanceKey).To(Equal(int32(400))) - }) - }) - Context("Ethernet Card Changes", func() { var expectedList object.VirtualDeviceList var currentList object.VirtualDeviceList diff --git a/pkg/vmprovider/providers/vsphere2/session/session_vm_update.go b/pkg/vmprovider/providers/vsphere2/session/session_vm_update.go index 23f1b8295..ab9172d2e 100644 --- a/pkg/vmprovider/providers/vsphere2/session/session_vm_update.go +++ b/pkg/vmprovider/providers/vsphere2/session/session_vm_update.go @@ -435,19 +435,6 @@ func UpdateConfigSpecFirmware( } } -// UpdateConfigSpecDeviceGroups sets the desired config spec device groups to reconcile by differencing the -// current VM config and the class config spec device groups. -func UpdateConfigSpecDeviceGroups( - config *vimTypes.VirtualMachineConfigInfo, - configSpec, classConfigSpec *vimTypes.VirtualMachineConfigSpec) { - - if classConfigSpec.DeviceGroups != nil { - if config.DeviceGroups == nil || !reflect.DeepEqual(classConfigSpec.DeviceGroups.DeviceGroup, config.DeviceGroups.DeviceGroup) { - configSpec.DeviceGroups = classConfigSpec.DeviceGroups - } - } -} - // updateConfigSpec overlays the VM Class spec with the provided ConfigSpec to form a desired // ConfigSpec that will be used to reconfigure the VM. func updateConfigSpec( @@ -475,7 +462,6 @@ func updateConfigSpec( vmCtx.VM, updateArgs.ExtraConfig, updateArgs.VirtualMachineImageV1Alpha1Compatible) UpdateConfigSpecChangeBlockTracking(config, configSpec, updateArgs.ConfigSpec, vmCtx.VM.Spec) UpdateConfigSpecFirmware(config, configSpec, vmCtx.VM) - UpdateConfigSpecDeviceGroups(config, configSpec, updateArgs.ConfigSpec) return configSpec } diff --git a/pkg/vmprovider/providers/vsphere2/session/session_vm_update_test.go b/pkg/vmprovider/providers/vsphere2/session/session_vm_update_test.go index bd3098660..13f8209b6 100644 --- a/pkg/vmprovider/providers/vsphere2/session/session_vm_update_test.go +++ b/pkg/vmprovider/providers/vsphere2/session/session_vm_update_test.go @@ -647,59 +647,6 @@ var _ = Describe("Update ConfigSpec", func() { }) }) - Context("DeviceGroups", func() { - var classConfigSpec *vimTypes.VirtualMachineConfigSpec - - BeforeEach(func() { - classConfigSpec = &vimTypes.VirtualMachineConfigSpec{} - }) - - It("No DeviceGroups set in class config spec", func() { - session.UpdateConfigSpecDeviceGroups(config, configSpec, classConfigSpec) - Expect(configSpec.DeviceGroups).To(BeNil()) - }) - - It("DeviceGroups set in class config spec", func() { - classConfigSpec.DeviceGroups = &vimTypes.VirtualMachineVirtualDeviceGroups{ - DeviceGroup: []vimTypes.BaseVirtualMachineVirtualDeviceGroupsDeviceGroup{ - &vimTypes.VirtualMachineVirtualDeviceGroupsDeviceGroup{ - GroupInstanceKey: int32(400), - }, - }, - } - - session.UpdateConfigSpecDeviceGroups(config, configSpec, classConfigSpec) - Expect(configSpec.DeviceGroups).NotTo(BeNil()) - Expect(configSpec.DeviceGroups.DeviceGroup).To(HaveLen(1)) - deviceGroup := configSpec.DeviceGroups.DeviceGroup[0].GetVirtualMachineVirtualDeviceGroupsDeviceGroup() - Expect(deviceGroup.GroupInstanceKey).To(Equal(int32(400))) - }) - - It("configInfo DeviceGroups set with vals different than the class config spec", func() { - classConfigSpec.DeviceGroups = &vimTypes.VirtualMachineVirtualDeviceGroups{ - DeviceGroup: []vimTypes.BaseVirtualMachineVirtualDeviceGroupsDeviceGroup{ - &vimTypes.VirtualMachineVirtualDeviceGroupsDeviceGroup{ - GroupInstanceKey: int32(400), - }, - }, - } - - config.DeviceGroups = &vimTypes.VirtualMachineVirtualDeviceGroups{ - DeviceGroup: []vimTypes.BaseVirtualMachineVirtualDeviceGroupsDeviceGroup{ - &vimTypes.VirtualMachineVirtualDeviceGroupsDeviceGroup{ - GroupInstanceKey: int32(500), - }, - }, - } - - session.UpdateConfigSpecDeviceGroups(config, configSpec, classConfigSpec) - Expect(configSpec.DeviceGroups).NotTo(BeNil()) - Expect(configSpec.DeviceGroups.DeviceGroup).To(HaveLen(1)) - deviceGroup := configSpec.DeviceGroups.DeviceGroup[0].GetVirtualMachineVirtualDeviceGroupsDeviceGroup() - Expect(deviceGroup.GroupInstanceKey).To(Equal(int32(400))) - }) - }) - Context("Ethernet Card Changes", func() { var expectedList object.VirtualDeviceList var currentList object.VirtualDeviceList