Find vCloud Director Orphaned VM’s

We all are familiar with concept of orphaned VM’s in vSphere. However orphaned VM’s in vCloud Director have slightly different meaning. 

From vCD perspective, virtual machines that are referenced in the vCenter database but not in the vCloud Director database are considered orphan VMs because vCD cannot access them even though they may be consuming compute and storage resources. This kind of reference mismatch can arise for a number of reasons, including high-volume workloads, database errors, and administrative actions.

Starting with vCD 8.2, VMware added one more option to cell management utility to locate such orphaned VM’s so that they can be removed or re-imported into vCloud Director. This utility is not available with any vCD version prior to 8.20.

The command to find orphaned VM’s is find-orphan-vms command which is used in conjunction with cell-management-tool and enables an administrator to list these VMs .

To list the options available with this command, run command: 

# /opt/vmware/vcloud-director/bin/cell-management-tool find-orphan-vms –help

vcd-orphaned-vms.PNG

If you are using self-signed certificates in vCD, then you have to specify truststore file and truststore password along with supplying vcd username/password and vcenter credentials etc. This is the full command that one can use: 

[root@vcd-a bin]# ./cell-management-tool find-orphan-vms –host vcd-a.alex.local -u admin –password vCD-Pwd –trustStore /opt/vmware/vcloud-director/vcd.ks –trustStorePassword vCloud@2017 –vc-name resourcevc01.alex.local –vc-user vcadmin@alex –vc-password passwd –output-file vmlist.txt

The above command will query all all Org VDC’s that are present in vCD and present the list of VM’s in the output file specified in above command.

Querying for VC by name resourcevc01.alex.local
Querying all VDCs associated with VC: resourcevc01.alex.local (https://resourcevc01.alex.local:443/sdk)
Querying all VDC<->resource pool mappings associated with VC: resourcevc01.alex.local (https://resourcevc01.alex.local:443/sdk)
Querying all VDC<->VM Moref mappings associated with VC: resourcevc01.alex.local (https://resourcevc01.alex.local:443/sdk)
Processing 1 VMs on 2 VDCs across 2 resource pools
Analysis complete.

You can use cat or less utility to see the contents of the output file. The file will list all orphaned VM’s/Org VDC. In my lab I did not had any orphaned VM’s so the list is empty

[root@vcd-a bin]# cat vmlist.txt
VDC: "Service_VDC [urn:vcloud:vdc:fcdf292a-b886-4dc9-9b6f-3a4df1a97782]" (org: "Service-vDC")
VDC: "Prod-DC [urn:vcloud:vdc:1c32832c-e4db-48b0-9cfc-116fbb302625]" (org: "Production")

Below is an example taken from vCD documentation which shows the output when orphaned VM’s are found

VDC: "ExampleOrgVDC [urn:vcloud:vdc:1a97...]" (org: "ExampleOrg") ResPool: primary (1a97...) [moref: "resgroup-30515"]
The following 22 orphan VMs were discovered:
Orphan VM: "indDisk100-0-95411 (cbc358a0-e199-4024-8fff-2e5cfce20953)" (parent name: "Test VMs", parent moref : "group-v30533")
...
Orphan VM: "indDisk12-0-51259 (0bbb4115-673e-4c84-ba26-6875159655e0)" (parent name: "Test VMs", parent moref : "group-v30533")

I hope you find this post informational. Feel free to share this on social media if it is worth sharing. Be sociable 🙂

Add a Comment