Uniqueness of MOIDs

A question was recently posted at the open source VI Java API forum regarding the uniqueness of MOIDs. The developer who raised the question wanted to build a caching on the client side so as to avoid getting back to the server for the name of a virtual machine with its MOID. If MOID doesn’t resonate with you, you may want to read this post before reading on.

Because the MOIDs are used to uniquely identify a managed object on the server side, it has to be unique, meaning given its value you should be able to get hold of the managed object. Once you have the object, you can get all sorts of properties of that managed object, say name.

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.

So the answer is simply yes.

But does it guarantees uniqueness all over the time? In other words, if a virtual machine gets deleted, will its MOIDs be assigned to a newly created virtual machine? Good question indeed.

I don’t see a MOID reused in my development and testing environment. This does not imply in any way a guarantee. Maybe my environment is too small or running too short for it to happen. So you should not assume it’s always unique over the time.

Now, what if you really want to have something truly unique? Then you need to use the UUID as I blogged earlier. For the virtual machine, just check out its config.uuid property.

This entry was posted in vSphere API and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted August 16, 2011 at 12:23 am | Permalink

    Hi Steve,

    I believe the MOID would be unique among a vCenter instance, there is probably a chance that you could see a duplicate across vCenter instance’s. As I understand it, with vSphere 4.0 API, the instanceUuid (http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.vm.Summary.ConfigSummary.html#instanceUuid) should be used to truly track a unique VM for a given vCenter instance versus the regular uuid.

  2. Rags
    Posted August 16, 2011 at 6:47 pm | Permalink

    Steve, thanks for the post, it’s useful! But honestly vsphere has a hole in this regard. Ideally there should be a truly unique identity for ALL objects in vsphere inventory. UUID is applicable only for vms and maybe few others liks hosts. IIRC dvs objects have their own identity etc. So in summary, there are holes in that not all objects have a fool-proof unique identity and it’s inconsistent in that different objects use different properties as unique identity.

    This is really a serious problem for anyone wanting to integrate with vsphere world in a big enterprise environment consisting of bunch of other products in the overall integration! Would you have any info/clue as to what the current recommendation is and/or what the future solution will be?

  3. Posted August 17, 2011 at 7:56 pm | Permalink

    Hi Rags,

    Thanks a lot for your feedback! I’ve heard similar concerns before. Other than using UUIDs, I don’t know of a unified way to achieve what you want. I will forward it to our engineering teams.


  4. Posted August 17, 2011 at 7:57 pm | Permalink

    Hi William,

    You are right – the uniqueness of MOID is only within one ESX or vCenter context.


  5. Lital Hassine
    Posted August 21, 2011 at 2:51 am | Permalink

    Hi Steve,

    Thank you for a very valuable post!

    I came across environments where in the same vCenter there are virtual machines with the same UUIDs. From my understanding this can happen for example when one clones a virtual machine not through the vCenter or using vCloud Director.

    What do you recommend to do in cases like these? maybe consider a combination of moid and UUID?


  6. Posted August 21, 2011 at 3:20 pm | Permalink

    Hi Lital,

    I am glad you find it helpful. Do you want to share what you want to do with the ID? In most cases, MOID is enough.


  7. Lital
    Posted August 22, 2011 at 8:35 am | Permalink

    Hi Steve,

    I would like to use the ID as an internal identification for virtual machines in the vCenter.


  8. Posted August 22, 2011 at 11:00 am | Permalink

    Hi Lital,

    The MOID itself should be good enough unless you want to manage across different vCenters. If you do, you can add vCenter ID as part of your VM IDs.


Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.