use of org.onosproject.net.Port in project onos by opennetworkinglab.
the class OpenRoadmFlowRuleProgrammable method openRoadmConnectionName.
/**
* Construct a connection name given an OpenRoadmFlowRule.
*
* @param xc the flow rule or crossconnection.
*/
private String openRoadmConnectionName(OpenRoadmFlowRule xc) {
DeviceService deviceService = this.handler().get(DeviceService.class);
Port srcPort = deviceService.getPort(did(), xc.inPort());
Port dstPort = deviceService.getPort(did(), xc.outPort());
Frequency centerFreq = xc.ochSignal().centralFrequency();
return openRoadmConnectionName(srcPort, dstPort, centerFreq);
}
use of org.onosproject.net.Port in project onos by opennetworkinglab.
the class OpticalPathProvisioner method createIntents.
/**
* Scans the list of cross connection points and returns a list of optical connectivity intents.
* During the process, save information about packet links to given set.
*
* @param crossConnectPoints list of (src, dst) pair between which optical path will be set up
* @return list of optical connectivity intents
*/
private List<Intent> createIntents(List<Pair<ConnectPoint, ConnectPoint>> crossConnectPoints) {
List<Intent> intents = new LinkedList<>();
Iterator<Pair<ConnectPoint, ConnectPoint>> itr = crossConnectPoints.iterator();
while (itr.hasNext()) {
// checkArgument at start ensures we'll always have pairs of connect points
Pair<ConnectPoint, ConnectPoint> next = itr.next();
ConnectPoint src = next.getLeft();
ConnectPoint dst = next.getRight();
Port srcPort = deviceService.getPort(src.deviceId(), src.port());
Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
OduCltPort srcOCPort = (OduCltPort) srcPort;
OduCltPort dstOCPort = (OduCltPort) dstPort;
if (!srcOCPort.signalType().equals(dstOCPort.signalType())) {
continue;
}
// Create OTN circuit
OpticalCircuitIntent circuitIntent = OpticalCircuitIntent.builder().appId(appId).src(src).dst(dst).signalType(srcOCPort.signalType()).bidirectional(false).build();
intents.add(circuitIntent);
} else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
OchPort srcOchPort = (OchPort) srcPort;
OchPort dstOchPort = (OchPort) dstPort;
if (!srcOchPort.signalType().equals(dstOchPort.signalType())) {
continue;
}
// Create lightpath
OpticalConnectivityIntent opticalIntent = OpticalConnectivityIntent.builder().appId(appId).src(src).dst(dst).signalType(srcOchPort.signalType()).bidirectional(false).build();
intents.add(opticalIntent);
} else {
log.warn("Unsupported cross connect point types {} {}", srcPort.type(), dstPort.type());
return Collections.emptyList();
}
}
return intents;
}
use of org.onosproject.net.Port in project onos by opennetworkinglab.
the class PlainTransceiver method enable.
@Override
public List<CharSequence> enable(PortNumber client, PortNumber line, boolean enable) {
DeviceId did = this.data().deviceId();
Port port = handler().get(DeviceService.class).getPort(did, client);
if (port == null) {
log.warn("{} does not exist on {}", client, did);
return Collections.emptyList();
}
String component = port.annotations().value(OC_NAME);
if (Strings.isNullOrEmpty(component)) {
log.warn("{} annotation not found on {}@{}", OC_NAME, client, did);
return Collections.emptyList();
}
return enable(component, enable);
}
use of org.onosproject.net.Port in project onos by opennetworkinglab.
the class PipelineInterpreterImpl method mapInboundPacket.
@Override
public InboundPacket mapInboundPacket(PiPacketOperation packetIn, DeviceId deviceId) throws PiInterpreterException {
// We assume that the packet is ethernet, which is fine since mytunnel.p4
// can deparse only ethernet packets.
Ethernet ethPkt;
try {
ethPkt = Ethernet.deserializer().deserialize(packetIn.data().asArray(), 0, packetIn.data().size());
} catch (DeserializationException dex) {
throw new PiInterpreterException(dex.getMessage());
}
// Returns the ingress port packet metadata.
Optional<PiPacketMetadata> packetMetadata = packetIn.metadatas().stream().filter(metadata -> metadata.id().toString().equals(INGRESS_PORT)).findFirst();
if (packetMetadata.isPresent()) {
short s = packetMetadata.get().value().asReadOnlyBuffer().getShort();
ConnectPoint receivedFrom = new ConnectPoint(deviceId, PortNumber.portNumber(s));
return new DefaultInboundPacket(receivedFrom, ethPkt, packetIn.data().asReadOnlyBuffer());
} else {
throw new PiInterpreterException(format("Missing metadata '%s' in packet-in received from '%s': %s", INGRESS_PORT, deviceId, packetIn));
}
}
use of org.onosproject.net.Port in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompiler method connectPorts.
/**
* Builds flow rule for mapping between two ports.
*
* @param src source port
* @param dst destination port
* @param priority
* @param slots Set of TributarySlots
* @return flow rules
*/
private FlowRule connectPorts(ConnectPoint src, ConnectPoint dst, int priority, Set<TributarySlot> slots) {
checkArgument(src.deviceId().equals(dst.deviceId()));
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
selectorBuilder.matchInPort(src.port());
if (!slots.isEmpty()) {
Port srcPort = deviceService.getPort(src.deviceId(), src.port());
Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
OduSignalType oduCltPortOduSignalType;
OduSignalType ochPortOduSignalType;
if (srcPort instanceof OduCltPort) {
oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) srcPort).signalType());
ochPortOduSignalType = ((OchPort) dstPort).signalType();
selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
// use Instruction of OduSignalId only in case of ODU Multiplexing
if (oduCltPortOduSignalType != ochPortOduSignalType) {
OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots);
treatmentBuilder.add(Instructions.modL1OduSignalId(oduSignalId));
}
} else {
// srcPort is OchPort
oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) dstPort).signalType());
ochPortOduSignalType = ((OchPort) srcPort).signalType();
selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
// use Criteria of OduSignalId only in case of ODU Multiplexing
if (oduCltPortOduSignalType != ochPortOduSignalType) {
OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots);
selectorBuilder.add(Criteria.matchOduSignalId(oduSignalId));
}
}
}
treatmentBuilder.setOutput(dst.port());
FlowRule flowRule = DefaultFlowRule.builder().forDevice(src.deviceId()).withSelector(selectorBuilder.build()).withTreatment(treatmentBuilder.build()).withPriority(priority).fromApp(appId).makePermanent().build();
return flowRule;
}
Aggregations