6.0
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
VMware, Inc. 19
2
ThischapterusesasimpleexamplescripttoillustratehowtowriteavSphereSDKforPerlscript.Thechapter
alsoexploresthebasicsofthevSphereAPIobjectmodel.
Thechapterincludesthesetopics:
“BasicvSphereSDKforPerlScript”onpage 19
“UnderstandingServer‐SideObjects”onpage 24
“UnderstandingPerlViewObjects”onpage 28
“WorkingwithViewObjectPropertyValues”onpage 28
“UnderstandingOperationsandMethods”onpage 30
“UpdatingViewObjects”onpage 32
Basic vSphere SDK for Perl Script
vSphereSDKforPerlscriptsretrieveobjects,suchasvirtualmachines,fromtheserverandworkwiththese
objects.vSphereSDKforPerlscriptsfollowthebasicpatternshowninTable 2‐1.
Writing vSphere SDK for Perl Scripts
2
NOTEThischapterdoesnotdiscussPerlbasics.YouareexpectedtoknowPerlandtounderstandits
programmingconventions.WhenyoudevelopavSphereSDKforPerlscript,followPerlstandardsfor
filenames,imports,andgeneralprocessingflow.Usetheappropriatefilenameextensionforthetypeofscript
orapplication
youarecreating(.plonWindowsand.plornosuffixonUNIX‐likesystems).
IMPORTANTThesamplescriptdoesnotusefiltersorpropertyfiltersforefficiency.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
Modules”onpage 20.