6.5
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
vSphere SDK for Perl Programming Guide
58 VMware, Inc.
WSMan::GenericOps->new
Constructorthattakesahashargumentcontainingkey‐valuepairsinthefollowingform:
$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
Theconstructorhasthefollowingarguments:
register_xml_ns
RegistersextraXMLnamespacesthatmightberequiredforproprietarytagsintheSOAPmessage.Calling
register_xml_nsisnotrequiredunlessyouaretryingtoextendtheclassitself.
Arguments
Ahash.Keysaretheprefixes,valuesaretherelativeURLsasvalues.
Example
$client->register_xml_ns((wsen => 'http://www.dmtf.org/wsen'));
DeclaresaprefixwsenwiththeURLhttp://www.dmtf.org/wsenintheglobalXMLnamespace.
register_class_ns
RegistersextraResourceURIsthattheWS‐Managementservermightrequire.Bydefault,theconstructor
providesasetofResourceURIsonlyforclassesintheCIMschema.Classeswithotherschemanames,suchas
VMware_*classes,requireadifferentResourceURIwhenenumeratedusingthevSphereSDKforPerl.
Youcanfindthe
ResourceURIscorrespondingtoothersupportedschemasintheOpenWSManconfiguration
file,whichislocatedintheserverʹsfilesystemat/etc/openwsman/openwsman.conf.TheResourceURIsare
listedinthevalueofthevendor_namespacesconfigurationparameter.
EnumerateAssociationInstanceNames Returnsobjectscontainingkeyvaluesoftheassociationinstancesofwhichtheclassis
apart.
GetInstance Retrievesaparticularinstanceofaclass.
Table A-4. Methods in WSMan::GenericOps (Continued)
Method Description
Argument Description
address URLoftheWS‐Managementserver.Specifythetransportprotocolbyaddingthehttpprefixfor
HTTP(basicuser‐passwordauthentication)orthehttpsprefixforHTTPwithSSLencryption.
port PortonwhichWS‐Managementlistensforrequests.
path PathtotheWS‐Managementserver.Thepathiscombinedwith
theaddressandportargumentsto
formthecomp leteURLoftheWS‐Managementserverinhttp://address:port/pathorder.
username UsernamefortheWS‐Managementserver.
password Passw ordfortheWS‐Managementserver.
namespace DefaultCIMnamespace.Defaultisroot/cimv2.
Ifthenamespaceisnotroot/cimv2,youmustpassinthe
namespaceoftheclassinthisargument.
timeout
(optional)
TimeoutfortheHTTPrequest,incaseofslowservers.