VMware {code} Community
cxh9055
Contributor
Contributor

Find template by UUID

I am storing the uuid of a template in a database.  At some later point I would like to access that template.  I have tried to use the the  SearchIndex.FindByUUID() method with no luck.  If I change the UUID to that of a VM then it finds it.  I was wondering if anybody knew of a way to for the FindByUUID method to find templates as well.

Thank you

Tags (2)
0 Kudos
2 Replies
lamw
Community Manager
Community Manager

Hi,

The FindByUUID() as mentioned in the documentation (http://pubs.vmware.com/vsphere50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.SearchIndex...) only supports looking up Virtual Machines and/or Hosts, Template lookup is not possible. What you could store is the MoRef ID, this will be the same whether the object is a VM or VM Template, there just one property that is boolean that determines whether a VM is a template or not, other than that, everything else is the same. This assumes that your templates are persisted and if they do change, you should update your external database with the proper MoRef ID and then you can create a Managed Object Ref based on the MoRef ID to quickly be able to perform an action on the template without having to search through your entire vSphere Inventory.

Just as an FYI, UUID is not guaranteed to be unique, you should use the instanceUUID which is guaranteed to be unique for a given vCenter Server instance.

0 Kudos
cxh9055
Contributor
Contributor

That is where I get confused?  The template is just a VM object with a bit set that marks it as a template.  When I get the MoRef it is of type "VirtualMachine"  so shouldnt I logically be able to search for it when looking for it?

0 Kudos