VMware Cloud Community
Marco_2_G
Contributor
Contributor
Jump to solution

Release backup software's lock on VMs

Hello everybody

We are having the issue that our backup software sometimes forgets to unlock VMs after it is done with its thing.

The software itself only allows the unlocking by browsing the backup selection and selecting each and every VM individually and hitting "unlock".

This not only hampers new backup attempt sometimes, it also blocks DRS vMotions and manual ones. While troubleshooting this on PS, I noticed that PS was aware that the VM was actually locked by the backup plugin.

So my hope is to find all VMs with such a lock and remove the lock via PS.

Does anybody have experience with this issue or can anyone be of assistance in finding a way to do this?

Thanks in advance for your time

Regards,

Marco

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Does the following detect the VMs?

$motion = 'RelocateVM_Task','MigrateVM_Task'

Get-VM | Select Name,

   @{N='(s)vMotion Disabled';E={

   $vm = $_

   ($motion | %{

   $vm.ExtensionData.DisabledMethod -contains $_

   }) -contains $true}}


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

View solution in original post

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

Hi Marco,

Do you have some more info on how those locks are visible (with PowerCLI)?


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

Reply
0 Kudos
Marco_2_G
Contributor
Contributor
Jump to solution

Screen Shot 2018-06-27 at 12.15.38.png

Basically we need to find out which VMs have the move method disabled by BKB_PLUGIN... and then undo that.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Does the following detect the VMs?

$motion = 'RelocateVM_Task','MigrateVM_Task'

Get-VM | Select Name,

   @{N='(s)vMotion Disabled';E={

   $vm = $_

   ($motion | %{

   $vm.ExtensionData.DisabledMethod -contains $_

   }) -contains $true}}


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

Reply
0 Kudos
Marco_2_G
Contributor
Contributor
Jump to solution

Geez you're good!

Indeed it does!

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you want to remove the lock following one the methods described in KB2008957, you could do the following.

Note that this requires the VM to be powered off.

$motion = 'RelocateVM_Task','MigrateVM_Task'

foreach($vm in Get-VM | where{

   $tVM = $_

   ($motion | %{$tVM.ExtensionData.DisabledMethod -contains $_}) -contains $true}){


   $vmxFile = $vm.ExtensionData.LayoutEx.File | where{$_.Type -eq 'config'}

   if($vmxFile -and $vm.PowerState -eq 'PoweredOff'){

   Remove-VM -VM $vm -Confirm:$false

   New-VM -VMFilePath $vmxFile.Name -VMHost $vm.VMHost

   }

}

There is another method, without the poweroff requirement, but it is a bit more complex.

See William's How to easily disable vMotion & Cross vCenter vMotion for a particular Virtual Machine?

Since the DisableMethods method is not public, William uses the MOB to call the method.

See his enable-disable-vsphere-api-method.ps1 script.


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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Saw too late that you already found William's script :smileygrin:
In any case,m you have the alternative from the KB as well now


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

Reply
0 Kudos
Marco_2_G
Contributor
Contributor
Jump to solution

Thank you

In case anybody in the future should need something similar:

I changed LucDs search to one using get-view:

$vms = get-view -viewtype VirtualMachine -filter @{"Config.Template"="False";"DisabledMethod"="RelocateVM_Task"}

And then simply ran each item through the Enable-vSphereMethod function:

Enable-vSphereMethod -vc_server $vcenter -vc_username $vcenter_user -vc_password $vcenter_pwd -vmmoref $($_.MoRef.Value) -enable_method $method_name

Reply
0 Kudos