5 Replies Latest reply on Apr 6, 2020 1:09 AM by walispeed

    How to properly remove a vm from cluster VM override

    walispeed Lurker

      Hi community,

       

      We're migrating vms from one vCenter to another. It looks like vms keep settings of VM override from source to destination cluster.

       

      I'm looking for a way to properly remove a vm from cluster vm override.

      When using developer mode in a web browser and triggering the delete action, I can see several classes hit but I can't figure it out to put everything together

       

       

      I didn't find either a full powershell method to achieve it.

       

      there is some option on set-vm : set-vm -HARestartPriority ClusterRestartPriority -HAIsolationResponse AsSpecifiedByCluster -DrsAutomationLevel AsSpecifiedByCluster

      this disable some override but does not remove the vm from vm override list.

       

      i don't see anything at cluster level to achieve that

       

      I found Damian Karlson site explaining how to change VMMonitoring, I presume to do the same for each here but i'm a bit lost with those classes

      Managing VMware HA’s VM Monitoring: PowerCLI

       

      Any tip would be very helpful.

       

      thank you

        • 1. Re: How to properly remove a vm from cluster VM override
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          You could try something like this

           

          $vmName = 'MyVM'

          $vm = Get-VM -Name $vmName

          $cluster = Get-Cluster -VM $vm


          $spec = New-Object VMware.Vim.ClusterConfigSpecEx

          $dasVM = New-Object VMware.Vim.ClusterDasVmConfigSpec

          $dasVM.RemoveKey = $vm.ExtensionData.MoRef

          $dasVM.Operation = [VMware.Vim.ArrayUpdateOperation]::remove

          $spec.DasVmConfigSpec += $dasVM

          $cluster.ExtensionData.ReconfigureComputeResource($spec,$true)

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: How to properly remove a vm from cluster VM override
            walispeed Lurker

            Hi Luc,

             

            thank you for your very quick feedback.

             

            your suggestion looks promising, but you did not consider the class : vim.cluster.VmOrchestrationSpec ? as seen in my screenshot above, there is a remove operation as well.

             

            what's happening behind the scene, could some setting keep attached to the object with some unwanted behavior,

            or your action simply discard everything ?

             

            Enjoy your weekend, take care

            • 3. Re: How to properly remove a vm from cluster VM override
              LucD Guru
              Community WarriorsUser ModeratorsvExpert

              Perhaps it would be helpful to show in the Web Client what exactly you override for the VM in the cluster config.

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: How to properly remove a vm from cluster VM override
                LucD Guru
                Community WarriorsvExpertUser Moderators

                Ok, I deduce from your extract that you have also use VM restart priority.
                In that case, try the following version

                 

                $vmName = 'MyVM'

                $vm = Get-VM -Name $vmName

                $cluster = Get-Cluster -VM $vm


                $spec = New-Object VMware.Vim.ClusterConfigSpecEx


                $dasVM = New-Object VMware.Vim.ClusterDasVmConfigSpec

                $dasVM.RemoveKey = $vm.ExtensionData.MoRef

                $dasVM.Operation = [VMware.Vim.ArrayUpdateOperation]::remove


                $spec.DasVmConfigSpec  += $dasVm


                $vmOrch = New-Object VMware.Vim.ClusterVmOrchestrationSpec

                $vmOrch.RemoveKey = $vm.ExtensionData.MoRef

                $vmOrch.Operation = [VMware.Vim.ArrayUpdateOperation]::remove


                $spec.VmOrchestrationSpec += $vmOrch


                $spec.DrsConfig = New-Object VMware.Vim.ClusterDrsConfigInfo

                $spec.DpmConfig = New-Object VMware.Vim.ClusterDpmConfigInfo


                $cluster.ExtensionData.ReconfigureComputeResource($spec,$true)

                Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                • 5. Re: How to properly remove a vm from cluster VM override
                  walispeed Lurker

                  thanks Luc,

                   

                  Actually I don't know what are the defined parameters in VM override, I did some quick test with your proposition but it looks like when an option is not set, I got an error.

                   

                  I see 2 approach,

                  - either find what are enabled and disable them

                  - or just try to disable everything, split each action, call reconfigureComputeResource and surround those by a try catch .. basically don't stop if an error, just continue

                   

                  anyway, you already help me a lot,

                   

                  thanks again for your support !