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
VMware, Inc. 17
Chapter 1 Getting Started with vSphere SDK for Perl
Hello Host: Running Your First Script
Beforeyourunyourfirstscript,youneedthefollowing:
SuccessfulvSphereSDKforPerlinstallation.SeethevSphereSDKforPerlInstallationGuideforinformation.
AccesstooneofthesupportedvSpherehosts.Performaconnectioncheckusingtheprocessdescribedin
“UsetheManagedObjectBrowsertoExploreServer‐SideObjects”onpage 24.
To run the connect.pl script
1Atacommandprompt,changetothe/apps/generaldirectory.
C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\general
--protocol <HTTP|HTTPS>
VI_PROTOCOL=<HTTP|HTTPS>
Usesthespecifiedprotocoltoconnecttothesystemspecifiedby--server.
DefaultisHTTPS.
--psc <hostname_or_IP>
VI_PSC=<hostname_or_IP>
HostnameorIPaddressofthePlatformServicesControllerinstancethatis
associatedwiththevCenterServersystemthatmanagesthehost.Inmany
cases,thePlatformServicesControllerisembeddedin
thevCenterServer
system,butexternalPlatformServicesControllerinstancesaresupportedas
well.Forthosecases,usethe--serveroptiontospecifythevCenterServer
systemthatmanagesthehost.
Thisoptionimpliesus erauthenticationwithvCenterSingleSign‐On.Theuser
youspecifymustbeabletoauthenticateto
vCenterSingleSign‐On.
--savesessionfile <file>
VI_SAVESESSIONFILE=<file>
Savesasessiontothespecifiedfile.Thesessionexpiresifithasbeenunused
for30minutes.
--server <server>
VI_SERVER=<server>
UsesthespecifiedESXiorvCenterServersystem.Defaultislocalhost.
If--serverpointstoavCenterServersystem,youcanalsospecifythe--psc
option
tologintothevCenterServersystemwithvCenterSingleSign‐On.
Usethe--vihostoptiontospecifytheESXihostthatyouwanttorunthe
commandagainst.See“AuthenticatingThroughvCenterServerandvCenter
SingleSign‐On”onpage 13.
--servicepath <path>
VI_SERVICEPATH=<path>
Usesthespecifiedservicepathtoconnectto
theESXihost.Defaultis
/sdk/webService.
--sessionfile <file>
VI_SESSIONFILE=<file>
Usesthespecifiedsessionfiletoloadapreviouslysavedsession.Thesession
mustbeunexpired.
--thumbprint <thumbprint>
VI_THUMBPRINT=<thumbprint>
ExpectedSHA‐1hostcertificatethumbprintifnoCAcertificatesfileis
providedinthe--cacertsfile argument.Thethumbprintisreturnedbythe
serverintheerrormessage
ifyouattempttorunacommandwithout
specifyingathumbprintorcertificatefile.
--url <url>
VI_URL=<url>
ConnectstothespecifiedvSphereWebServicesSDKURL.
--username <u_name>
VI_USERNAME=<u_name>
Usesthespecifiedusername.
If--serverspecifiesavCenterServersystem,theusernameand
passwordapplytothatserver.IfyoucanlogintothevCenterServer
system,youneednoadditionalauthenticationtoruncommandsonthe
ESXihoststhatservermanages.
If--serverspecifiesanESXisystem,theusernameandpasswordapply
tothatsystem.
Ifyoudonotspecifyausernameandpasswordonthecommandline,the
systempromptsyouanddoesnotechoyourinputtothescreen.
--vihost <host>
-h <host>
WhenyourunavCLIcommandwiththe
--serveroptionpointingtoa
vCenterServersystem,use--vihosttospecifytheESXihosttorunthe
commandagainst.
N
OTE:Thisoptionisnotsupportedforeachcommand.Ifsupported,the
optionisincludedwhenyourun<cmd> --help.
Table 1-3. Options Available for All SDK for Perl Commands
Option and Environment Variable Description