VMware Cloud Community
walispeed
Contributor
Contributor
Jump to solution

How to properly remove a vm from cluster VM override

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

pastedImage_0.png

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
walispeed
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
walispeed
Contributor
Contributor
Jump to solution

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 !

Reply
0 Kudos
cosna3
Contributor
Contributor
Jump to solution

First of all, to remove a VM from a VM override in a cluster you have to make sure your settings are set correctly.

The first thing you need to check is your DRS settings. You will need to select the cluster in your vCenter list and select the 'configure' tab.

On the 'configure' tab, under services select "vSphere DRS" and then click the 'Edit' button.

Next, you need to make sure that the bottom checkbox labelled as "Virtual Machine Automation"  (the button labelled as 'enable') is checked. If this is not checked, you will need to check the box and click OK; otherwise you will not be able to remove a VM Override in the vCenter GUI.

Reply
0 Kudos