How to figure out the vCenter name of a vCloud Director VM?
There is a regular ask in various community channels on how to be able to map the vCloud Director virtual machine name to the exact VM in vCenter Server.
This blog post will look at an easy mechanism to do so since the Flash client is now either deprecated or completely gone depending on which vCloud Director verison you are actually running.
To quickly describe the problem let's look at 2 screenshots. The first one is the view in vCloud Director.
The second view is from vCenter Server.
How do you map these 2 now?
Since vCloud Director 10.2 it's actually quite simply, you can directly look it up in the properties of the virtual machine in vCloud Director as you used to be able to do in the vCloud Director Flash client. The field called "Name in vSphere" will tell you, if you have the correct permissions of course, what the actual virtual machine name is.
What if you are not running vCloud Director 10.2 or want a more programmable approach though?
PowerCLI will be able to help you out there by connecting to both vCloud Director as well as vCenter Server you can simply build a 2 liner which grabs the moref ID from vCloud Director and then queries the moref in the backing vCenter Server to get the virtual machine name.
We can see that we have 2 virtual machines called "web-paris" in this Org... further investigation shows one is part of a vApp called "web-cities" and the other is a standalone VM.
Let's try to map the "web-paris" VM from the vApp to the actual vSphere VM. First as a system administrator we grab the vCenter Server moref link from the vCloud Extension data of the virtual machine object.
1PS C:> $vcd_moref = (get-civapp web-cities | get-civm web-paris).ExtensionData.vCloudextension.any.vmvimobjectref.moref
And then in step 2 we query vCenter Server to find the appropriate moref and give us the VM name.
1PS C:> $vc_vm = (get-vm -ID VirtualMachine-$vcd_moref).name
This can easily be scripted on a per Org basis to build out an inventory over hundreds of vApps and VMs to be able to map them in an automated fashion by simply using a couple of loops, I'll leave that exercise up to the reader though ;)