18.08.2013 Views

vSphere SDK for Perl Programming Guide - Documentation - VMware

vSphere SDK for Perl Programming Guide - Documentation - VMware

vSphere SDK for Perl Programming Guide - Documentation - VMware

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Returns<br />

Chapter 4 <strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong> Subroutine Reference<br />

Reference to an array of view objects containing static copies of property values <strong>for</strong> the matching inventory<br />

objects. If no matching entities are found, the array is empty.<br />

Example<br />

The following example, originally published in <strong>VMware</strong> Communities in post #1272780, retrieves the name<br />

property from each inventory object. Note that $entity_views extracted from the server‐side managed object<br />

is an array reference, not a scalar.<br />

...<br />

my %opts = (<br />

entity => {<br />

type => "=s",<br />

variable => "VI_ENTITY",<br />

help => "ManagedEntity type: HostSystem, etc",<br />

required => 1, },<br />

);<br />

Opts::add_options(%opts);<br />

Opts::parse();<br />

Opts::validate();<br />

Util::connect();<br />

# Obtain all inventory objects of the specified type<br />

my $entity_type = Opts::get_option('entity');<br />

my $entity_views = Vim::find_entity_views();<br />

view_type => $entity_type,<br />

properties => [ 'name' ]);<br />

...<br />

get_service_instance<br />

Retrieves a ServiceInstance object, which can be used to query the server time or to retrieve the<br />

ServiceContent object.<br />

Parameters<br />

No parameters.<br />

Returns<br />

Returns a ServiceInstance object.<br />

get_service_content<br />

Retrieves properties of the service instance enabling access to the managed objects of the service. Alternatively,<br />

you can use get_views(), get_view(), and other subroutines to access the objects more directly. If you start<br />

with the service content to work with the Web service, you can navigate to the object of interest.<br />

Parameters<br />

No parameters.<br />

Returns<br />

Reference to ServiceContent object, which contains managed object references to all inventory content,<br />

including the root folder.<br />

<strong>VMware</strong>, Inc. 47

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!