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());
}
}
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);
}
}
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);
}
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);
}
}
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);
}
Aggregations