use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class DefaultOpenstackNodeHandler method isDpdkIntfsCreated.
private boolean isDpdkIntfsCreated(OpenstackNode osNode, Collection<DpdkInterface> dpdkInterfaces) {
OvsdbClientService client = getOvsdbClient(osNode, ovsdbPortNum, ovsdbController);
if (client == null) {
log.info("Failed to get ovsdb client");
return false;
}
Set<OvsdbPort> ports = client.getPorts();
for (DpdkInterface dpdkIntf : dpdkInterfaces) {
Optional<OvsdbPort> port = ports.stream().filter(ovsdbPort -> ovsdbPort.portName().value().equals(dpdkIntf.intf())).findAny();
if (!port.isPresent()) {
return false;
}
Interface intf = client.getInterface(dpdkIntf.intf());
if (intf == null) {
return false;
}
OvsdbSet mtu = (OvsdbSet) intf.getMtuColumn().data();
if (mtu == null) {
return false;
}
OvsdbMap option = (OvsdbMap) intf.getOptionsColumn().data();
if (option == null) {
return false;
}
if (!mtu.set().contains(dpdkIntf.mtu().intValue()) || !option.toString().contains(dpdkIntf.pciAddress())) {
log.trace("The dpdk interface {} was created but mtu or " + "pci address is different from the config.");
return false;
}
}
return true;
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getPortError.
@Override
public boolean getPortError(List<OvsdbPortName> portNames, DeviceId bridgeId) {
Uuid bridgeUuid = getBridgeUuid(bridgeId);
List<Interface> interfaceList = portNames.stream().collect(Collectors.toMap(java.util.function.Function.identity(), port -> (Interface) getInterfacebyPort(getPortUuid(port.value(), bridgeUuid.value()), port.value()))).entrySet().stream().filter(intf -> Objects.nonNull(intf.getValue()) && ((OvsdbSet) intf.getValue().getOpenFlowPortColumn().data()).set().stream().findAny().orElse(OFPORT_ERROR_COMPARISON).equals(OFPORT_ERROR)).map(Map.Entry::getValue).collect(Collectors.toList());
interfaceList.forEach(intf -> ((Consumer<Interface>) intf1 -> {
try {
Set<String> setErrors = ((OvsdbSet) intf1.getErrorColumn().data()).set();
log.info("Port has errors. ofport value - {}, Interface - {} has error - {} ", intf1.getOpenFlowPortColumn().data(), intf1.getName(), setErrors.stream().findFirst().get());
} catch (ColumnSchemaNotFoundException | VersionMismatchException e) {
log.debug("Port has errors. ofport value - {}, Interface - {} has error - {} ", intf1.getOpenFlowPortColumn().data(), intf1.getName(), e);
}
}).accept(intf));
return !interfaceList.isEmpty();
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getOvsdbQueue.
private OvsdbQueue getOvsdbQueue(Row row) {
DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
Queue queue = (Queue) TableGenerator.getTable(dbSchema, row, OvsdbTable.QUEUE);
if (queue == null) {
return null;
}
OvsdbSet dscpOvsdbSet = ((OvsdbSet) queue.getDscpColumn().data());
Set dscpSet = dscpOvsdbSet.set();
Long dscp = null;
if (dscpSet != null && !dscpSet.isEmpty()) {
dscp = Long.valueOf(dscpSet.toArray()[0].toString());
}
Map<String, String> otherConfigs;
Map<String, String> externalIds;
otherConfigs = ((OvsdbMap) queue.getOtherConfigColumn().data()).map();
externalIds = ((OvsdbMap) queue.getExternalIdsColumn().data()).map();
return OvsdbQueue.builder().dscp(dscp).otherConfigs(otherConfigs).externalIds(externalIds).build();
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class DefaultOvsdbClient method removeQos.
@Override
public void removeQos(PortNumber portNumber) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
OvsdbRowStore rowStore = getRowStore(DATABASENAME, PORT);
if (rowStore == null) {
log.debug("The qos uuid is null");
return;
}
ConcurrentMap<String, Row> ovsTableRows = rowStore.getRowStore();
Row portRow = ovsTableRows.values().stream().filter(r -> r.getColumn("name").data().equals(portNumber.name())).findFirst().orElse(null);
if (portRow == null) {
log.warn("Couldn't find port {} in ovsdb port table.", portNumber.name());
return;
}
OvsdbSet ovsdbSet = ((OvsdbSet) portRow.getColumn(PORT_QOS).data());
@SuppressWarnings("unchecked") Set<Uuid> qosIdSet = ovsdbSet.set();
if (qosIdSet == null || qosIdSet.isEmpty()) {
return;
}
Uuid qosUuid = (Uuid) qosIdSet.toArray()[0];
Condition condition = ConditionUtil.isEqual(UUID, portRow.uuid());
List<Condition> conditions = Lists.newArrayList(condition);
Mutation mutation = MutationUtil.delete(PORT_QOS, qosUuid);
List<Mutation> mutations = Lists.newArrayList(mutation);
ArrayList<Operation> operations = Lists.newArrayList();
Mutate mutate = new Mutate(dbSchema.getTableSchema(PORT), conditions, mutations);
operations.add(mutate);
transactConfig(DATABASENAME, operations);
}
use of org.onosproject.ovsdb.rfc.notation.OvsdbSet in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getControllers.
private List<Controller> getControllers(Uuid bridgeUuid) {
DatabaseSchema dbSchema = schema.get(DATABASENAME);
if (dbSchema == null) {
return null;
}
OvsdbRowStore rowStore = getRowStore(DATABASENAME, BRIDGE);
if (rowStore == null) {
log.debug("There is no bridge table");
return null;
}
Row bridgeRow = rowStore.getRow(bridgeUuid.value());
Bridge bridge = (Bridge) TableGenerator.getTable(dbSchema, bridgeRow, OvsdbTable.BRIDGE);
// FIXME remove log
log.warn("type of controller column", bridge.getControllerColumn().data().getClass());
Set<Uuid> controllerUuids = (Set<Uuid>) ((OvsdbSet) bridge.getControllerColumn().data()).set();
OvsdbRowStore controllerRowStore = getRowStore(DATABASENAME, CONTROLLER);
if (controllerRowStore == null) {
log.debug("There is no controller table");
return null;
}
List<Controller> ovsdbControllers = new ArrayList<>();
ConcurrentMap<String, Row> controllerTableRows = controllerRowStore.getRowStore();
controllerTableRows.forEach((key, row) -> {
if (!controllerUuids.contains(Uuid.uuid(key))) {
return;
}
Controller controller = (Controller) TableGenerator.getTable(dbSchema, row, OvsdbTable.CONTROLLER);
ovsdbControllers.add(controller);
});
return ovsdbControllers;
}
Aggregations