use of org.onosproject.ovsdb.controller.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method dropInterface.
@Override
public boolean dropInterface(String ifaceName) {
OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
if (rowStore == null) {
log.warn("Failed to get BRIDGE table");
return false;
}
ConcurrentMap<String, Row> bridgeTableRows = rowStore.getRowStore();
if (bridgeTableRows == null) {
log.warn("Failed to get BRIDGE table rows");
return false;
}
// interface name is unique
Optional<String> bridgeId = bridgeTableRows.keySet().stream().filter(uuid -> getPortUuid(ifaceName, uuid) != null).findFirst();
if (bridgeId.isPresent()) {
String portId = getPortUuid(ifaceName, bridgeId.get());
deleteConfig(PORT, UUID, portId, BRIDGE, PORTS, Uuid.uuid(portId));
return true;
} else {
log.warn("Unable to find the interface with name {}", ifaceName);
return false;
}
}
use of org.onosproject.ovsdb.controller.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getQoses.
@Override
public Set<OvsdbQos> getQoses() {
Set<OvsdbQos> ovsdbQoses = new HashSet<>();
OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
if (rowStore == null) {
log.debug("The qos uuid is null");
return ovsdbQoses;
}
ConcurrentMap<String, Row> rows = rowStore.getRowStore();
ovsdbQoses = rows.keySet().stream().map(uuid -> getRow(DATABASENAME, QOS, uuid)).map(this::getOvsdbQos).filter(Objects::nonNull).collect(Collectors.toSet());
return ovsdbQoses;
}
use of org.onosproject.ovsdb.controller.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method dropQos.
@Override
public void dropQos(QosId qosId) {
OvsdbRowStore rowStore = getRowStore(DATABASENAME, QOS);
if (rowStore != null) {
ConcurrentMap<String, Row> qosTableRows = rowStore.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) {
deleteConfig(QOS, UUID, qosRow.uuid().value(), PORT, PORT_QOS, qosRow.uuid());
}
}
}
use of org.onosproject.ovsdb.controller.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getLocalPorts.
@Override
public Set<OvsdbPort> getLocalPorts(Iterable<String> ifaceids) {
Set<OvsdbPort> ovsdbPorts = new HashSet<>();
OvsdbTableStore tableStore = getTableStore(DATABASENAME);
if (tableStore == null) {
return null;
}
OvsdbRowStore rowStore = tableStore.getRows(INTERFACE);
if (rowStore == null) {
return null;
}
ConcurrentMap<String, Row> rows = rowStore.getRowStore();
for (String uuid : rows.keySet()) {
Row row = getRow(DATABASENAME, INTERFACE, uuid);
DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
Interface intf = (Interface) TableGenerator.getTable(dbSchema, row, OvsdbTable.INTERFACE);
if (intf == null || getIfaceid(intf) == null) {
continue;
}
String portName = intf.getName();
if (portName == null) {
continue;
}
Set<String> ifaceidSet = Sets.newHashSet(ifaceids);
if (portName.startsWith(TYPEVXLAN) || !ifaceidSet.contains(getIfaceid(intf))) {
continue;
}
long ofPort = getOfPort(intf);
if (ofPort < 0) {
continue;
}
ovsdbPorts.add(new OvsdbPort(new OvsdbPortNumber(ofPort), new OvsdbPortName(portName)));
}
return ovsdbPorts;
}
use of org.onosproject.ovsdb.controller.OvsdbRowStore in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getFirstRow.
@Override
public Optional<Object> getFirstRow(String dbName, OvsdbTable tblName) {
DatabaseSchema dbSchema = getDatabaseSchema(dbName);
if (Objects.isNull(dbSchema)) {
return Optional.empty();
}
OvsdbTableStore tableStore = ovsdbStore.getOvsdbTableStore(dbName);
if (tableStore == null) {
return Optional.empty();
}
OvsdbRowStore rowStore = tableStore.getRows(tblName.tableName());
if (rowStore == null) {
return Optional.empty();
}
ConcurrentMap<String, Row> rows = rowStore.getRowStore();
if (rows == null) {
log.debug("The {} Table Rows is null", tblName);
return Optional.empty();
}
// There should be only 1 row in this table
Optional<String> uuid = rows.keySet().stream().findFirst();
if (uuid.isPresent() && rows.containsKey(uuid.get())) {
return Optional.of(TableGenerator.getTable(dbSchema, rows.get(uuid.get()), tblName));
} else {
return Optional.empty();
}
}
Aggregations