VMware {code} Community
vijayagce
Enthusiast
Enthusiast
Jump to solution

How to get Datacenter moref using VM moref in c#

Hi All,

Could anyone tell how to get Datacenter managedobjectreference using virtual machine moref? or anyother easy way is there?. If anyone have sample code in C# plz share with me?

Thanks,

Vijaya

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

You can get the datacenter in which the VM resides in by doing the following lookup:

VM Moref -> Parent (vmFolder)

VM Folder Moref -> Parent (datacenter)

VM's parent object will always be the vmFolder and the vmFolder object will always be a datacenter.

For more details on vSphere Inventory/object model, take a look at this blog post - http://www.doublecloud.org/2010/03/vsphere-inventory-structure-deep-dive/

View solution in original post

0 Kudos
2 Replies
lamw
Community Manager
Community Manager
Jump to solution

You can get the datacenter in which the VM resides in by doing the following lookup:

VM Moref -> Parent (vmFolder)

VM Folder Moref -> Parent (datacenter)

VM's parent object will always be the vmFolder and the vmFolder object will always be a datacenter.

For more details on vSphere Inventory/object model, take a look at this blog post - http://www.doublecloud.org/2010/03/vsphere-inventory-structure-deep-dive/

0 Kudos
vijayagce
Enthusiast
Enthusiast
Jump to solution

Thanks. Its very helpful to begin my coding.

0 Kudos