6.0

Table Of Contents
VMware, Inc. 19
2
ThischapterusesasimpleexamplescripttoillustratehowtowriteavSphereSDKforPerlscript.Thechapter
alsoexploresthebasicsofthevSphereAPIobjectmodel.
Thechapterincludesthesetopics:
“BasicvSphereSDKforPerlScript”onpage 19
“UnderstandingServerSideObjects”onpage 24
“UnderstandingPerlViewObjects”onpage 28
“WorkingwithViewObjectPropertyValuesonpage 28
“UnderstandingOperationsandMethods”onpage 30
“UpdatingViewObjects”onpage 32
Basic vSphere SDK for Perl Script
vSphereSDKforPerlscriptsretrieveobjects,suchasvirtualmachines,fromtheserverandworkwiththese
objects.vSphereSDKforPerlscriptsfollowthebasicpatternshowninTable 21.
Writing vSphere SDK for Perl Scripts
2
NOTEThischapterdoesnotdiscussPerlbasics.YouareexpectedtoknowPerlandtounderstandits
programmingconventions.WhenyoudevelopavSphereSDKforPerlscript,followPerlstandardsfor
filenames,imports,andgeneralprocessingflow.Usetheappropriatefilenameextensionforthetypeofscript
orapplication
youarecreating(.plonWindowsand.plornosuffixonUNIXlikesystems).
IMPORTANTThesamplescriptdoesnotusefiltersorpropertyfiltersforefficiency.See“RefiningvSphereSDK
forPerlScripts”onpage 33forinformationaboutthosetopics.
Table 2-1. Basic vSphere SDK for Perl Script (simpleclient.pl)
Code element Discussed in
#!/usr/bin/perl
use strict;
use warnings;
use VMware::VIRuntime;
“Step1:ImportthevSphereSDKforPerl
Modulesonpage 20.