VMware {code} Community
halcabes
Enthusiast
Enthusiast

VI Perl Toolkit update released on Sourceforge

A new release of the VI Perl Toolkit is now available at http://sourceforge.net/projects/viperltoolkit/

The VI Perl Toolkit provides an easy-to-use Perl scripting interface to VMware Infrastructure API. Administrators and developers who wish to develop scripts for automating common VMware Infrastructure operations can now quickly develop applications using the full features available in the VMware Infrastructure API. The VI Perl Toolkit allows you to connect to the VMware Infrastructure through the VirtualCenter Server or any ESX Server.

The VI Perl Toolkit also includes a set of scripts that you can immediately use for common management tasks including VM Power Operations, Host Configuration, and VM Life Cycle Management. These scripts can be used as supplied, can be adapted to your own environment, or simply be used as examples for developing your own scripts.

We have made several improvements to the VI Perl Toolkit since the alpha 5 release:

• Improved documentation

• A new module, VILib.pm, provides many utility libraries for improved connection management and parameter parsing,

• Support for multiple sessions and support for saving login information across scripts,

• Additional sample scripts to provide examples for a broader set of VI API functions,

• Experimental Support for Filtering Views Selectively Using Properties (see below)

Your feedback is very important to us. While the VI Perl Toolkit Beta Discussion Forum is in beta please direct your feedback to the "VMware Management APIs (VI SDK, VI Perl, CIM SDK)" discussion forum (http://www.vmware.com/community/forum.jspa?forumID=393).

\----


Experimental Support for Filtering Views Selectively Using Properties

The view subroutines—get_view(), get_views(), find_entity_view(), and find_entity_views()—can accept a properties argument that comprises a list of property paths for retrieval from the server. Property paths can be full paths, and can include nested properties—they do not need to be top-level managed object properties.

Note: This feature is experimental, and may be changed or removed in the future.

For example, to populate a virtual machine view with power-state information only, you can write:

my $vm_view = Vim::find_entity_view(

view_type => 'VirtualMachine',

filter => \{ 'name' => 'foo' },

properties => \[ 'runtime.powerState' ]

);

To retrieve properties from a filtered view, you should use the view’s get_property method. For example:

my $state = $vm_view->get_property('runtime.powerState');

Note that you can also get subproperties of the retrieved property:

my $vm_view = Vim::find_entity_view(

view_type => 'VirtualMachine',

filter => \{ 'name' => 'foo' },

properties => \[ 'config.hardware' ]);

my $memsize = $vm_view->get_property('config.hardware.memoryMB');

And that get_property works with fully-populated views as well. So:

my $vm_view = Vim::find_entity_view(

view_type => 'VirtualMachine',

filter => \{ 'name' => 'foo' });

my $memsize = $vm_view->get_property('config.hardware.memoryMB');

Is equivalent to:

my $vm_view = Vim::find_entity_view(

view_type => 'VirtualMachine',

filter => \{ 'name' => 'foo' });

my $memsize = $vm_view->config->hardware->memoryMB;

When using a filtered view, any attempts to read a property that wasn’t retrieved from the server will act the same as if the property were unset.

Using property filters is intended primarily to optimize performance, by reducing latency and network bandwidth associated with retrieving full views of a large number of objects. In general, you should start with full views and switch to filtered views only when tuning application performance.

--Harvey Harvey Alcabes Product Manager VMware, Inc.
0 Kudos
1 Reply
halcabes
Enthusiast
Enthusiast

Follow on question from mlmpella moved to a new thread at http://www.vmware.com/community/thread.jspa?threadID=90540&tstart=0

--Harvey Harvey Alcabes Product Manager VMware, Inc.
0 Kudos