Search in sources :

Example 1 with Column

use of org.onosproject.ovsdb.rfc.notation.Column in project onos by opennetworkinglab.

the class DefaultOvsdbClient method applyQos.

@Override
public void applyQos(PortNumber portNumber, String qosName) {
    DatabaseSchema dbSchema = schema.get(DATABASENAME);
    OvsdbRowStore portRowStore = getRowStore(DATABASENAME, PORT);
    if (portRowStore == null) {
        log.debug("The port uuid is null");
        return;
    }
    OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
    if (qosRowStore == null) {
        log.debug("The qos uuid is null");
        return;
    }
    // Due to Qos Table doesn't have a unique identifier except uuid, unlike
    // Bridge or Port Table has a name column,in order to make the api more
    // general, put qos name in external_ids column of Qos Table if this qos
    // created by onos.
    ConcurrentMap<String, Row> qosTableRows = qosRowStore.getRowStore();
    ConcurrentMap<String, Row> portTableRows = portRowStore.getRowStore();
    Row qosRow = qosTableRows.values().stream().filter(r -> {
        OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
        return qosName.equals(ovsdbMap.map().get(QOS_EXTERNAL_ID_KEY));
    }).findFirst().orElse(null);
    Row portRow = portTableRows.values().stream().filter(r -> r.getColumn("name").data().equals(portNumber.name())).findFirst().orElse(null);
    if (portRow != null && qosRow != null) {
        String qosId = qosRow.uuid().value();
        Uuid portUuid = portRow.uuid();
        Map<String, Column> columns = new HashMap<>();
        Row newPortRow = new Row(PORT, portUuid, columns);
        Port newport = new Port(dbSchema, newPortRow);
        columns.put(Port.PortColumn.QOS.columnName(), newport.getQosColumn());
        newport.setQos(Uuid.uuid(qosId));
        updateConfig(PORT, UUID, portUuid.value(), newport.getRow());
    }
}
Also used : Uuid(org.onosproject.ovsdb.rfc.notation.Uuid) Column(org.onosproject.ovsdb.rfc.notation.Column) HashMap(java.util.HashMap) OvsdbPort(org.onosproject.ovsdb.controller.OvsdbPort) Port(org.onosproject.ovsdb.rfc.table.Port) OvsdbMap(org.onosproject.ovsdb.rfc.notation.OvsdbMap) Row(org.onosproject.ovsdb.rfc.notation.Row) OvsdbRowStore(org.onosproject.ovsdb.controller.OvsdbRowStore) DatabaseSchema(org.onosproject.ovsdb.rfc.schema.DatabaseSchema)

Example 2 with Column

use of org.onosproject.ovsdb.rfc.notation.Column in project onos by opennetworkinglab.

the class Insert method generateOperationRow.

/**
 * Row entity convert into the row format of insert operation. Refer to RFC
 * 7047 Section 5.2.
 * @param row Row entity
 */
private void generateOperationRow(Row row) {
    Collection<Column> columns = row.getColumns();
    for (Column column : columns) {
        String columnName = column.columnName();
        Object value = column.data();
        Object formatValue = TransValueUtil.getFormatData(value);
        this.row.put(columnName, formatValue);
    }
}
Also used : Column(org.onosproject.ovsdb.rfc.notation.Column)

Example 3 with Column

use of org.onosproject.ovsdb.rfc.notation.Column in project onos by opennetworkinglab.

the class AbstractOvsdbTableService method setDataHandler.

@Override
public void setDataHandler(ColumnDescription columnDesc, Object obj) {
    if (!isValid()) {
        return;
    }
    String columnName = columnDesc.name();
    checkColumnSchemaVersion(columnDesc);
    ColumnSchema columnSchema = getColumnSchema(columnName);
    Column column = new Column(columnSchema.name(), obj);
    row.addColumn(columnName, column);
}
Also used : Column(org.onosproject.ovsdb.rfc.notation.Column) ColumnSchema(org.onosproject.ovsdb.rfc.schema.ColumnSchema)

Example 4 with Column

use of org.onosproject.ovsdb.rfc.notation.Column in project onos by opennetworkinglab.

the class Update method generateOperationRow.

/**
 * Row entity convert into the row format of update operation. Refer to RFC
 * 7047 Section 5.2.
 * @param row Row entity
 */
private void generateOperationRow(Row row) {
    Collection<Column> columns = row.getColumns();
    for (Column column : columns) {
        String columnName = column.columnName();
        Object value = column.data();
        Object formatValue = TransValueUtil.getFormatData(value);
        this.row.put(columnName, formatValue);
    }
}
Also used : Column(org.onosproject.ovsdb.rfc.notation.Column)

Example 5 with Column

use of org.onosproject.ovsdb.rfc.notation.Column in project onos by opennetworkinglab.

the class FromJsonUtil method createRow.

/**
 * Convert Operation JsonNode into Row.
 * @param tableSchema TableSchema entity
 * @param rowNode JsonNode
 * @return Row
 */
private static Row createRow(TableSchema tableSchema, Uuid uuid, JsonNode rowNode) {
    if (tableSchema == null) {
        return null;
    }
    Map<String, Column> columns = Maps.newHashMap();
    Iterator<Map.Entry<String, JsonNode>> rowIter = rowNode.fields();
    while (rowIter.hasNext()) {
        Map.Entry<String, JsonNode> next = rowIter.next();
        ColumnSchema columnSchema = tableSchema.getColumnSchema(next.getKey());
        if (columnSchema != null) {
            String columnName = columnSchema.name();
            Object obj = TransValueUtil.getValueFromJson(next.getValue(), columnSchema.type());
            columns.put(columnName, new Column(columnName, obj));
        }
    }
    return new Row(tableSchema.name(), uuid, columns);
}
Also used : Column(org.onosproject.ovsdb.rfc.notation.Column) JsonNode(com.fasterxml.jackson.databind.JsonNode) ColumnSchema(org.onosproject.ovsdb.rfc.schema.ColumnSchema) Row(org.onosproject.ovsdb.rfc.notation.Row) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

Column (org.onosproject.ovsdb.rfc.notation.Column)5 HashMap (java.util.HashMap)2 Row (org.onosproject.ovsdb.rfc.notation.Row)2 ColumnSchema (org.onosproject.ovsdb.rfc.schema.ColumnSchema)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Map (java.util.Map)1 OvsdbPort (org.onosproject.ovsdb.controller.OvsdbPort)1 OvsdbRowStore (org.onosproject.ovsdb.controller.OvsdbRowStore)1 OvsdbMap (org.onosproject.ovsdb.rfc.notation.OvsdbMap)1 Uuid (org.onosproject.ovsdb.rfc.notation.Uuid)1 DatabaseSchema (org.onosproject.ovsdb.rfc.schema.DatabaseSchema)1 Port (org.onosproject.ovsdb.rfc.table.Port)1