6.5
Table Of Contents
- vSphere SDK for Perl Programming Guide
- Contents
- Getting Started with vSphere SDK for Perl
- Writing vSphere SDK for Perl Scripts
- Refining vSphere SDK for Perl Scripts
- Creating and Using Filters
- Filtering Views Selectively Using Properties
- Retrieving the ServiceInstance Object on a vSphere Host
- Saving and Using Sessions
- Using Multiple Sessions
- Learning About Object Structure Using Data::Dumper
- Specifying Untyped Arguments in Scheduled Tasks and Callbacks
- Using Advanced Subroutines
- vSphere SDK for Perl Subroutine Reference
- Web Services for Management Perl Library
- Credential Store Perl Library
vSphere SDK for Perl Programming Guide
28 VMware, Inc.
# Disconnect on receipt of an interrupt signal while in the infinite loop below.
$SIG{INT} = sub { Util::disconnect();
exit;
};
while (1) {
$log = $diagMgr->BrowseDiagnosticLog(
key => "hostd",
start => $start);
if ($log->lineStart != 0) {
foreach my $line (@{$log->lineText}) {
# next if ($line =~ /verbose\]/);
print "$line\n";
}
}
$start = $log->lineEnd + 1;
sleep 2;
}
Understanding Perl View Objects
Aviewisaclient‐sidePerlobjectpopulatedwiththestateofoneormoreserver‐sidemanagedobjectsbythe
vSphereSDKforPerl.Aviewobjecthasthefollowingcharacteristics:
Isastaticcopyofaserver‐sidemanagedobjectandincludespropertiesandmethodsthatcorrespondto
thepropertiesandoperationsoftheserver‐sidemanagedobject.
Mustbeexplicitlyupdatedwhentheobjectontheserverchanges.See“UpdatingViewObjects”on
page 32.
Haspropertiesthatcorrespondtopropertiesofserver‐sidemanagedobjectsasfollows:
Foreachsimpleproperty(string,Boolean,numericdatatype),includinginheritedsimpleproperties,
theSDKcreatesanaccessormethod.Theaccessormethodnameisthesameasthepropertyname.
Arraysofpropertiesbecomearraysofpropertiesofthesamename.
Includesthesemethods:
Anaccessormethodforeachmanagedobjectproperty.ThevSphereSDKforPerlprovidesaccessors
foranyproperty,regardlessofitsdepthinsideacompositeobjectstructure.
Ablockingandanon‐blockingmethodforeach(non‐blocking)operationprovidedbytheserver‐side
managedobject.See“Non‐BlockingandBlockingMethods”onpage 30.
Amethodthatupdatesthestateofanyclient‐sideviewobjectwithcurrentdatafromtheserver.See
“UpdatingViewObjects”onpage 32.
ThevSphereSDKforPerlsimplifiesprogrammingasfollows:
Providesa_thisparametertoreferencetheobjectonwhichamethodisrun,ifneeded.
Allowsyoutopassaviewobjectasaparametertomethodsthattakemanagedobjectreferencesas
requiredparameter.TheSDKconvertstheviewobjecttothecorrespondingmanagedobject.
Working with View Object Property Values
vSphereSDKforPerlviewobjectsarePerlobjects.Youcanretrieveaview,accessandmanipulateits
properties,andcallitsmethodsusingPerl’sobject‐orientedsyntax.
Accessing Property Values
Eachpropertyisdefinedasaspecificdatatypeandcanbeoneofthefollowing: