Search in sources :

Example 11 with OvsdbRowStore

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

the class DefaultOvsdbClient method getMirrorUuid.

@Override
public String getMirrorUuid(String mirrorName) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, MIRROR);
    if (rowStore == null) {
        log.warn("The mirror uuid is null");
        return null;
    }
    ConcurrentMap<String, Row> mirrorTableRows = rowStore.getRowStore();
    if (mirrorTableRows == null) {
        log.warn("The mirror uuid is null");
        return null;
    }
    for (String uuid : mirrorTableRows.keySet()) {
        Mirror mirror = (Mirror) TableGenerator.getTable(dbSchema, mirrorTableRows.get(uuid), OvsdbTable.MIRROR);
        String name = mirror.getName();
        if (name.contains(mirrorName)) {
            return uuid;
        }
    }
    log.warn("Mirroring not found");
    return null;
}
Also used : Row(org.onosproject.ovsdb.rfc.notation.Row) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Mirror(org.onosproject.ovsdb.rfc.table.Mirror) OvsdbMirror(org.onosproject.ovsdb.controller.OvsdbMirror) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 12 with OvsdbRowStore

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

the class DefaultOvsdbClient method getControllers.

private List<Controller> getControllers(Uuid bridgeUuid) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    if (dbSchema == null) {
        return null;
    }
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
    if (rowStore == null) {
        log.debug("There is no bridge table");
        return null;
    }
    Row bridgeRow = rowStore.getRow(bridgeUuid.value());
    Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
    // FIXME remove log
    log.warn("type of controller column", bridge.getControllerColumn().data().getClass());
    Set<Uuid> controllerUuids = (Set<Uuid>) ((OvsdbSet) bridge.getControllerColumn().data()).set();
    OvsdbRowStore controllerRowStore = getRowStore(DATABASENAME, CONTROLLER);
    if (controllerRowStore == null) {
        log.debug("There is no controller table");
        return null;
    }
    List<Controller> ovsdbControllers = new ArrayList<>();
    ConcurrentMap<String, Row> controllerTableRows = controllerRowStore.getRowStore();
    controllerTableRows.forEach((key, row) -> {
        if (!controllerUuids.contains(Uuid.uuid(key))) {
            return;
        }
        Controller controller = (Controller) TableGenerator.getTable(dbSchema, row, OvsdbTable.CONTROLLER);
        ovsdbControllers.add(controller);
    });
    return ovsdbControllers;
}
Also used : Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) ArrayList(java.util.ArrayList) Row(org.onosproject.ovsdb.rfc.notation.Row) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Controller(org.onosproject.ovsdb.rfc.table.Controller) Bridge(org.onosproject.ovsdb.rfc.table.Bridge) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 13 with OvsdbRowStore

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

the class DefaultOvsdbClient method getOvsUuid.

private String getOvsUuid(String dbName) {
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, DATABASENAME);
    if (rowStore == null) {
        log.debug("The bridge uuid is null");
        return null;
    }
    ConcurrentMap<String, Row> ovsTableRows = rowStore.getRowStore();
    if (ovsTableRows != null) {
        for (String uuid : ovsTableRows.keySet()) {
            Row row = ovsTableRows.get(uuid);
            String tableName = row.tableName();
            if (tableName.equals(dbName)) {
                return uuid;
            }
        }
    }
    return null;
}
Also used : Row(org.onosproject.ovsdb.rfc.notation.Row) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore)

Example 14 with OvsdbRowStore

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

the class DefaultOvsdbClient method getMirrorings.

/**
 * Helper method which retrieves mirrorings statistics using bridge uuid.
 *
 * @param bridgeUuid the uuid of the bridge
 * @return the list of the mirrorings statistics.
 */
private List<MirroringStatistics> getMirrorings(Uuid bridgeUuid) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    if (dbSchema == null) {
        log.warn("Unable to retrieve dbSchema {}", DATABASENAME);
        return null;
    }
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
    if (rowStore == null) {
        log.warn("Unable to retrieve rowStore {} of {}", BRIDGE, DATABASENAME);
        return null;
    }
    Row bridgeRow = rowStore.getRow(bridgeUuid.value());
    Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
    Set<Uuid> mirroringsUuids = (Set<Uuid>) ((OvsdbSet) bridge.getMirrorsColumn().data()).set();
    OvsdbRowStore mirrorRowStore = getRowStore(DATABASENAME, MIRROR);
    if (mirrorRowStore == null) {
        log.warn("Unable to retrieve rowStore {} of {}", MIRROR, DATABASENAME);
        return null;
    }
    List<MirroringStatistics> mirroringStatistics = new ArrayList<>();
    ConcurrentMap<String, Row> mirrorTableRows = mirrorRowStore.getRowStore();
    mirrorTableRows.forEach((key, row) -> {
        if (!mirroringsUuids.contains(Uuid.uuid(key))) {
            return;
        }
        Mirror mirror = (Mirror) TableGenerator.getTable(dbSchema, row, OvsdbTable.MIRROR);
        mirroringStatistics.add(MirroringStatistics.mirroringStatistics(mirror.getName(), (Map<String, Integer>) ((OvsdbMap) mirror.getStatisticsColumn().data()).map()));
    });
    return ImmutableList.copyOf(mirroringStatistics);
}
Also used : Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashSet(java.util.HashSet) OvsdbSet(org.onosproject.ovsdb.rfc.notation.OvsdbSet) ArrayList(java.util.ArrayList) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) Row(org.onosproject.ovsdb.rfc.notation.Row) MirroringStatistics(org.onosproject.net.behaviour.MirroringStatistics) Mirror(org.onosproject.ovsdb.rfc.table.Mirror) OvsdbMirror(org.onosproject.ovsdb.controller.OvsdbMirror) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) Bridge(org.onosproject.ovsdb.rfc.table.Bridge) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 15 with OvsdbRowStore

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

the class DefaultOvsdbClient method createQueue.

@Override
public boolean createQueue(OvsdbQueue ovsdbQueue) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    Queue queue = (Queue) TableGenerator.createTable(dbSchema, OvsdbTable.QUEUE);
    ArrayList<Operation> operations = Lists.newArrayList();
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, QUEUE);
    if (rowStore == null) {
        log.debug("The queue uuid is null");
        return false;
    }
    if (ovsdbQueue.dscp().isPresent()) {
        queue.setDscp(ImmutableSet.of(ovsdbQueue.dscp().get()));
    }
    queue.setOtherConfig(ovsdbQueue.otherConfigs());
    queue.setExternalIds(ovsdbQueue.externalIds());
    Insert queueInsert = new Insert(dbSchema.getTableSchema(QUEUE), QUEUE, queue.getRow());
    operations.add(queueInsert);
    try {
        transactConfig(DATABASENAME, operations).get();
    } catch (InterruptedException | ExecutionException e) {
        log.error("createQueue transactConfig get exception !");
    }
    return true;
}
Also used : Operation(org.onosproject.ovsdb.rfc.operations.Operation) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Insert(org.onosproject.ovsdb.rfc.operations.Insert) ExecutionException(java.util.concurrent.ExecutionException) OvsdbQueue(org.onosproject.ovsdb.controller.OvsdbQueue) Queue(org.onosproject.ovsdb.rfc.table.Queue) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Aggregations

OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)26 Row (org.onosproject.ovsdb.rfc.notation.Row)21 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)16 Uuid (org.onosproject.ovsdb.rfc.notation.Uuid)12 OvsdbMap (org.onosproject.ovsdb.rfc.notation.OvsdbMap)11 OvsdbTableStore (org.onosproject.ovsdb.controller.OvsdbTableStore)10 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 OvsdbBridge (org.onosproject.ovsdb.controller.OvsdbBridge)8 Operation (org.onosproject.ovsdb.rfc.operations.Operation)8 Map (java.util.Map)7 ConcurrentMap (java.util.concurrent.ConcurrentMap)7 Bridge (org.onosproject.ovsdb.rfc.table.Bridge)7 Condition (org.onosproject.ovsdb.rfc.notation.Condition)6 Mutation (org.onosproject.ovsdb.rfc.notation.Mutation)6 OvsdbSet (org.onosproject.ovsdb.rfc.notation.OvsdbSet)6 Mutate (org.onosproject.ovsdb.rfc.operations.Mutate)6 ImmutableSet (com.google.common.collect.ImmutableSet)5 ArrayList (java.util.ArrayList)5 Set (java.util.Set)5