#!/usr/bin/perl -w # The simpleclient.pl script outputs a list of all the entities of the # specified managed entity type (ClusterComputeResource, ComputeResource, Datacenter, # Folder, HostSystem, ResourcePool, or VirtualMachine) found on the # target VirtualCenter Server or ESX Server system. # Script users must provide logon credentials and the managed entity type. # The simpleclient.pl script leverages the Util::trace() subroutine to # actually display the found entities of the specified type. use strict; use warnings; use VMware::VIRuntime; use VMware::VILib; # Script users must pass one of the seven managed-entity types # as a command-line parameter ('entity') when they run this script, # or the the help message displays. # my %opts = ( entity => { type => "=s", help => "ManagedEntity type: ClusterComputeResource, ComputeResource, Datacenter,\n Folder, HostSystem, ResourcePool, or VirtualMachine", required => 1, }, ); Opts::add_options(%opts); # Parse all connection options, both built-in and custom, and then # connect to the server Opts::parse(); Opts::validate(); Util::connect(); # Obtain all inventory objects of the specified type my $entity_type = Opts::get_option('entity'); my $entity_views = Vim::find_entity_views(view_type => $entity_type); # Process the findings and output to the console foreach my $entity_view (@$entity_views) { my $entity_name = $entity_view->name; Util::trace(0, "Found $entity_type: $entity_name\n"); } # Disconnect from the server Util::disconnect();