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.