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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong> <strong>Programming</strong> <strong>Guide</strong><br />

<strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong> <strong>Programming</strong> Conventions<br />

Several programming conventions are different than you might expect because the <strong>SDK</strong> interacts with a server<br />

using SOAP/WSDL.<br />

Boolean data types – <strong>SDK</strong> applications send and receive Boolean values as follows:<br />

Input (sending from the client application):<br />

false: Use 0, ʹ0ʹ, or ʹfalseʹ (capitalization ignored)<br />

true: Use 1, ʹ1ʹ, or ʹtrueʹ (capitalization ignored)<br />

Output (receiving from the server):<br />

false: Return value is 0<br />

true: Return value is 1<br />

To match Boolean values in a filter, use the strings true and false. See “Creating and Using Filters” on<br />

page 33.<br />

Date/Time – The server returns a SOAP dateTime value. You can use the Date::Parse <strong>Perl</strong> module to<br />

process these objects.<br />

The <strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong> accepts only native SOAP dateTime values using standard date time <strong>for</strong>mat<br />

with or without fractional seconds, and with or without GMT (Z) time zone:<br />

YYYY-MM-DDThh:mm:ssTZD, <strong>for</strong> example, 1997-07-16T19:20:30+01:00<br />

YYYY-MM-DDThh:mm:ss.sTZD, <strong>for</strong> example, 1997-07-16T19:20:30.45+01:00<br />

The <strong>SDK</strong> always returns dateTime values in the standard date time <strong>for</strong>mat.<br />

SOAP error message – Most likely indicates an error on the server, not an error with the communication<br />

to the server.<br />

<strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong> Common Options<br />

A number of options are available <strong>for</strong> any <strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong> script. Most of these options allow you to<br />

specify the host or hosts to connect to. Most options require an option value.<br />

perl .pl -- <br />

For example, to power on a virtual machine using the vmcontrol.pl utility application, you must specify the<br />

name of the virtual machine to power on, as follows:<br />

perl vmcontrol.pl --server --username --password --operation<br />

poweron --vmname <br />

Run any application or sample without any options or with --help to see its parameters and execution<br />

examples. In<strong>for</strong>mation about common and script‐specific options is included.<br />

IMPORTANT If the host you are targeting is in lockdown mode, you cannot execute <strong>Perl</strong> scripts against the<br />

host.<br />

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

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

Saved successfully!

Ooh no, something went wrong!