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
12 VMware, Inc.
Output(receivingfromtheserver):
TomatchBooleanvaluesinafilter,usethestringstrueandfalse.See“CreatingandUsingFilters”on
page 33.
Date/Time–TheserverreturnsaSOAPdateTimevalue.YoucanusetheDate::ParsePerlmoduleto
processtheseobjects.
ThevSphereSDKforPerlacceptsonlynativeSOAPdateTimevaluesusingstandarddatetimeformat
withorwithoutfractionalseconds,andwithorwithoutGMT(Z)timezone:
YYYY-MM-DDThh:mm:ssTZD,
forexample,1997-07-16T19:20:30+01:00
YYYY-MM-DDThh:mm:ss.sTZD,forexample,1997-07-16T19:20:30.45+01:00
TheSDKalwaysreturnsdateTimevaluesinthestandarddatetimeformat.
SOAPerrormessage–Mostlikelyindicatesanerrorontheserver,notanerrorwiththecommunication
totheserver.
vSphere SDK for Perl Common Options
AnumberofoptionsareavailableforanyvSphereSDKforPerlscript.Mostoftheseoptionsallowyouto
specifythehostorhoststoconnectto.Mostoptionsrequireanoptionvalue.
perl <app_name>.pl --<option_name> <option_value>
Forexample,topoweronavirtualmachineusingthevmcontrol.plutilityapplication,youmustspecifythe
nameofthevirtualmachinetopoweron,asfollows:
perl vmcontrol.pl --server <myserver> --username <admin> --password <mypassword> --operation
poweron --vmname <virtual_machine_name>
Runanyapplicationorsamplewithoutanyoptionsorwith--helptoseeitsparametersandexecution
examples.Informationaboutcommonandscript‐specificoptionsisincluded.
Specifying Options
Youcanspecifythecommonoptionsinseveralways,discussedinthissection.
WhenyourunavSphereCLIcommand,authenticationhappensinthefollowingorderofprecedence:
false: Use0,ʹ0ʹ,orʹfalseʹ(capitalizationignored)
true: Use1,ʹ1ʹ,orʹtrueʹ(capitalizationignored)
false: Returnvalueis0
true: Returnvalueis1
I
MPORTANTIfthehostyouaretargetingisinlockdownmode,youcannotexecutePerlscriptsagainstthe
host.
Table 1-2. vSphere CLI Authentication Precedence
Authentication Description See
TargetingvCenter
ServerandUsing
vCenterSingle
Sign‐On
Ifyouareworkinginanenvironmentthatis
managedbyvCenterSingleSign‐On,youcan
specifythevCenterSingleSign‐Onserverand
ausername,password,andtargethost.
“UsingaSessionFile”onpage 13
Commandline Password(--password),
sessionfile
(--sessionfile),orconfigurationfile
(--config) specifiedonthecommandline.
“UsingaSessionFile”onpage 13
Configurationfile Passwordsspecifiedina.visdkrc
configurationfile.
“UsingaConfigurationFile”onpage 15