Using a vc:virtualmachine object, retrieve ESXi host and vCenter Cluster objects. Most of the other attributes are easy to find in the API explorer, but these two are ‘hidden’ in the ‘runtime’ attribute.
// vcVM is a vc:virtualmachine object esxiHost = (vcVM.runtime).host // type vcHostSystem vCenterCluster = (vcVM.runtime).host.parent // type vcManagedEntity vCenterClusterName = (vcVM.runtime).host.parent.name // type String
Leave a Reply