use of org.onosproject.net.Port in project onos by opennetworkinglab.
the class DefaultKubevirtNetwork method tenantToTunnelPort.
@Override
public PortNumber tenantToTunnelPort(DeviceId deviceId) {
String portName = TENANT_TO_TUNNEL_PREFIX + segmentIdHex(segmentId);
Port port = port(deviceId, portName);
if (port == null) {
return null;
} else {
return port.number();
}
}
use of org.onosproject.net.Port 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.net.Port in project onos by opennetworkinglab.
the class DefaultOpenstackNode method tunnelPortNum.
private PortNumber tunnelPortNum(String tunnelType) {
if (dataIp == null) {
return null;
}
DeviceService deviceService = DefaultServiceDirectory.getService(DeviceService.class);
Port port = deviceService.getPorts(intgBridge).stream().filter(p -> p.isEnabled() && Objects.equals(p.annotations().value(PORT_NAME), tunnelType)).findAny().orElse(null);
return port != null ? port.number() : null;
}
use of org.onosproject.net.Port in project onos by opennetworkinglab.
the class PointToPointIntentCompiler method updateFailoverGroup.
// Removes buckets whose treatments rely on disabled ports from the
// failover group.
private void updateFailoverGroup(PointToPointIntent pointIntent) {
DeviceId deviceId = pointIntent.filteredIngressPoint().connectPoint().deviceId();
GroupKey groupKey = makeGroupKey(pointIntent.id());
Group group = waitForGroup(deviceId, groupKey);
Iterator<GroupBucket> groupIterator = group.buckets().buckets().iterator();
while (groupIterator.hasNext()) {
GroupBucket bucket = groupIterator.next();
Instruction individualInstruction = bucket.treatment().allInstructions().get(0);
if (individualInstruction instanceof Instructions.OutputInstruction) {
Instructions.OutputInstruction outInstruction = (Instructions.OutputInstruction) individualInstruction;
Port port = deviceService.getPort(deviceId, outInstruction.port());
if (port == null || !port.isEnabled()) {
GroupBuckets removeBuckets = new GroupBuckets(Collections.singletonList(bucket));
groupService.removeBucketsFromGroup(deviceId, groupKey, removeBuckets, groupKey, pointIntent.appId());
}
}
}
}
use of org.onosproject.net.Port in project onos by opennetworkinglab.
the class OplinkHandshakerUtil method buildPortPowerDescriptions.
/**
* Creates port descriptions with current power.
*
* @param portPowers current power
* @return port descriptions
*/
public List<PortDescription> buildPortPowerDescriptions(List<OFOplinkPortPower> portPowers) {
DeviceService deviceService = driver.handler().get(DeviceService.class);
List<Port> ports = deviceService.getPorts(driver.data().deviceId());
HashMap<Long, OFOplinkPortPower> powerMap = new HashMap<>(portPowers.size());
// Get each port power value
portPowers.forEach(power -> powerMap.put((long) power.getPort(), power));
final List<PortDescription> portDescs = new ArrayList<>();
for (Port port : ports) {
DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
builder.putAll(port.annotations());
OFOplinkPortPower power = powerMap.get(port.number().toLong());
if (power != null) {
// power value is actually signed-short value, down casting to recover sign bit.
builder.set(OpticalAnnotations.CURRENT_POWER, Short.toString((short) power.getPowerValue()));
}
portDescs.add(DefaultPortDescription.builder().withPortNumber(port.number()).isEnabled(port.isEnabled()).type(port.type()).portSpeed(port.portSpeed()).annotations(builder.build()).build());
}
return portDescs;
}
Aggregations