Remove locked Instant-Clone objects in VMware Horizon DaaS
Remove locked Instant-Clone objects in VMware Horizon DaaS

Introduction

In this article I will describe how to remove Instant Clone objects created in VMware Horizon DaaS from your vCenter Server.

I had to do this because I (on one of those famous rough Monday mornings 😉 ) deleted one of my demo tenants in VMware Horizon DaaS without properly clean the tenant first.

Note to self: kill the VDI’s first, than remove the images, etc. properly and THAN delete the tenant!

Unfortunately this wasn’t a very clever move because you can’t delete the remaining objects afterwards due to a lock in the database:

Deleting Instant Cloning cp-xxx objects is not possible due to a lock
Deleting Instant Cloning cp-xxx objects is not possible due to a lock

This can be avoided by changing the capacity of the desktop pools to 0 and convert/delete the images before you delete your tenant from the Horizon DaaS Service center.

Beware!
If these actions are outside your comfort zone, reach out to the VMware Support team to assist you with this. When you delete the wrong objects, there will be consequences.

Preparation

First, you need gather a list of cp-xxx objects you want to remove from the vCenter Server. I did this by listing all the VM objects sitting in the remaining desktop VLAN of my deleted tenant.

Now, export them to a Excel/CSV file.
In the second part of this article we will add a column to the file, so a clear overview is advised.

You can use the Data > “Text to columns” option in Excel to make the list more clear to read. My list looked like this:

Instant Clone - Overview
Instant Clone – Overview

Log on to the vCenter Server MOB.
To do this, type the following behind the FQDN of your vCenter Server: /mob/?vmodl=1.

Example: https://vcsa-fqdn/mob/?vmodl=1

After you logged on (use the administrator@vsphere.local account, or equal privileges) to the MOB, Browse to Content.

vCenter Managed Object Browser ><noscript><img decoding= Content” class=”wp-image-178″/>
vCenter Managed Object Browser > Content

Navigate to the rootFolder > vim.folder > group-d1 (Datacenters)

vCenter Managed Object Browser ><noscript><img decoding= rootFolder > vim.Folder” class=”wp-image-179″/>
vCenter Managed Object Browser > rootFolder > vim.Folder

We need to navigate to the datacenter where your cp-xxx objects are located: Navigate to childEntity > vim.ManagedEntity[] > datacenter-21 (Name of your DataCenter)

vCenter Managed Object Browser ><noscript><img decoding= childEntity > vim.ManagedEntity” class=”wp-image-180″/>
vCenter Managed Object Browser > childEntity > vim.ManagedEntity

Next step is to find the datastore where the cp-xxx objects are stored.
In my situation it’s a NFS datastore: vim.Datastore[] > datastore-56

vCenter Managed Object Browser ><noscript><img decoding= datastore > vim.Datastore” class=”wp-image-181″/>
vCenter Managed Object Browser > datastore > vim.Datastore

Once there, browse to the vm – vim.VirtualMachine[] row and choose more..

vCenter Managed Object Browser ><noscript><img decoding= vm > vim.VirtualMachine” class=”wp-image-182″/>
vCenter Managed Object Browser > vm > vim.VirtualMachine

Now, get back to your Excel and copy the name of one of the cp-xxx objects. Use your browser’s search feature to find the objects.

You need to write down the vm-xxxx nr. of each object:

Instant Clone - Object correlation
Instant Clone – Object correlation

Remove the lock from the Instant Clone cp-xxx objects

In the following steps we will use MOB to remove the lock from Instant Clone cp-xxx objects.

Log on to the vCenter Server MOB.
To do this, type the following behind the FQDN of your vCenter Server: /mob/?vmodl=1.

Example: https://vcsa-fqdn/mob/?vmodl=1

After you logged on (use the administrator@vsphere.local account, or equal privileges) to the MOB, Browse to Content.

vCenter Managed Object Browser ><noscript><img decoding= Content > ServiceContent” class=”wp-image-187″/>
vCenter Managed Object Browser > Content > ServiceContent

Browse to Content > AuthorizationManager

vCenter Managed Object Browser ><noscript><img decoding= authorizationManager > ManagedObjectReference:AuthorizationManager” class=”wp-image-188″/>
vCenter Managed Object Browser > authorizationManager > ManagedObjectReference:AuthorizationManager

If one of these options is missing, close all your browser windows and retry OR open an incongnito window.

Navigate to vim.AuthorizationManager.EntityDisabledMethodInfo[] > enableMethods, A new browser tab will open with three fields: Entity, Method and SourceID.

vCenter Managed Object Browser ><noscript><img decoding= authorizationManager > ManagedObjectReference:AuthorizationManager” class=”wp-image-189″/>
vCenter Managed Object Browser > authorizationManager > ManagedObjectReference:AuthorizationManager

We go back to the Excel list with the locked cp-xxx objects and the vm-xxxx numbers correlated to the them. We need those vm-xxxx numbers in the steps below.

Copy/Paste the XML content from the first code block below to the entity > vim.ManagedEntity[] value.

<!--array start --> 
<entity type="ManagedEntity" xsi:type="ManagedObjectReference">vm-0001</entity> 
<entity type="ManagedEntity" xsi:type="ManagedObjectReference">vm-0002</entity> 
<entity type="ManagedEntity" xsi:type="ManagedObjectReference">vm-0003</entity> 
<entity type="ManagedEntity" xsi:type="ManagedObjectReference">vm-0004</entity> 
<entity type="ManagedEntity" xsi:type="ManagedObjectReference">vm-0005</entity> 
<!--array end -->

Change the vm-xxx object names to the names you correlated during the preparations.

Copy/Paste the XML content from the second code block below to the method > vmodl.MethodName[] value.

<!-- array start -->
<entity type="MethodName" xsi:type="string">vim.VirtualMachine.unregister</entity>
<entity type="MethodName" xsi:type="string">vim.VirtualMachine.powerOff</entity>
<entity type="MethodName" xsi:type="string">vim.VirtualMachine.powerOn</entity>  
<entity type="MethodName" xsi:type="string">vim.ManagedEntity.destroy</entity>
<!-- array end -->
vCenter Managed Object Browser ><noscript><img decoding= authorizationManager > ManagedObjectReference:AuthorizationManager > Invoke Command” class=”wp-image-192″/>
vCenter Managed Object Browser > authorizationManager > ManagedObjectReference:AuthorizationManager > Invoke Command

When done, choose Invoke Method in the right bottom.
The command will run for about 1 minute.

After running these commands, the lock on the cp-xxx objects have been removed.

You can now delete the cp-xxx objects using the GUI.

If you’re new to VMware Horizon DaaS, check out our Horizon DaaS Explained series here!

Loading

By Marc Roeleveld

VCDX-DCV #299 | Cloud Architect | Owner at Roeleveld Cloud Services

3 thoughts on “Remove locked Instant-Clone objects in VMware Horizon DaaS”
  1. Many thanks Marc, I have delete the orphaned folder “VMwareViewComposerReplicaFolder” It works … thanks & Bye p.s. VCSA v6.7update3

Leave a Reply

Your email address will not be published. Required fields are marked *