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 />

# Disconnect on receipt of an interrupt signal while in the infinite loop below.<br />

$SIG{INT} = sub { Util::disconnect();<br />

exit;<br />

};<br />

while (1) {<br />

$log = $diagMgr->BrowseDiagnosticLog(<br />

key => "hostd",<br />

start => $start);<br />

if ($log->lineStart != 0) {<br />

<strong>for</strong>each my $line (@{$log->lineText}) {<br />

# next if ($line =~ /verbose\]/);<br />

print "$line\n";<br />

}<br />

}<br />

$start = $log->lineEnd + 1;<br />

sleep 2;<br />

}<br />

Understanding <strong>Perl</strong> View Objects<br />

A view is a client‐side <strong>Perl</strong> object populated with the state of one or more server‐side managed objects by the<br />

<strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong>. A view object has the following characteristics:<br />

Is a static copy of a server‐side managed object and includes properties and methods that correspond to<br />

the properties and operations of the server‐side managed object.<br />

Must be explicitly updated when the object on the server changes. See “Updating View Objects” on<br />

page 32.<br />

Has properties that correspond to properties of server‐side managed objects as follows:<br />

For each simple property (string, Boolean, numeric data type), including inherited simple properties,<br />

the <strong>SDK</strong> creates an accessor method. The accessor method name is the same as the property name.<br />

Arrays of properties become arrays of properties of the same name.<br />

Includes these methods:<br />

An accessor method <strong>for</strong> each managed object property. The <strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong> provides accessors<br />

<strong>for</strong> any property, regardless of its depth inside a composite object structure.<br />

A blocking and a non‐blocking method <strong>for</strong> each (non‐blocking) operation provided by the server‐side<br />

managed object. See “Non‐Blocking and Blocking Methods” on page 31.<br />

A method that updates the state of any client‐side view object with current data from the server. See<br />

“Updating View Objects” on page 32.<br />

The <strong>vSphere</strong> <strong>SDK</strong> <strong>for</strong> <strong>Perl</strong> simplifies programming as follows:<br />

Provides a _this parameter to reference the object on which a method is run, if needed.<br />

Allows you to pass a view object as a parameter to methods that take managed object references as<br />

required parameter. The <strong>SDK</strong> converts the view object to the corresponding managed object.<br />

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

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

Saved successfully!

Ooh no, something went wrong!