Wednesday, February 8, 2012

VMware vSphere Blog: Uniquely Identifying Virtual Machines in vSphere and vCloud Part 1: Overview

VMware vSphere Blog: Uniquely Identifying Virtual Machines in vSphere and vCloud Part 1: Overview:

By William Lam, Sr. Technical Marketing Engineer

The question of uniquely identifying virtual machines in either a vSphere or vCloud environment is one that comes up from time to time. I hear you asking, why is this import to me? One such reason is to help track virtual machine assets using external systems such as a CMDB (Configuration Management Database) and being able to uniquely identify a VM across multiple vCenter Servers and/or vCloud Director Cells.

In Part 1 of this article, I will provide an overview of what is needed to uniquely identify a VM in both vSphere vCenter and vCloud Director. In Part 2, we will dive into an example using the vSphere API and vCloud API showing the relationships.


In vSphere, to uniquely identify a virtual machine, you can use the MoRef ID (Managed Object Reference ID) or the instanceUuid of a VM which is available using the vSphere API.

The MoRef ID is a VMware internal identifier that is generated by vSphere when new objects are created in vCenter (e.g. adding ESXi host or creating a VM). This MoRef ID is used by all VMware solutions to reference objects within vCenter. The instanceUuid is a new property that was introduced in the vSphere 4.0 API to provide an easy way to uniquely identify a VM. Previous to this, the BIOS uuid of a VM was being used to identify a VM, but it was not always guaranteed to be unique and hence a vCenter specific UUID was created.

An example of a MoRef ID for a VM would be vm-415 where “vm” identifies the object type and 415 is just a counter. An example of an instanceUuid for a VM would be 501d6aa3-54fc-8b8d-99a2-e448463ead18 which represents a 128bit identifier.

If you are managing a single vSphere environment and using vCenter Server, then you can use either property from the vSphere API to uniquely identify your VMs. If you are managing multiple vSphere environments, then you need to combine the either the MoRef ID or instanceUuid VM with the unique identifier for a given vCenter Server. Within the vCenter Server, there is also a property in the vSphere API called instanceUuid which uniquely identifies a vCenter Server. This then allows you to uniquely identify a VM across multiple vCenter Servers as the individual instanceUuid of a VM is only guaranteed to be unique across a single vCenter Server instance.


With vCloud Director, to uniquely identify a virtual machine, you would use the vCloud Director Object ID that is automatically generated by vCloud Director when a new virtual machine is created. The vCloud Director Object ID is available using the vCloud API.

An example of a vCloud Director Object ID for a VM would be urn:vcloud:vm:71d5b81a-f82d-495a-9e58-4b95a645c841 which is expressed in URN format.

To automatically handle uniqueness of a VM across a single or multi vCloud Director Cell, there is an object reference property called href that is provided as a URL that contains information about the vCloud Director Cell and VM vCloud Director Object ID.

An example of an href for a VM would be https://vcloudurl/api/vApp/vm-71d5b81a-f82d-495a-9e58-4b95a645c841 where the UUID of the VM is captured as part of the URL.

By using the href property, you are guaranteed a unique key within vCloud Director.

vSphere and vCloud

If you need to uniquely identify a virtual machine in both vSphere and vCloud, you can still use the identifiers listed above in their respective stack but how do you go about correlating the two? As mentioned earlier, all VMware solutions leverage the MoRef ID to reference objects within vCenter. Since vCloud Director sits on top of vSphere, it too also uses the MoRef ID to map entities between the two environments. As part of the vCloud API, there is a vCloud Extension API that provides information about the underlying vSphere infrastructure including the MoRef ID of a VM and vCenter Server instanceUuid.

Here is a diagram to help visualize the unique properties between vSphere and vCloud:


From a vCloud Director VM, we can map it to a specific vCenter Server using the vCloud Extension API to retrieve the MoRef ID of the VM and instanceUuid of the vCenter Server. Using the instanceUuid, we can then correlate that back to a specific vCenter Server and find the VM with matching MoRef ID.

It is recommended that you leverage the MoRef ID as the common identifier between vCloud and vSphere. If you are only within vCloud, then you can use href property.

If you would like more details on the importance of the MoRef ID within vCloud Director, Chris Colotti wrote an excellent article here. I would highly recommend you take a look at his article.

Additional Notes:

  • If you move a VM to another Organization vDC, the href and UUID will change

  • If you Import a VM from vSphere to vCloud, the VM MoRef ID will stay same if you use “move” operation. If you use “copy”, the MoRef ID will change.

Additional resources:

Thanks to Michael Haines and Timo Sugliani for their feedback on the article.

Get notification of new blog postings and more by following VMware Automation on Twitter: @VMWAutomation

No comments:

Post a Comment