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. 13
Chapter 1 Getting Started with vSphere SDK for Perl
Thisorderofprecedencealwaysapplies.Thatmeans,forexample,thatyoucannotoverrideanenvironment
variablesettinginaconfigurationfile.
Authenticating Through vCenter Server and vCenter Single Sign-On
ForallESXihoststhat aremanagedbyavCenterServersystemthatisintegratedwithvCenterSingleSign‐On
6.0andlater,youcanauthenticatedirectlytothevCenterServersystem,oryoucanauthorizetovCenter
ServerthroughvCenterSingleSign‐On.
BestpracticeistoauthenticatethroughvCenter
SingleSign‐On.ThevCenterSingleSign‐Onserviceis
includedinthePlatformServicesController.ThePlatformServicesControllercanbeembeddedinyour
vCenterServerinstallation,oronePlatformServicesControllercanhandleauthentication,certificate
management,andsomeothertasksformultiplevCenterServersystems.
Youusethe
--pscoptionand,optionally,the--server option.
psc‐SpecifiesthePlatformServicesControllerinstanceassociatedwiththevCenterServersystemthat
managesthehost.
server‐SpecifiesthevCenterServersystemthatmanagesthehost.RequiredifthePlatformServices
ControllerinstanceisassociatedwithmorethanonevCenterServersystem.
vihost‐SpecifiestheESXihost,asinearlierversionsofvCLI.
Example
vminfo.pl --server <vc_HOSTNAME_OR_IP> --psc <psc_HOSTNAME_OR_IP> --vihost
<esxi_HOSTNAME_OR_IP>--username root --password vmware --vihost <esxi_host>
IfthespecifieduserisknowntovCenterSingleSign‐On,asessioniscreated.Youcansavethesessionwiththe
--savesessionfileargument,andlaterusethatsessionwiththe--sessionfile argument.
UsingasessionfileresultsinlessoverheadandbetterperformancethanconnectingtothePlatformServices
Controller
repeatedly.
Using a Session File
Thesave_session.plscriptintheapps/sessiondirectoryillustrateshowtocreateasessionfile.Youcan
modifythescriptandincludeitinyourownapplication,orcreateasessionfileusingthescriptonthe
commandline,andthenpassinthatsessionfilewhenrunningvSphereSDKforPerl
commands.See“Saving
Sessions”onpage 36.
Thesessionfiledoesnotrevealpasswordinformation.Ifasessionfileisnotusedfor30minutes,thesession
expires.
To create and use a session file
1 Connecttothedirectorywherethescriptislocated,forexample,onWindows:
cd C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\session
Environment
variable
Passwordspecifiedinanenvironment
variable.
“SettingEnvironmentVariables”onpage 14
Credentialstore Passwordretrievedfromthecredentialstore. “CredentialStorePerlLibrary”onpage 61
Currentaccount
(ActiveDirectory)
Currentaccountinformationus edtoestablish
anSSPIconnection.Windowsonly.
.“UsingMicrosoftWindowsSecuritySupport
ProviderInterface(SSPI)”onpage 15
Prompttheuserfora
password.
NOTEYoucannotusethisapproachifvCenterServerisintegratedwithvCenterSingleSign‐On5.0.
Table 1-2. vSphere CLI Authentication Precedence (Continued)
Authentication Description See