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. 15
Chapter 1 Getting Started with vSphere SDK for Perl
VI_PROTOCOL = https
VI_PORTNUMBER = 443
Donotescapespecialcharactersinthefilethatspecifiesenvironmentvariables.
Ifyouhavesetupyoursystemtorunthisfile,youcanrunscriptsonthespecifiedserverafterwards.
Using a Configuration File
Aconfigurationfileisatextfilethatcontainsvariablenamesandsettings.Variablescorrespondingtothe
connectionoptionsareshowninTable 1‐3,“OptionsAvailableforAllSDKforPerlCommands,”onpage 16.
Use--configiftheconfigurationinformationissavedinadifferentfilethan./visdkrc.Ifyou
specify
--config,thesystemignoresthe./visdkrcsettings.
Youcanusethe--configoptiontorunascriptwiththeconfigurationfile,forexample:
connect.pl --config <my_saved_config> --list
Usingaconfigurationfileisusefulforrepeatedlyenteringconnectiondetails.Ifyouhavemultiple
vCenter ServerorESX/ESXisystemsandyouadministereachsystemindividually,youcancreatemultiple
configurationfileswithdifferentnames.Whenyouwanttorunacommandorasetofcommandsonaserver,
youpass
inthe--configoptionwiththeappropriatefilenameatthecommandline.
Using Microsoft Windows Security Support Provider Interface (SSPI)
Youcanusethe--passthroughauthcommand‐lineargumenttologintoavCenterServersystem(vCenter
Serverversion2.5Update2orlater).Using--passthroughauthpassesthecredentialsoftheexecutinguser
totheserver.Iftheexecutinguserisknownbyboththemachinefromwhichyouaccessthe
vCenterServer
systemandthemachinerunningthevCenterServersystem,noadditionalauthenticationisrequired.
IfSDKcommandsandthevCenterServersystemrunonthesamemachine,alocalaccountfortheexecuting
userworks.Iftheyrunondifferentmachines,thentheexecutingusermusthavean
accountinadomain
trustedbybothmachines.
SSPIsupportsanumberofprotocols.Bydefault,itselectstheNegotiateprotocol,whichindicatesthatclient
andserverattempttofindamutuallysupportedprotocol.Alternatively,youcanuse
--passthroughauthpackagetospecifyanotherprotocolsupportedbySSPI.Kerberos,theWindows
standardfor
domain‐levelauthentication,iscommonlychosen.
IfthevCenterServersystemisconfiguredtoacceptonlyaspecificprotocol,specifyingtheprotocoltovSphere
SDKforPerlcommandswith --passthroughauthpackagemightberequiredforsuccessfulauthentication
totheserver.Ifyouuse--passthroughauth,youdonothavetospecifyauthentication
informationinany
otherway.Forexample,torunconnect.plontheserver,youcanusethefollowingcommandatthe
commandline.
<command> <login_params> --passthroughauth
SeetheMicrosoftWebsiteforadetaileddiscussionofSSPI.
ThefollowingexampleconnectstoaserverthathasbeensetuptouseSSPI.Whenyourunthecommand,the
systemcallsvminfo.plwiththe--vmnameoption.Thesystemdoesnotpromptforausernameandpassword
because
thecurrentuserisknowntotheserver.
vminfo.pl --server <vc_server> --passthroughauth --passthroughauthpackage “Kerberos”
--vihost my_esx --vmname <name>
CAUTIONLimitreadaccesstoaconfigurationfile,especiallyifitcontainsusercredentials.
NOTEUsingSSPIissupportedonlywhenyouruncommandsfromWindows,anduseavCenterServer
systemasthetargetserver.