The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

XAS::Lib::WS::Manage - A class to manage Servers over WS-Manage

SYNOPSIS

 use Data::Dumper;
 use XAS::Lib::WS::Manage;

 my $results;
 my $wsman = XAS::Lib::WS::Manage->new(
     -username    => 'Administrator',
     -password    => 'secret',
     -url         => 'http://windowserver:5985/wsman',
     -auth_method => 'basic',
 );

 $results = $wsman->invoke(
     -action   => 'stopservice', 
     -class    => 'Win32_Service', 
     -selector => {Name => 'spooler'}
 );
 warn Dumper($results);

 $results = $wsman->get(
     -class    => 'Win32_Service', 
     -selector => {Name => 'spooler'}
 );
 warn Dumper($results);

 $results = $wsman->invoke(
     -action   => 'startservice', 
     -class    => 'Win32_Service', 
     -selector => {Name => 'spooler'}
 );
 warn Dumper($results);

 $results = $wsman->get(
     -class    => 'Win32_Service', 
     -selector => {Name => 'spooler'}
 );
 warn Dumper($results);

DESCRIPTION

This package implements an interface to manage a server thru WS-Manage. This is primiarily geared toward Microsoft based servers. But other servers can be accommodated when using the proper resources and classes.

METHODS

new

This package inherits from XAS::Lib::WS::Base and takes the same parameters.

create(...)

This method will create an object within the resource class, depending on the selector. It takes the following parameters:

-resource

The resource of the class. Defaults to 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2'

-class

A class that exists within the resource.

-selector

A hashref of name value pairs to select an object within the class.

-xml

Raw XML to be used as the data source for the created object.

delete(...)

This method will delete an object within the resource class, depending on the selector. It takes the following parameters:

-resource

The resource of the class. Defaults to 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2'

-class

A class that exists within the resource.

-selector

A hashref of name value pairs to select an object within the class.

enumerate(...)

This method will return all objects within the resource class, depending on the selector. It takes the following parameters:

-resource

The resource of the class. Defaults to 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2'

-class

A class that exists within the resource.

-selector

A hashref of name value pairs to select an object within the class.

get(...)

This method will retrieve a single object from the resource class, depending on the selector. It takes the following parameters:

-resource

The resource of the class. Defaults to 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2'

-class

A class that exists within the resource.

-selector

A hashref of name value pairs used to select an object within the resource class.

invoke(...)

This method will initiate an action on an object within the resource class, depending on the selector. It takes the following parameters:

-resource

The resource of the class. Defaults to 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2'

-class

A class that exists within the resource.

-selector

A hashref of name value pairs to select an object within the class.

-action

A object specific action to be performed.

pull(...)

This method is used during an enumeration to collect all of the pending items. This method is usually not called directly. It takes the following parameters:

-resource

The resource of the class. Defaults to 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2'

-class

A class that exists within the resource.

-context

The context of the enumeration.

-items

A arraryref of items collected during the enumeration.

put(...)

This method will update an object within the resource class, depending on the name of the key. It takes the following parameters:

-resource

The resource of the class. Defaults to 'http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2'

-class

A class that exists within the resource.

-key

The name of a key within the object.

-value

The value of that key.

-data

A hashref of name value pairs to be used for the update action.

SEE ALSO

XAS::Lib::WS::Base
XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (c) 2012-2016 Kevin L. Esteb

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.