6.0

Table Of Contents
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.
TheWSManagementlibraryconsistsoftheWSMan::BasicandWSMan::GenericOpsclasses,and
the
StubOps.pmobjectorientedwrapperforgenericoperations.Thefollowingsectionsdiscusseachlibrary
component.
SOAP Message Construction with WSMan::WSBasic
YoucanusetheWSMan::WSBasicclasstoconstructSOAPmessagesforcommunicatingwiththe
WSManagementserver.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::LiteWSMan::WSBasicrequiresVersion0.65orlatertoformSOAPmessagesandtoparseXML
repliesthatarereceivedfromtheWSManagementserver.
Table A-1. Components and Locations
Path Description
Perl/samples/WSMan SamplePerlscriptsthatusetheWSManagementlibrarytoobtaininformationthroughthe
CIMOMofanESX/ESXiorvCenterServersystem.Sampleprogramsletyouchecksensor
health,obtainfirmwarerevisionlevels,listfieldreplaceableunits,andlistpowersupply
details.SeeTable A2,“WSManSampleScripts,”onpage 53.
Perl/lib/WSMan WSManagementinterfacePerlmodules.
Table A-2. WSMan Sample Scripts
Script Description
checksensorhealth.pl Returnsalistofsensorsassociatedwithallsystemdevices.
firmwarerevisions.pl Obtainsalistoffirmwarerevisionsonthesystem.
listfrus.pl Returnsalistofallfieldreplaceableunitsonthesystem.
listpowersupplies.pl Obtainsstatusofdiscretesensorsassociatedwithallpowersupplies.Demonstrates
traversingassociationsandusingGetInstance.