use of org.onosproject.ovsdb.rfc.schema.TableSchema in project onos by opennetworkinglab.
the class AbstractOvsdbTableService method toString.
@Override
public String toString() {
TableSchema schema = getTableSchema();
String tableName = schema.name();
return toStringHelper(this).add("tableName", tableName).add("row", row).toString();
}
use of org.onosproject.ovsdb.rfc.schema.TableSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method updateConfig.
/**
* Update transact config.
*
* @param tableName table name
* @param columnName column name
* @param uuid uuid
* @param row the config data
*/
private void updateConfig(String tableName, String columnName, String uuid, Row row) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
TableSchema tableSchema = dbSchema.getTableSchema(tableName);
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.isEqual(columnName, Uuid.uuid(uuid));
conditions.add(condition);
Update update = new Update(tableSchema, row, conditions);
ArrayList<Operation> operations = Lists.newArrayList();
operations.add(update);
transactConfig(DATABASENAME, operations);
}
use of org.onosproject.ovsdb.rfc.schema.TableSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method unbindQueues.
@SuppressWarnings("unchecked")
@Override
public void unbindQueues(QosId qosId, List<Long> queueKeys) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
OvsdbRowStore qosRowStore = getRowStore(DATABASENAME, QOS);
if (qosRowStore == null) {
return;
}
ConcurrentMap<String, Row> qosTableRows = qosRowStore.getRowStore();
Row qosRow = qosTableRows.values().stream().filter(r -> {
OvsdbMap ovsdbMap = (OvsdbMap) (r.getColumn(EXTERNAL_ID).data());
return qosId.name().equals(ovsdbMap.map().get(QOS_EXTERNAL_ID_KEY));
}).findFirst().orElse(null);
if (qosRow == null) {
log.warn("Can't find QoS {}", qosId);
return;
}
Map<Long, Uuid> deleteQueuesMap;
Map<Integer, Uuid> queuesMap = ((OvsdbMap) qosRow.getColumn(QUEUES).data()).map();
deleteQueuesMap = queueKeys.stream().filter(key -> queuesMap.containsKey(key.intValue())).collect(Collectors.toMap(key -> key, key -> queuesMap.get(key.intValue()), (a, b) -> b));
if (deleteQueuesMap.size() != 0) {
TableSchema parentTableSchema = dbSchema.getTableSchema(QOS);
ColumnSchema parentColumnSchema = parentTableSchema.getColumnSchema(QUEUES);
Mutation mutation = MutationUtil.delete(parentColumnSchema.name(), OvsdbMap.ovsdbMap(deleteQueuesMap));
List<Mutation> mutations = Collections.singletonList(mutation);
Condition condition = ConditionUtil.isEqual(UUID, qosRow.uuid());
List<Condition> conditionList = Collections.singletonList(condition);
List<Operation> operations = Collections.singletonList(new Mutate(parentTableSchema, conditionList, mutations));
transactConfig(DATABASENAME, operations);
}
}
use of org.onosproject.ovsdb.rfc.schema.TableSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method deleteConfig.
/**
* Delete transact config.
*
* @param childTableName child table name
* @param childColumnName child column name
* @param childUuid child row uuid
* @param parentTableName parent table name
* @param parentColumnName parent column
* @param referencedValue referenced value
*/
private void deleteConfig(String childTableName, String childColumnName, String childUuid, String parentTableName, String parentColumnName, Object referencedValue) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
TableSchema childTableSchema = dbSchema.getTableSchema(childTableName);
ArrayList<Operation> operations = Lists.newArrayList();
if (parentTableName != null && parentColumnName != null && referencedValue != null) {
TableSchema parentTableSchema = dbSchema.getTableSchema(parentTableName);
ColumnSchema parentColumnSchema = parentTableSchema.getColumnSchema(parentColumnName);
List<Mutation> mutations = Lists.newArrayList();
Mutation mutation = MutationUtil.delete(parentColumnSchema.name(), referencedValue);
mutations.add(mutation);
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.includes(parentColumnName, referencedValue);
conditions.add(condition);
Mutate op = new Mutate(parentTableSchema, conditions, mutations);
operations.add(op);
}
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.isEqual(childColumnName, Uuid.uuid(childUuid));
conditions.add(condition);
Delete del = new Delete(childTableSchema, conditions);
operations.add(del);
transactConfig(DATABASENAME, operations);
}
Aggregations