VMware

FindDatacenterByHostname.pl

VERSION 5 Published

Created on: Mar 4, 2009 3:08 PM by stumpr - Last Modified:  May 22, 2009 11:16 AM by stumpr

FindDatacenterByHostname.pl demonstrates how to use the parent property to identify the Datacenter to which a particular VMware ESX host is assigned. Using the parent property is more efficient than doing a full search of all Datacenters and all Host objects for a match. The script uses a simple recursive function to walk up the parent tree from the specified ESX host until the datacenter object is reached and then returns the name of that datacenter. This script also demonstrates an undocumented feature of the VI Perl Toolkit, which is the properties named argument for the various view functions (find_entity_view, find_entity_views, get_view, and get_views). By default the VI Perl Toolkit will retrieve all properties of a ManagedObject (when properties is not set in a view call). This is particularly intensive and can dramatically increase the running time of a script as the number of requested ManagedObjects increases (for example, when requesting several hundred virtual machine ManagedObjects with find_entity_views.)

Average User Rating
(0 ratings)




Comments

There are no comments on this document

 

Actions

Developer Social Media

Communities