Generic CIM Operations with WSMan::GenericOps
The GenericOps module implements some of the generic operations specified in the WS-Management CIM bindings published by the DMTF. Not all generic operations are implemented. The Perl module is located at Perl/lib/WSMan/GenericOps.pm.
The WSBasic module discussed in SOAP Message Construction with WSMan::WSBasic provides more primitive intrinsic WS-Management operations. The GenericOps module requires the WSMan::WSBasic module.
Methods in WSMan::GenericOps lists the methods the GenericOps class provides, which are discussed in more detail below.
Performs the wsmid:Identify operation, which causes the WS-Management server to identify itself.
WSMan::GenericOps->new
Constructor that takes a hash argument containing key-value pairs in the following form:
$client = WSMan::GenericOps->new(( address => 'http://www.abc.com/',
port => '80',
path => 'wsman',
username => 'wsman',
password => 'secret',
namespace => 'root/cimv2', #optional
timeout => ‘60’ #optional
));
Arguments
The constructor has the following arguments:
URL of the WS-Management server. Specify the transport protocol by adding the http prefix for HTTP (basic user-password authentication) or the https prefix for HTTP with SSL encryption.
Port on which WS-Management listens for requests.
Path to the WS-Management server. The path is combined with the address and port arguments to form the complete URL of the WS-Management server in http://address:port/path order.
User name for the WS-Management server.
Password for the WS-Management server.
Default CIM namespace. Default is root/cimv2.
If the namespace is not root/cimv2, you must pass in the namespace of the class in this argument.
timeout (optional)
Timeout for the HTTP request, in case of slow servers.
register_xml_ns
Registers extra XML namespaces that might be required for proprietary tags in the SOAP message. Calling register_xml_ns is not required unless you are trying to extend the class itself.
Arguments
A hash. Keys are the prefixes, values are the relative URLs as values.
Example
$client->register_xml_ns((wsen => 'http://www.dmtf.org/wsen'));
Declares a prefix wsen with the URL http://www.dmtf.org/wsen in the global XML namespace.
register_class_ns
Registers extra ResourceURIs that the WS-Management server might require. By default, the constructor provides a set of ResourceURIs only for classes in the CIM schema. Classes with other schema names, such as VMware_* classes, require a different ResourceURI when enumerated using the vSphere SDK for Perl.
You can find the ResourceURIs corresponding to other supported schemas in the OpenWSMan configuration file, which is located in the server's file system at /etc/openwsman/openwsman.conf. The ResourceURIs are listed in the value of the vendor_namespaces configuration parameter.
Arguments
A hash. Keys are the prefixes, values are the relative URLs as values.
Example
$client->register_class_ns((OMC => 'http://schema.omc-project.org/wbem/wscim/1/cim-schema/2',
VMware => 'http://schemas.vmware.com/wbem/wscim/1/cim-schema/2'));
Registers the ResourceURIs needed to enumerate classes in the OMC and VMware schemas.
Identify
Performs the wsmid:Identify operation, which causes the WS-Management server to identify itself. Helps you determine whether the server is running.
Arguments
No arguments.
Returns
Prints a fault string if a fault occurs, or returns the reply sent by the server. The reply is a hash reference containing the parsed reply in key-value pairs.
EnumerateInstances
Enumerates the instances of a given class.
Returns
Returns a list of hashes containing the parsed reply from the server, or prints a fault string from the server if an error occurs.
Example
$client->EnumerateInstances(
class_name => 'CIM_Processor',
namespace => 'root/cimv2' #optional
)
EnumerateInstanceNames
Enumerates only the key values of the instances of a given class. Similar to EnumerateInstances.
Returns
Like EnumerateInstances, either returns a list of hashes containing the parsed reply from the server (keys only), or prints a fault string if an error occurs.
EnumerateAssociatedInstances
Returns the instances related to the source object through an association. Results are filtered based on the argument you pass in.
Arguments
Accepts the following arguments:
Name of the class for which you want to get the associated instances.
role (optional)
Role that the object plays in the association class. The method filters the results according to the role.
resultclassname (optional)
Result class name, which must be present in the association. The method returns only those instances.
resultrole (optional)
Role that the result class plays in this instance. The method returns the results based on resultrole.
includeresult (optional)
Default CIM namespace. Default is root/cimv2.
If the namespace is not root/cimv2, you must pass in the namespace of the class in this argument.
Example
$client->EnumerateAssociatedInstances(
class_name => 'CIM_Foo',
selectors => \%hash;
associationclassname => 'CIM_Bar', #optional
role => 'CIM_Baz', #optional
resultclassname => 'CIM_Bat', #optional
resultrole => 'CIM_Quux', #optional
includeresult => \%hash, #optional
namespace => 'root/cimv2' #optional
EnumerateAssociatedInstanceNames
Returns objects with only the key values of the associated instance populated. The usage is the same as for EnumerateAssociatedInstances.
EnumerateAssociationInstances
Returns objects containing association instances of which the class is a part. The usage is the same as for EnumerateAssociatedInstances.
EnumerateAssociationInstanceNames
Returns objects containing key values of the association instances of which the class is a part. The usage is the same as for EnumerateAssociatedInstances.
GetInstance
Retrieves a particular instance of a class.
Arguments
Accepts the following named arguments:
Keys for the instance on which you want to perform the GetInstance operation. The argument is passed as a reference to a hash containing the keys in name-value pairs.
Default CIM namespace. Default is root/cimv2.
If the namespace is not root/cimv2, you must pass in the namespace of the class in this argument.
Returns
Prints a fault string or returns the result in a hash.