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. 57
Chapter A Web Services for Management Perl Library
#Construct the client.
$client = WSMan::WSBasic->new(
path => 'wsman',
username => 'wsman',
password => 'secret',
port => '8889',
address => 'http://something.somewhere.com'
);
#Execute the Enumerate method.
$result = $client->Enumerate(class_name => 'CIM_Processor',
#namespace => 'root/cimv2'
);
if($result->fault){
#If a fault occurred, then print the faultstring
die $result->faultstring;
}
else{
#If no fault occurred then get the enumid.
$enumid = $result->result;
}
$result = $client->PullRelease(
class_name => 'CIM_Processor',
enumid => $enumid,
action => 'Pull',
#namespace => 'root/cimv2'
);
if($result->fault){
#If a fault occurred, then print the faultstring
die $result->faultstring;
}
else{
# Do stuff with $result, which is a SOAP::SOM object containing a deserialized XML reply.
# It is better to use the Generic Operations module, built on top of this module.
}
Generic CIM Operations with WSMan::GenericOps
TheGenericOpsmoduleimplementssomeofthegenericoperationsspecifiedintheWS‐ManagementCIM
bindingspublishedbytheDMTF.Notallgenericoperationsareimplemented.ThePerlmoduleislocatedat
Perl/lib/WSMan/GenericOps.pm.
TheWSBasicmodulediscussedin“SOAPMessageConstructionwithWSMan::WSBasic”onpage 53provides
moreprimitiveintrinsicWS‐Management
operations.TheGenericOpsmodulerequirestheWSMan::WSBasic
module.
Table A‐4liststhemethodstheGenericOpsclassprovides,whicharediscussedinmoredetailbelow.
Table A-4. Methods in WSMan::GenericOps
Method Description
WSMan::GenericOps‐>new Constructor .
register_xml_ns RegistersextraXMLnamespacesthatmightberequiredforproprietarytagsinthe
SOAPmessage.
register_class_ns RegistersextraCIMnamespacesthattheWS‐Managementservermightrequire.
Identify Performsthewsmid:Identifyoperation,whichcausestheWS‐Managementserver
toidentifyitself.
EnumerateInstances Enumeratestheinstancesofagivenclass.
EnumerateInstanceNames Enumerates
onlythekeyvaluesoftheinstancesofagivenclass.
EnumerateAssociatedInstances Returnstheinstancesrelatedtothesourceobjectthroughanassociation.
EnumerateAssociatedInstanceNames Returnsobjectswithonlythekeyvaluesoftheassociatedinstancepopulated.
EnumerateAssociationInstances Returnsobjectscontainingassociationinstancesofwhichtheclassisapart.