StatusDaemon - base module for the CIToolkit status daemon
extras
use StatusDaemon;
my $obj = StatusDaemon->new_obj( node => 'admin-0',
command => 'UPDATE');
my $flat_obj = $obj->flatten_obj();
my $socket = StatusDaemon::connect( 'admin-0', 2009 );
This module provides the base storage class and common functions for the CIToolkit's status daemon. It is essentially a wrapper around a hash table with some extra functions for debugging and making socket connections to remote ports.
Look at the output of
status_daemon --help
for information on turning on debugging for this module.
The following methods are availble:
$obj = StatusDaemon->new_obj( ); $obj = StatusDaemon->new_obj( %args ); $obj = StatusDaemon->new_obj( command => 'QUERY' );
Creates the datastructure that is the base storage for the status daemon and will be passed between client and server. Basically a wrapper around a hash tabled blessed into the class.
$obj->command('QUERY');
$command = $obj->command();
Any method (other than those described here) will end up calling this method. The method name will be used as a key for the object hash. WIth no arguments, the value associated with that key will be returned. With on argument, the value associated with that key will be set to the argument.
This method is ``dangerous'' because the programmer can junk things up pretty easily if not carefull. Currently, there is no checking for typos, etc. so it is very easy to screw up... Have Fun!
$socket = StatusDaemon::connect( 'admin-0', 2009 );
First argument is the hostname and second is the port to connect to. Returns a socket if successful. Dies if unsuccessful. This may be caught in a eval block if you don't want you process to end on a failed connection.
$flat_obj = $obj->flatten_obj();
Returns a flattened form of the object, good for passing over a socket connection. Can be reconstitued by passing the flatten object to the restore_obj method below.
$obj = restore_obj( $flat_obj );
Returns a blessed object from the flattened objedt passed in, or undef if there is an error restoring the object.
status_daemon