Event subscription
The Perl API provides mechanisms for subscribing
to and acting upon events generated by
Domain Manager
s.The
VMware Smart Assurance
programming model delivers two different modes of client/server communication.
The most direct is where a client makes a request of the Domain Manager
which acts on the request and responds. A simple example of this is an object query or update. For example, the action of
obtaining the vendor of a particular device is one such query. In Perl, this query would be encoded in a manner similar to the following fragment.use InCharge::session; use InCharge::object; $session = InCharge::session->init( ); $device = "Router::gw1"; $obj = $session->object( $device ); $vendor = $obj->{Vendor}; print $vendor . "\n”;
The second mechanism provides asynchronous notifications through subscriptions and is used when the client program needs to listen for events generated by the
Domain Manager
in
response to other external events. One example would be a script that waits for the Vendor field of a particular router to change. In Perl, this could be coded in the following way.use InCharge::session; use InCharge::object; $session = InCharge::session->init( ); $observer = $session->observer( ); $device = "Router::gw1"; $session->propertySubscribe($device, "Vendor", 30 ); while ( 1 ) { @event = $observer->receiveEvent( ); print "Vendor $event[2]::$event[3] is now \ $event[5]\n”; }
The following sections provide an overview of mechanisms for creating and controlling a number of different types of subscriptions.