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
62 VMware, Inc.
Apersistencefileusedtostoreauthenticationcredentials.Currently,onlypasswordsaresupported.The
persistencefilemapsaremoteuseraccountfromanESX/ESXihosttothatuser’spasswordonthehost.
vSphereWebServicesSDK(C#andJava)andvSphereSDKforPerllibrariesforprogrammatically
managingthefile.vSphereWebServicesSDKandvSphereSDKforPerlaccessthesamecredentialstore.
Credential Store Components
ThevSphereSDKforPerlincludestwocredentialstorefilesinitsinstallationpackage:
VICredStore.pm–ThePerlpackageforthecredentialstorelibrarylocatedin:
Windows: \Program Files\VMware\VMware vSphere CLI\Perl\lib\VMware\VICredStore.pm
Linux: /usr/lib/perl5/site_perl/5.8.8/VMware/VICredStore.pm
Perlapplicationscanusethispackagetoadd,retrieve,delete,update,andlisttheentriesstoredinthe
credentialstore.Theapps/general/credstore_admin.plfileisanexampleforcredentialstoreuse.
Eachentryinthecredentialstoreisatupleofhostname,username,andpassword.Thepasswordis
storedin
anobfuscatedmannerinthecredentialstore.
credstore_admin.pl—APerlapplicationthatusesVICredStore.pmforaccessingthecredentialstore.
Youcanusecredstore_admin.pl,whichisanexample,asacommand‐lineinterfacetothecredential
store.credstore_admin.plislocatedin:
Windows: \Program Files\VMware\VMware vSphere CLI\Perl\apps\general\credstore_admin.pl
Linux: /usr/lib/vmware-viperl/apps/general/credstore_admin.pl
Managing the Credential Store
YoucanusePerltomanagethecredentialstoreinoneoftwoways:
UsethesubroutinesinVICredStore.pminyourPerlscript.See“vSphereCredentialStoreSubroutine
Reference”onpage 63forreferencedocumentation.Thecredstore_admin.plscriptillustrateshowto
usethesubroutines.
Usethe\apps\general\credstore_admin.plcommandstomanagethestoreinteractively.
Using the Credential Store
Afteryouhavesetupthecredentialstorewithusersandpasswords,youcanusethecredentialsasfollows:
InyourownPerlscripts,youcanretrievepasswordsorotherinformationasneededusingthelibrary
subroutine.
WhenyourunanexistingvSphereSDKforPerlorvSphereCLIscript,youcanspecifythehostanduser
nameeitherfromthecommandlineorinanenvironmentvariable.Whenthathostandusernamehasan
entrywithavalidpasswordinthecredentialstore,thescriptis
run.
Ifyourunascriptthatincludesahostnamebutnouser,andifthecredentialstorecontainsexactlyone
entryforthathost,thescripttakestheuserfromthatcredentialstoreentryandnotpromptforauser.
WhenyoucallanexistingvSphereSDKforPerlorvSphereCLIscript,andyouspecifyonlythehostname,
theauthenticationmechanismpromptsforausername.Ifnoentryexistsforthatuser,theauthentication
mechanismalsopromptsforapassword.
I
MPORTANTThepasswordsinthefileareobfuscatedbutnotencrypted.Youmustprotectthefilebyother
meansandcarefullycontrolwhocanaccessit.
IMPORTANTCreateauserwithappropriateprivilegesandstorethecorrespondingusernameandpassword
inthecredentialstore.Donotusetherootoradministratoruserandthecorrespondingpassword.