Search in sources :

Example 1 with OvsdbEventListener

use of org.onosproject.ovsdb.controller.OvsdbEventListener in project onos by opennetworkinglab.

the class OvsdbControllerImpl method dispatchInterfaceEvent.

/**
 * Dispatches event to the north.
 *
 * @param clientService OvsdbClientService instance
 * @param row           a new row
 * @param eventType     type of event
 * @param dbSchema      ovsdb database schema
 */
private void dispatchInterfaceEvent(OvsdbClientService clientService, Row row, Type eventType, DatabaseSchema dbSchema) {
    long dpid = getDataPathid(clientService, dbSchema);
    Interface intf = (Interface) TableGenerator.getTable(dbSchema, row, OvsdbTable.INTERFACE);
    if (intf == null) {
        return;
    }
    String portType = (String) intf.getTypeColumn().data();
    long localPort = getOfPort(intf);
    if (localPort < 0) {
        return;
    }
    String[] macAndIfaceId = getMacAndIfaceid(intf);
    if (macAndIfaceId == null) {
        return;
    }
    EventSubject eventSubject = new DefaultEventSubject(MacAddress.valueOf(macAndIfaceId[0]), new HashSet<>(), new OvsdbPortName(intf.getName()), new OvsdbPortNumber(localPort), new OvsdbDatapathId(Long.toString(dpid)), new OvsdbPortType(portType), new OvsdbIfaceId(macAndIfaceId[1]));
    for (OvsdbEventListener listener : ovsdbEventListener) {
        listener.handle(new OvsdbEvent<>(eventType, eventSubject));
    }
}
Also used : DefaultEventSubject(org.onosproject.ovsdb.controller.DefaultEventSubject) OvsdbPortName(org.onosproject.ovsdb.controller.OvsdbPortName) OvsdbPortNumber(org.onosproject.ovsdb.controller.OvsdbPortNumber) DefaultEventSubject(org.onosproject.ovsdb.controller.DefaultEventSubject) EventSubject(org.onosproject.ovsdb.controller.EventSubject) OvsdbDatapathId(org.onosproject.ovsdb.controller.OvsdbDatapathId) OvsdbEventListener(org.onosproject.ovsdb.controller.OvsdbEventListener) OvsdbPortType(org.onosproject.ovsdb.controller.OvsdbPortType) OvsdbIfaceId(org.onosproject.ovsdb.controller.OvsdbIfaceId) Interface(org.onosproject.ovsdb.rfc.table.Interface)

Aggregations

DefaultEventSubject (org.onosproject.ovsdb.controller.DefaultEventSubject)1 EventSubject (org.onosproject.ovsdb.controller.EventSubject)1 OvsdbDatapathId (org.onosproject.ovsdb.controller.OvsdbDatapathId)1 OvsdbEventListener (org.onosproject.ovsdb.controller.OvsdbEventListener)1 OvsdbIfaceId (org.onosproject.ovsdb.controller.OvsdbIfaceId)1 OvsdbPortName (org.onosproject.ovsdb.controller.OvsdbPortName)1 OvsdbPortNumber (org.onosproject.ovsdb.controller.OvsdbPortNumber)1 OvsdbPortType (org.onosproject.ovsdb.controller.OvsdbPortType)1 Interface (org.onosproject.ovsdb.rfc.table.Interface)1