NAME

Net::OpenWBEM::Provider - Perl provider interface for OpenWBEM


DESCRIPTION

This is owperlprovider, a Perl provider interface for OpenWBEM. This lets you write OpenWBEM providers in Perl. There are also client side Perl bindings for OpenWBEM, but they are in a different package.

This module contains no functionality on its own, it merely imports the necessary modules when writing a provider.


WRITING A PROVIDER

Writing a provider involves implementing a number of functions that are called by the CIMOM whenever data from a certain class (or classes) is needed.

Here you will find some general information about writing a provider. This is followed by a list of specific functions that you can implement.

Initializing

There is no initialize function. Perform any initializing tasks by putting code outside of any functions. This code will be run immediately after the script is loaded and compiled.

Throwing exceptions

To throw an exception, just use the standard Perl die statement. The provider interface wraps each method invocation in an eval { } block and then checks the value of $@ upon return from the Perl code. If the value of $@ is defined, an exception will be raised, and the text used in the die statement will be passed back to the caller.

Logging

Access to OpenWBEM's logging facility is available through the Provider Environment provided as first argument to all methods ($env).

 my $logger = $env->getLogger();

The logger provides the following methods:

 $logger->logDebug("Message", $fileName, $lineNumber, $methodName);
 $logger->logInfo(...);
 $logger->logError(...);
 $logger->logFatalError(...);

Only the first parameter (the log message) is mandatory.

Log::Log4perl-Style - methods are provided for convenience - they fill out the $fileName, $lineNumber and $methodName fields automatically.

These are:

 $log->debug("Message");
 $log->info("Message");
 $log->warn("Message");        # same as error
 $log->error("Message");
 $log->fatal("Message"); 
 $log->logdie("Message");      # same as $log->fatal("Message"); die "Message";

Dynamic unloading

OpenWBEM has the ability to dynamically unload providers. This holds true for Net::OpenWBEM::Provider plugins, too, but you have to keep some things in mind:

Triggering dynamic unloading

Net::OpenWBEM::Provider will only unload Perl Providers which implement the following method:

 sub canUnload { return 1; };

Returning any true value from canUnload tells the provider interface that it may unload this provider.

Net::OpenWBEM::Provider will never unload providers which do not implement this method (though it will attempt to call it).

If you have providers which may become non-unloadable after some part of work do the following:

 my $CAN_UNLOAD = 1;    # a GLOBAL !
 
 sub canUnload { return $CAN_UNLOAD; }
 
 ...
 
 # somewhere else, maybe in invokeMethod or the like
 $CAN_UNLOAD = 0;
 
The provider will not unload after you've set $CAN_UNLOAD to 0.


PROVIDER METHODS

The provider interface is still considered incomplete. A C++ OpenWBEM provider has access to functions that are not documented here, because they are not currently available to Perl providers. This is not a limitation of Perl, only that the relevant calling code has not been written.

Following each function is a more detailed list of the parameters used when the function is invoked. It lists recommended names and the types of each parameter.

canUnload

  sub canUnload
  {
      return 1;
  }

When OpenWBEM is ready to unload a provider, it calls this method first, to see if it's ok to unload. Return any true value to allow OpenWBEM to proceed with the unload.

enumInstanceNames

  sub enumInstanceNames
  {
      my ($env, $ns, $className, $result, $cimClass) = @_;
  
      # foreach underlining object...
      {
          my $mcop = Net::OpenWBEM::CIMObjectPath->new($className, $ns);
  
          # fill key properties
          # ...
  
          $result->handle($mcop);
      }
  }

enumInstances

  sub enumInstances
  {
      my ($env, $ns, $className, $localOnly, $deep, $includeQualifiers,
          $includeClassOrigin, $result, $cimClass, $requestedClass,
                  $propertyList) = @_;
      # foreach underlining object...
      {
          my $ci = $cimClass->newInstance;
          # set instance properties
          # ...
          $result->handle($ci);
      }
  }

getInstance

  sub getInstance
  {
      my ($env, $ns, $instanceName, $localOnly, $includeQualifiers,
          $includeClassOrigin, $propertyList, $cimClass) = @_;
      # get key values from $instanceName
      my $key1 = $instanceName->getStringKeyValue('key1');
      my $key2 = $instanceName->getIntegerKeyValue('key2');
      my $ci = $cimClass->newInstance;
        
      # set instance properties
      # ...
        
      return $ci;
  }

createInstance

  sub createInstance
  {
      my ($env, $ns, $cimInstance) = @_;
      # create the underlining object
      # ...
      # create a path for the new instance
      my $cop = Net::OpenWBEM::CIMObjectPath->new($ns, $cimInstance);
      return $cop;
  }

modifyInstance

  sub modifyInstance
  {
      my ($env, $ns, $modifiedInstance, $previousInstance,
          $includeQualifiers, $propertyList, $theClass) = @_;
        
      # modify the underlining data
      # ...
  }

deleteInstance

  sub deleteInstance
  {
      my ($env, $ns, $cop) = @_;
      # delete the underlining object
      # ...
  }

associators

  sub associators
  {
      my ($env, $result, $ns, $objectName, $assocClass, $resultClass,
          $role, $resultRole, $includeQualifiers, $includeClassOrigin,
          $propertyList) = @_;
      # for each underlining associated object...
      {
          my $ci = ...
          # set instance properties
          # ...
          $result->handle($ci);
      }
  }

associatorNames

  sub associatorNames
  {
      my ($env, $result, $ns, $objectName, $assocClass, $resultClass,
          $role, $resultRole) = @_;
      # foreach underlining associated object...
      {
          my $mcop = Net::OpenWBEM::CIMObjectPath->new($className, $ns);
          # fill key properties
          # ...
          $result->handle($mcop);
      }
  }

references

  sub references
  {
      my ($env, $result, $ns, $objectName, $resultClass,
          $role, $includeQualifiers, $includeClassOrigin,
          $propertyList) = @_;
      # for each association...
      {
          my $ci = ...
          # set instance properties
          # ...
          $result->handle($ci);
      }
  }

referenceNames

  sub referenceNames
  {
      my ($env, $result, $ns, $objectName, $resultClass, $role) = @_;
      # for each association...
      {
          my $mcop = Net::OpenWBEM::CIMObjectPath->new($resultClass, $ns);
          # fill key properties
          # ...
          $result->handle($mcop);
      }
  }

invokeMethod

  sub invokeMethod
  {
      my ($env, $ns, $objectName, $methodName, $inParams, $outParams) = @_;
      # generate a value...
      my $value = ....
      return $value;
  }


SEE ALSO

  Net::OpenWBEM
  Net::OpenWBEM::Client


AUTHOR

Jason Long - jason@long.name


COPYRIGHT

This file is part of owperlprovider.

Copyright (c) 2004-2005 Jason Long. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.