use of org.onosproject.ovsdb.rfc.schema.ColumnSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method handlePortInsertTable.
/**
* Handles port insert.
*
* @param portRow row of port
* @return insert, empty if null
*/
private Insert handlePortInsertTable(Row portRow) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
TableSchema portTableSchema = dbSchema.getTableSchema(PORT);
ColumnSchema portColumnSchema = portTableSchema.getColumnSchema("name");
String portName = (String) portRow.getColumn(portColumnSchema.name()).data();
Interface inf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
inf.setName(portName);
TableSchema intfTableSchema = dbSchema.getTableSchema(INTERFACE);
return new Insert(intfTableSchema, INTERFACE, inf.getRow());
}
use of org.onosproject.ovsdb.rfc.schema.ColumnSchema in project onos by opennetworkinglab.
the class DefaultOvsdbClient method insertConfig.
/**
* Insert transact config.
*
* @param childTableName child table name
* @param childColumnName child column name
* @param parentTableName parent table name
* @param parentColumnName parent column
* @param parentUuid parent uuid
* @param row the config data
* @return uuid, empty if no uuid is find
*/
private String insertConfig(String childTableName, String childColumnName, String parentTableName, String parentColumnName, String parentUuid, Row row) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
TableSchema tableSchema = dbSchema.getTableSchema(childTableName);
Insert insert = new Insert(tableSchema, childTableName, row);
ArrayList<Operation> operations = Lists.newArrayList();
operations.add(insert);
if (parentTableName != null && parentColumnName != null) {
TableSchema parentTableSchema = dbSchema.getTableSchema(parentTableName);
ColumnSchema parentColumnSchema = parentTableSchema.getColumnSchema(parentColumnName);
List<Mutation> mutations = Lists.newArrayList();
Mutation mutation = MutationUtil.insert(parentColumnSchema.name(), Uuid.uuid(childTableName));
mutations.add(mutation);
List<Condition> conditions = Lists.newArrayList();
Condition condition = ConditionUtil.isEqual(UUID, Uuid.uuid(parentUuid));
conditions.add(condition);
Mutate op = new Mutate(parentTableSchema, conditions, mutations);
operations.add(op);
}
if (childTableName.equalsIgnoreCase(PORT)) {
log.debug("Handle port insert");
Insert intfInsert = handlePortInsertTable(row);
if (intfInsert != null) {
operations.add(intfInsert);
}
Insert ins = (Insert) operations.get(0);
ins.getRow().put("interfaces", Uuid.uuid(INTERFACE));
}
List<OperationResult> results;
try {
results = transactConfig(DATABASENAME, operations).get(TRANSACTCONFIG_TIMEOUT, TimeUnit.SECONDS);
return results.get(0).getUuid().value();
} catch (TimeoutException e) {
log.warn("TimeoutException thrown while to get result");
} catch (InterruptedException e) {
log.warn("Interrupted while waiting to get result");
Thread.currentThread().interrupt();
} catch (ExecutionException e) {
log.error("Exception thrown while to get result");
}
return null;
}
use of org.onosproject.ovsdb.rfc.schema.ColumnSchema 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.schema.ColumnSchema in project onos by opennetworkinglab.
the class AbstractOvsdbTableService method getColumnSchema.
/**
* Returns ColumnSchema from TableSchema by column name.
* @param columnName column name
* @return ColumnSchema
*/
private ColumnSchema getColumnSchema(String columnName) {
TableSchema tableSchema = getTableSchema();
if (tableSchema == null) {
String message = TableSchemaNotFoundException.createMessage(tableDesc.name(), dbSchema.name());
throw new TableSchemaNotFoundException(message);
}
ColumnSchema columnSchema = tableSchema.getColumnSchema(columnName);
if (columnSchema == null) {
String message = ColumnSchemaNotFoundException.createMessage(columnName, tableSchema.name());
throw new ColumnSchemaNotFoundException(message);
}
return columnSchema;
}
use of org.onosproject.ovsdb.rfc.schema.ColumnSchema in project onos by opennetworkinglab.
the class AbstractOvsdbTableService method getColumnHandler.
@Override
public Column getColumnHandler(ColumnDescription columnDesc) {
if (!isValid()) {
return null;
}
String columnName = columnDesc.name();
checkColumnSchemaVersion(columnDesc);
ColumnSchema columnSchema = getColumnSchema(columnName);
if (row == null) {
return null;
}
return row.getColumn(columnSchema.name());
}
Aggregations