find_entity_views
Searches the inventory tree for managed
objects that match the specified entity type.
To avoid performance problems, use this command
with a filter or specify the
properties
argument. By default, this subroutine
retrieves all properties of an entity. See
Creating and Using Filters and
Filtering Views Selectively Using Properties.
See the vSphere SDK for Perl API Reference for a
list of properties. You can specify properties inherited from
ManagedEntity
or local to a specific entity type.
Parameters
Parameter
| Description
|
---|---|
view_type
| Managed entity type
specified as one of these strings.
|
begin_entity
(optional)
| Managed object
reference that specifies the starting point for search in the inventory. This
parameter helps you narrow the scope.
|
filter (optional)
| Hash of one or more
name-value pairs. The name represents the property value to test and the value
represents a pattern that the property must match. If more than one pair is
specified, all the patterns must match.
|
properties
| Properties to retrieve.
Default is all properties. Use a filter or properties to avoid performance
problems. See
Filtering Views Selectively Using Properties.
|
Returns
Reference to an array of view objects containing
static copies of property values for the matching inventory objects. If no
matching entities are found, the array is empty.
Example
The following example, originally published in
VMware Communities in post #1272780, retrieves the
name
property from each inventory object. Note that
$entity_views
extracted from the server-side managed
object is an array reference, not a scalar.
... my %opts = ( entity => { type => "=s", variable => "VI_ENTITY", help => "ManagedEntity type: HostSystem, etc", required => 1, }, ); Opts::add_options(%opts); 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, properties => [ 'name' ]); ...