Search in sources :

Example 1 with OvsdbPortNumber

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

the class DefaultOvsdbClient method getOvsdbPort.

private OvsdbPort getOvsdbPort(Row row) {
    DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
    Interface intf = (Interface) TableGenerator.getTable(dbSchema, row, OvsdbTable.INTERFACE);
    if (intf == null) {
        return null;
    }
    long ofPort = getOfPort(intf);
    String portName = intf.getName();
    if ((ofPort < 0) || (portName == null)) {
        return null;
    }
    return new OvsdbPort(new OvsdbPortNumber(ofPort), new OvsdbPortName(portName));
}
Also used : OvsdbPortNumber(org.onosproject.ovsdb.controller.OvsdbPortNumber) OvsdbPortName(org.onosproject.ovsdb.controller.OvsdbPortName) Interface(org.onosproject.ovsdb.rfc.table.Interface) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 2 with OvsdbPortNumber

use of org.onosproject.ovsdb.controller.OvsdbPortNumber 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)

Example 3 with OvsdbPortNumber

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

the class OvsdbHostProviderTest method portRemoved.

@Test
public void portRemoved() {
    DefaultEventSubject eventSubject = new DefaultEventSubject(MAC, null, new OvsdbPortName("portName"), new OvsdbPortNumber(0L), new OvsdbDatapathId("10002"), new OvsdbPortType("vxlan"), new OvsdbIfaceId("102345"));
    controller.ovsdbEventListener.handle(new OvsdbEvent<EventSubject>(OvsdbEvent.Type.PORT_REMOVED, eventSubject));
    assertEquals("port status unhandled", 1, providerService.removeCount);
}
Also used : DefaultEventSubject(org.onosproject.ovsdb.controller.DefaultEventSubject) OvsdbPortType(org.onosproject.ovsdb.controller.OvsdbPortType) OvsdbIfaceId(org.onosproject.ovsdb.controller.OvsdbIfaceId) OvsdbPortName(org.onosproject.ovsdb.controller.OvsdbPortName) OvsdbPortNumber(org.onosproject.ovsdb.controller.OvsdbPortNumber) OvsdbDatapathId(org.onosproject.ovsdb.controller.OvsdbDatapathId) DefaultEventSubject(org.onosproject.ovsdb.controller.DefaultEventSubject) EventSubject(org.onosproject.ovsdb.controller.EventSubject) Test(org.junit.Test)

Example 4 with OvsdbPortNumber

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

the class OvsdbHostProviderTest method portAdded.

@Test
public void portAdded() {
    DefaultEventSubject eventSubject = new DefaultEventSubject(MAC, null, new OvsdbPortName("portName"), new OvsdbPortNumber(0L), new OvsdbDatapathId("10002"), new OvsdbPortType("vxlan"), new OvsdbIfaceId("102345"));
    controller.ovsdbEventListener.handle(new OvsdbEvent<EventSubject>(OvsdbEvent.Type.PORT_ADDED, eventSubject));
    assertNotNull("never went throught the provider service", providerService.added);
}
Also used : DefaultEventSubject(org.onosproject.ovsdb.controller.DefaultEventSubject) OvsdbPortType(org.onosproject.ovsdb.controller.OvsdbPortType) OvsdbIfaceId(org.onosproject.ovsdb.controller.OvsdbIfaceId) OvsdbPortName(org.onosproject.ovsdb.controller.OvsdbPortName) OvsdbPortNumber(org.onosproject.ovsdb.controller.OvsdbPortNumber) OvsdbDatapathId(org.onosproject.ovsdb.controller.OvsdbDatapathId) DefaultEventSubject(org.onosproject.ovsdb.controller.DefaultEventSubject) EventSubject(org.onosproject.ovsdb.controller.EventSubject) Test(org.junit.Test)

Example 5 with OvsdbPortNumber

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

the class DefaultOvsdbClient method getLocalPorts.

@Override
public Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids) {
    Set<OvsdbPort> ovsdbPorts = new HashSet<>();
    OvsdbTableStore tableStore = getTableStore(DATABASENAME);
    if (tableStore == null) {
        return null;
    }
    OvsdbRowStore rowStore = tableStore.getRows(INTERFACE);
    if (rowStore == null) {
        return null;
    }
    ConcurrentMap<String, Row> rows = rowStore.getRowStore();
    for (String uuid : rows.keySet()) {
        Row row = getRow(DATABASENAME, INTERFACE, uuid);
        DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
        Interface intf = (Interface) TableGenerator.getTable(dbSchema, row, OvsdbTable.INTERFACE);
        if (intf == null || getIfaceid(intf) == null) {
            continue;
        }
        String portName = intf.getName();
        if (portName == null) {
            continue;
        }
        Set<String> ifaceidSet = Sets.newHashSet(ifaceids);
        if (portName.startsWith(TYPEVXLAN) || !ifaceidSet.contains(getIfaceid(intf))) {
            continue;
        }
        long ofPort = getOfPort(intf);
        if (ofPort < 0) {
            continue;
        }
        ovsdbPorts.add(new OvsdbPort(new OvsdbPortNumber(ofPort), new OvsdbPortName(portName)));
    }
    return ovsdbPorts;
}
Also used : OvsdbTableStore(org.onosproject.ovsdb.controller.OvsdbTableStore) OvsdbPortNumber(org.onosproject.ovsdb.controller.OvsdbPortNumber) OvsdbPortName(org.onosproject.ovsdb.controller.OvsdbPortName) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) Row(org.onosproject.ovsdb.rfc.notation.Row) Interface(org.onosproject.ovsdb.rfc.table.Interface) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface) HashSet(java.util.HashSet) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Aggregations

OvsdbPortName (org.onosproject.ovsdb.controller.OvsdbPortName)5 OvsdbPortNumber (org.onosproject.ovsdb.controller.OvsdbPortNumber)5 DefaultEventSubject (org.onosproject.ovsdb.controller.DefaultEventSubject)3 EventSubject (org.onosproject.ovsdb.controller.EventSubject)3 OvsdbDatapathId (org.onosproject.ovsdb.controller.OvsdbDatapathId)3 OvsdbIfaceId (org.onosproject.ovsdb.controller.OvsdbIfaceId)3 OvsdbPortType (org.onosproject.ovsdb.controller.OvsdbPortType)3 Interface (org.onosproject.ovsdb.rfc.table.Interface)3 Test (org.junit.Test)2 OvsdbInterface (org.onosproject.ovsdb.controller.OvsdbInterface)2 OvsdbPort (org.onosproject.ovsdb.controller.OvsdbPort)2 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)2 HashSet (java.util.HashSet)1 OvsdbEventListener (org.onosproject.ovsdb.controller.OvsdbEventListener)1 OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)1 OvsdbTableStore (org.onosproject.ovsdb.controller.OvsdbTableStore)1 Row (org.onosproject.ovsdb.rfc.notation.Row)1