use of org.onosproject.ovsdb.controller.OvsdbPort 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.controller.OvsdbPort in project onos by opennetworkinglab.
the class OvsdbBridgeConfig method getPorts.
@Override
public Collection<PortDescription> getPorts() {
OvsdbClientService client = getOvsdbClientService(handler());
if (client == null) {
return Collections.emptyList();
}
Set<OvsdbPort> ports = client.getPorts();
return ports.stream().map(x -> DefaultPortDescription.builder().withPortNumber(PortNumber.portNumber(x.portNumber().value())).isEnabled(true).annotations(DefaultAnnotations.builder().set("portName", x.portName().value()).build()).build()).collect(Collectors.toSet());
}
use of org.onosproject.ovsdb.controller.OvsdbPort in project onos by opennetworkinglab.
the class DefaultOvsdbClient method getOvsdbPort.
private OvsdbPort getOvsdbPort(Row row) {
DatabaseSchema dbSchema = getDatabaseSchema(DATABASENAME);
Interface intf = (Interface) TableGenerator.getTable(dbSchema, row, OvsdbTable.INTERFACE);
if (intf == null) {
return null;
}
long ofPort = getOfPort(intf);
String portName = intf.getName();
if ((ofPort < 0) || (portName == null)) {
return null;
}
return new OvsdbPort(new OvsdbPortNumber(ofPort), new OvsdbPortName(portName));
}
use of org.onosproject.ovsdb.controller.OvsdbPort in project onos by opennetworkinglab.
the class OvsdbBridgeConfig method getPortNumbers.
@Override
public Set<PortNumber> getPortNumbers() {
DriverHandler handler = handler();
OvsdbClientService client = getOvsdbClientService(handler);
if (client == null) {
return Collections.emptySet();
}
Set<OvsdbPort> ports = client.getPorts();
return ports.stream().map(x -> PortNumber.portNumber(x.portNumber().value(), x.portName().value())).collect(Collectors.toSet());
}
use of org.onosproject.ovsdb.controller.OvsdbPort in project onos by opennetworkinglab.
the class OvsdbBridgeConfig method getLocalPorts.
@Override
public List<PortNumber> getLocalPorts(Iterable<String> ifaceIds) {
List<PortNumber> ports = new ArrayList<>();
DriverHandler handler = handler();
OvsdbClientService client = getOvsdbClientService(handler);
if (client == null) {
return Collections.emptyList();
}
Set<OvsdbPort> ovsdbSet = client.getLocalPorts(ifaceIds);
ovsdbSet.forEach(o -> {
PortNumber port = PortNumber.portNumber(o.portNumber().value(), o.portName().value());
ports.add(port);
});
return ports;
}
Aggregations