18.08.2013 Views

vSphere SDK for Perl Programming Guide - Documentation - VMware

vSphere SDK for Perl Programming Guide - Documentation - VMware

vSphere SDK for Perl Programming Guide - Documentation - VMware

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix A Web Services <strong>for</strong> Management <strong>Perl</strong> Library<br />

#Construct the client.<br />

$client = WSMan::WSBasic->new(<br />

path => 'wsman',<br />

username => 'wsman',<br />

password => 'secret',<br />

port => '8889',<br />

address => 'http://something.somewhere.com'<br />

);<br />

#Execute the Enumerate method.<br />

$result = $client->Enumerate(class_name => 'CIM_Processor',<br />

#namespace => 'root/cimv2'<br />

);<br />

if($result->fault){<br />

#If a fault occurred, then print the faultstring<br />

die $result->faultstring;<br />

}<br />

else{<br />

#If no fault occurred then get the enumid.<br />

$enumid = $result->result;<br />

}<br />

$result = $client->PullRelease(<br />

class_name => 'CIM_Processor',<br />

enumid => $enumid,<br />

action => 'Pull',<br />

#namespace => 'root/cimv2'<br />

);<br />

if($result->fault){<br />

#If a fault occurred, then print the faultstring<br />

die $result->faultstring;<br />

}<br />

else{<br />

# Do stuff with $result, which is a SOAP::SOM object containing a deserialized XML reply.<br />

# It is better to use the Generic Operations module, built on top of this module.<br />

}<br />

Generic CIM Operations with WSMan::GenericOps<br />

The GenericOps module implements some of the generic operations specified in the WS‐Management CIM<br />

bindings published by the DMTF. Not all generic operations are implemented. The <strong>Perl</strong> module is located at<br />

<strong>Perl</strong>/lib/WSMan/GenericOps.pm.<br />

The WSBasic module discussed in “SOAP Message Construction with WSMan::WSBasic” on page 53 provides<br />

more primitive intrinsic WS‐Management operations. The GenericOps module requires the WSMan::WSBasic<br />

module.<br />

Table A‐4 lists the methods the GenericOps class provides, which are discussed in more detail below.<br />

Table A-4. Methods in WSMan::GenericOps<br />

Method Description<br />

WSMan::GenericOps‐>new Constructor.<br />

register_xml_ns Registers extra XML namespaces that might be required <strong>for</strong> proprietary tags in the<br />

SOAP message.<br />

register_class_ns Registers extra CIM namespaces that the WS‐Management server might require.<br />

Identify Per<strong>for</strong>ms the wsmid:Identify operation, which causes the WS‐Management server<br />

to identify itself.<br />

EnumerateInstances Enumerates the instances of a given class.<br />

EnumerateInstanceNames Enumerates only the key values of the instances of a given class.<br />

EnumerateAssociatedInstances Returns the instances related to the source object through an association.<br />

EnumerateAssociatedInstanceNames Returns objects with only the key values of the associated instance populated.<br />

EnumerateAssociationInstances Returns objects containing association instances of which the class is a part.<br />

<strong>VMware</strong>, Inc. 57

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!