Search in sources :

Example 1 with Qos

use of org.onosproject.ovsdb.rfc.table.Qos in project onos by opennetworkinglab.

the class DefaultOvsdbClient method createQos.

@Override
public boolean createQos(OvsdbQos ovsdbQos) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    Qos qos = (Qos) TableGenerator.createTable(dbSchema, OvsdbTable.QOS);
    OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
    if (rowStore == null) {
        log.debug("The qos uuid is null");
        return false;
    }
    ArrayList<Operation> operations = Lists.newArrayList();
    Set<String> types = Sets.newHashSet();
    Map<Long, Uuid> queues = Maps.newHashMap();
    types.add(ovsdbQos.qosType());
    qos.setOtherConfig(ovsdbQos.otherConfigs());
    qos.setExternalIds(ovsdbQos.externalIds());
    qos.setType(types);
    if (ovsdbQos.qosQueues().isPresent()) {
        for (Map.Entry<Long, String> entry : ovsdbQos.qosQueues().get().entrySet()) {
            OvsdbRowStore queueRowStore = getRowStore(DATABASENAME, QUEUE);
            if (queueRowStore != null) {
                ConcurrentMap<String, Row> queueTableRows = queueRowStore.getRowStore();
                Row queueRow = queueTableRows.values().stream().filter(r -> {
                    OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
                    return entry.getValue().equals(ovsdbMap.map().get(QUEUE_EXTERNAL_ID_KEY));
                }).findFirst().orElse(null);
                if (queueRow != null) {
                    queues.put(entry.getKey(), queueRow.uuid());
                }
            }
        }
        qos.setQueues(queues);
    }
    Insert qosInsert = new Insert(dbSchema.getTableSchema(QOS), QOS, qos.getRow());
    operations.add(qosInsert);
    try {
        transactConfig(DATABASENAME, operations).get();
    } catch (InterruptedException | ExecutionException e) {
        return false;
    }
    return true;
}
Also used : Operation(org.onosproject.ovsdb.rfc.operations.Operation) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) Insert(org.onosproject.ovsdb.rfc.operations.Insert) Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) Qos(org.onosproject.ovsdb.rfc.table.Qos) OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) Row(org.onosproject.ovsdb.rfc.notation.Row) ExecutionException(java.util.concurrent.ExecutionException) Map(java.util.Map) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 2 with Qos

use of org.onosproject.ovsdb.rfc.table.Qos in project onos by opennetworkinglab.

the class DefaultOvsdbClient method getOvsdbQos.

private OvsdbQos getOvsdbQos(Row row) {
    DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
    Qos qos = (Qos) TableGenerator.getTable(dbSchema, row, OvsdbTable.QOS);
    if (qos == null) {
        return null;
    }
    String type = (String) qos.getTypeColumn().data();
    Map<String, String> otherConfigs;
    Map<String, String> externalIds;
    Map<Long, String> queues;
    otherConfigs = ((OvsdbMap) qos.getOtherConfigColumn().data()).map();
    externalIds = ((OvsdbMap) qos.getExternalIdsColumn().data()).map();
    queues = ((OvsdbMap) qos.getQueuesColumn().data()).map();
    return OvsdbQos.builder().qosType(type).queues(queues).otherConfigs(otherConfigs).externalIds(externalIds).build();
}
Also used : Qos(org.onosproject.ovsdb.rfc.table.Qos) OvsdbQos(org.onosproject.ovsdb.controller.OvsdbQos) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Aggregations

OvsdbQos (org.onosproject.ovsdb.controller.OvsdbQos)2 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)2 Qos (org.onosproject.ovsdb.rfc.table.Qos)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ExecutionException (java.util.concurrent.ExecutionException)1 OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)1 OvsdbMap (org.onosproject.ovsdb.rfc.notation.OvsdbMap)1 Row (org.onosproject.ovsdb.rfc.notation.Row)1 Uuid (org.onosproject.ovsdb.rfc.notation.Uuid)1 Insert (org.onosproject.ovsdb.rfc.operations.Insert)1 Operation (org.onosproject.ovsdb.rfc.operations.Operation)1