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. 53
Chapter A Web Services for Management Perl Library
AfteryouhaveinstalledvSphereSDKforPerl,thefollowingartifactsandsamplesareinthevSphereSDKfor
Perlinstallationdirectory:
Sample Scripts
Youcanrunthesamplescriptsasis.YoucanalsousethescriptsasthestartingpointforwritingyourownPerl
scriptstoobtainCIMdatafromtheserver.IfyouacceptedthedefaultsduringvSphereSDKforPerl
installation,thesamplesareinthefollowinglocationona
Windowssystem:
C:\Program Files\VMware\VMware VI CLI\Perl\samples\WSMan
Whenyourunthesamples,youmustspecifyconnectionoptions.See“vSphereSDKforPerlCommon
Options”onpage 12.Forexample,youcanspecifyconnectionoptionsonthecommandlineasfollows:
perl <scriptname.pl> --server <servername> --username <username> --password <password>
Forexample:
perl firmwarerevisions.pl --server my.FQDN.esx35server.com --username root --password root_pass
If--serverisnotspecified,itdefaultstolocalhost.Ifyouareconnectingtoaremotehostanddonotspecify
ausernameandpassword,youareprompted.
TheCIMOMservicelistensforrequestsonport80.
TheWS‐ManagementlibraryconsistsoftheWSMan::BasicandWSMan::GenericOpsclasses,and
the
StubOps.pmobject‐orientedwrapperforgenericoperations.Thefollowingsectionsdiscusseachlibrary
component.
SOAP Message Construction with WSMan::WSBasic
YoucanusetheWSMan::WSBasicclasstoconstructSOAPmessagesforcommunicatingwiththe
WS‐Managementserver.ThePerlmoduleislocatedinPerl/lib/WSMan/WSBasic.pm.Alloperationsinthis
classreturndeserializedSOAP::SOMobjectsfromwhichyoucanextractthefaultcodeortheSOAPreplies.
Youusuallydonotusethis
moduledirectly.Instead,youusetheGenericOpsmodulebuiltontopofWSBasic.
GenericOpssupportsgenericoperationsasdefinedbytheDMTFstandards.See“GenericCIMOperations
withWSMan::GenericOps”onpage 57.IfyouwanttousetheSOAP::SOMlibrarydirectly,seetheCPAN
documentationforSOAP::SOM.
TheWSMan::WSBasicmodulerequires
thefollowingPerlmodules:
SOAP::Lite–WSMan::WSBasicrequiresVersion0.65orlatertoformSOAPmessagesandtoparseXML
repliesthatarereceivedfromtheWS‐Managementserver.
Table A-1. Components and Locations
Path Description
Perl/samples/WSMan SamplePerlscriptsthatusetheWS‐Managementlibrarytoobtaininformationthroughthe
CIMOMofanESX/ESXiorvCenterServersystem.Sampleprogramsletyouchecksensor
health,obtainfirmwarerevisionlevels,listfield‐replaceableunits,andlistpowersupply
details.SeeTable A‐2,“WSManSampleScripts,”onpage 53.
Perl/lib/WSMan WS‐ManagementinterfacePerlmodules.
Table A-2. WSMan Sample Scripts
Script Description
checksensorhealth.pl Returnsalistofsensorsassociatedwithallsystemdevices.
firmwarerevisions.pl Obtainsalistoffirmwarerevisionsonthesystem.
listfrus.pl Returnsalistofallfield‐replaceableunitsonthesystem.
listpowersupplies.pl Obtainsstatusofdiscretesensorsassociatedwithallpowersupplies.Demonstrates
traversingassociationsandusingGetInstance.