Home > vSphere API > UUID vs. vSphere

UUID vs. vSphere

August 12th, 2010 Leave a comment Go to comments

UUID stands for universally unique identifier (UUID). It’s a 128-bit value. vSphere uses it as IDs for many different types of entities like HostSystem, VirtualMachine, Datastore, etc.

The UUID surfaces to the vSphere API as well. You can find many methods use UUID as parameter or return result. The most commonly used one is the SearchIndex.findByUuid() which find you a virtual machine or a host based on its UUID, either instance or BIOS UUID. The format used for UUID is as follows:

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

52dc2e26-dbc4-7d05-5fed-019d234379d9

Since 4.0, DistributedVirtualSwitchManager managed object is added and it has a method called queryDvsByUuid(). As reported by VI Java API community, the standard format doesn’t work. The accepted format is like this:

aa aa aa aa bb bb cc cc-dd dd ee ee ee ee ee ee

I checked the API reference, and found no description about the format. So whatever works is the right format.

To my curiosity, I looked into the MOB (vSphere Client doesn’t normally show you UUIDs). I found 3rd format for datastores as follows:

4bdf6f1f-2b2366eb-c3e5-0026b95b6e32

Now what is the right format for UUID? The most commonly used format is the first one in this blog. Although the format does not affect the final value, it does affect the usage of the API. When you have a string for something like UUID, you should document it in the API reference on its format especially when it’s not the most commonly used format.

Besides format, I would like to add a little more about UUID itself. UUID has different variants or types (see the UUID spec):

Msb0  Msb1  Msb2  Description
 
0     x     x    Reserved, NCS backward compatibility.
1     0     x    The variant specified in this document. 
1     1     0    Reserved, Microsoft Corporation backward
                     compatibility
1     1     1    Reserved for future definition.
(note by Steve: the integer values are 0, 2, 6, and 7 respectively.)

Let’s take a sample with a virtual machine UUID:

564dd81c-48c9-cd30-565b-557a22101001

The variant is 0. Interesting enough, the datastore uses different variant as 6.

4bdf6f1f-2b2366eb-c3e5-0026b95b6e32

Although these UUIDs come with different variants, they are used as ID. As long as they are unique, they are fine.

BTW, you can use java.util.UUID class to find out more information like variant, version, and optionally time stamp of a UUID.

  1. amogh
    January 15th, 2013 at 01:45 | #1

    give me the code for retriving resourcepool uuid,cluster uuid.. plz help me

  2. January 15th, 2013 at 02:36 | #2

    Please check out the samples at http://vijava.sf.net. Good luck!
    Steve

  3. amogh
    January 15th, 2013 at 03:04 | #3

    yes steve,am referring that only.. but there is no such code for geting uuid of resourcepool and cluster,give me some simple method to retrive only uuids of them
    thanx!

  4. December 27th, 2014 at 15:04 | #4

    I have read so many articles concerning the blogger lovers
    but this post is genuinely a pleasant article, keep it up.

  1. No trackbacks yet.