EXOS System Events

Events

General system events are provided through Throw over IPML. Throw adhears to the publish-subscribe model for generating events. As events are created by the owning module, Throw will keep track of subscriptions and publish the event to each subscriber.

Currently, throw supports some events from these modules:

  • fdb
  • vlan
  • otm

Event ID

The event ID follows a heirachy. At the root of that is the “exos” ID. Its a special case, as subscribing to “exos” will provide events for everything supported by throw.

Otherwise, events are broken down by module name and operation, ex. “vlan”. The module names are listed above. The operation part is based on CRUD operation names; create, read, update, and delete. If two events have the same Event ID, it will likely contain a differentiator in the event data.

Subscribing for Events

Subscribing for an event requires two steps. First create a Subscription object with the event ID:

import exos.api.throwapi as throwapi
ev = throwapi.Subscribtion("vlan")

Then activate the subscription and provide a callback to receive the event’s data:

ev.sub(event_cb)

The callback will be called with two arguments, one is the event data and the other is the subscription that matched the event. This allows you to handle multiple events in one callback if you so choose.

So our example will look like:

import exos.api.throwapi as throwapi

def event_cb(event,subs):
    print "Event happened!"
ev = throwapi.Subscribtion("vlan")
ev.sub(event_cb)

Unsubscribing for Events

To unsubscribe, call the unsub method on the Subscription object that corresponds to the Event ID you no longer want to subscribe to:

ev.unsub()