Search in sources :

Example 1 with OtuPort

use of org.onosproject.net.optical.OtuPort in project onos by opennetworkinglab.

the class OpticalOduIntentCompiler method createRules.

/**
 * Create rules for the forward (or the reverse) path of the intent.
 *
 * @param intent OpticalOduIntent intent
 * @param path path found for intent
 * @param slotsMap Map of LinkKey and TributarySlots resources
 * @return list of flow rules
 */
private List<FlowRule> createRules(OpticalOduIntent intent, ConnectPoint src, ConnectPoint dst, Path path, Map<LinkKey, Set<TributarySlot>> slotsMap, boolean reverse) {
    // Build the ingress OTN rule
    TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
    selector.matchInPort(src.port());
    OduSignalType oduCltPortOduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
    selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
    List<FlowRule> rules = new LinkedList<>();
    ConnectPoint current = src;
    List<Link> links = ((!reverse) ? path.links() : Lists.reverse(path.links()));
    for (Link link : links) {
        Set<TributarySlot> slots = slotsMap.get(linkKey(link));
        OtuPort otuPort = (OtuPort) (deviceService.getPort(link.src().deviceId(), link.src().port()));
        OduSignalType otuPortOduSignalType = OduSignalUtils.mappingOtuSignalTypeToOduSignalType(otuPort.signalType());
        TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
        OduSignalId oduSignalId = null;
        // use Instruction of OduSignalId only in case of ODU Multiplexing
        if (oduCltPortOduSignalType != otuPortOduSignalType) {
            oduSignalId = OduSignalUtils.buildOduSignalId(otuPortOduSignalType, slots);
            treat.add(Instructions.modL1OduSignalId(oduSignalId));
        }
        ConnectPoint next = ((!reverse) ? link.src() : link.dst());
        treat.setOutput(next.port());
        FlowRule rule = createFlowRule(intent, current.deviceId(), selector.build(), treat.build());
        rules.add(rule);
        current = ((!reverse) ? link.dst() : link.src());
        selector = DefaultTrafficSelector.builder();
        selector.matchInPort(current.port());
        selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
        // use Criteria of OduSignalId only in case of ODU Multiplexing
        if (oduCltPortOduSignalType != otuPortOduSignalType) {
            selector.add(Criteria.matchOduSignalId(oduSignalId));
        }
    }
    // Build the egress OTN rule
    TrafficTreatment.Builder treatLast = DefaultTrafficTreatment.builder();
    treatLast.setOutput(dst.port());
    FlowRule rule = createFlowRule(intent, dst.deviceId(), selector.build(), treatLast.build());
    rules.add(rule);
    return rules;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) OtuPort(org.onosproject.net.optical.OtuPort) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) LinkedList(java.util.LinkedList) TributarySlot(org.onosproject.net.TributarySlot) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) OduSignalId(org.onosproject.net.OduSignalId) Link(org.onosproject.net.Link)

Example 2 with OtuPort

use of org.onosproject.net.optical.OtuPort in project onos by opennetworkinglab.

the class OpticalPortsListCommand method printPorts.

@Override
protected void printPorts(DeviceService service, Device device) {
    List<Port> ports = new ArrayList<>(service.getPorts(device.id()));
    ports.sort((p1, p2) -> Long.signum(p1.number().toLong() - p2.number().toLong()));
    for (Port port : ports) {
        if (!isIncluded(port)) {
            continue;
        }
        String portName = port.number().toString();
        String portIsEnabled = port.isEnabled() ? "enabled" : "disabled";
        String portType = port.type().toString().toLowerCase();
        switch(port.type()) {
            case OCH:
                if (port instanceof OchPort) {
                    OchPort och = (OchPort) port;
                    print(FMT_OCH, portName, portIsEnabled, portType, och.signalType().toString(), och.isTunable() ? "yes" : "no", annotations(och.unhandledAnnotations()));
                    break;
                }
                print("WARN: OchPort but not on OpticalDevice or ill-formed");
                print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations()));
                break;
            case ODUCLT:
                if (port instanceof OduCltPort) {
                    OduCltPort oduCltPort = (OduCltPort) port;
                    print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, oduCltPort.signalType().toString(), annotations(oduCltPort.unhandledAnnotations()));
                    break;
                }
                print("WARN: OduCltPort but not on OpticalDevice or ill-formed");
                print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations()));
                break;
            case OMS:
                if (port instanceof OmsPort) {
                    OmsPort oms = (OmsPort) port;
                    print(FMT_OMS, portName, portIsEnabled, portType, oms.minFrequency().asHz() / Frequency.ofGHz(1).asHz(), oms.maxFrequency().asHz() / Frequency.ofGHz(1).asHz(), oms.grid().asHz() / Frequency.ofGHz(1).asHz(), oms.totalChannels(), annotations(oms.unhandledAnnotations()));
                    break;
                }
                print("WARN: OmsPort but not on OpticalDevice or ill-formed");
                print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations()));
                break;
            case OTU:
                if (port instanceof OtuPort) {
                    OtuPort otuPort = (OtuPort) port;
                    print(FMT_ODUCLT_OTU, portName, portIsEnabled, portType, otuPort.signalType().toString(), annotations(otuPort.unhandledAnnotations()));
                    break;
                }
                print("WARN: OtuPort but not on OpticalDevice or ill-formed");
                print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations(port.annotations()));
                break;
            default:
                // do not print non-optical ports
                break;
        }
    }
}
Also used : OmsPort(org.onosproject.net.optical.OmsPort) OtuPort(org.onosproject.net.optical.OtuPort) OtuPort(org.onosproject.net.optical.OtuPort) OmsPort(org.onosproject.net.optical.OmsPort) OduCltPort(org.onosproject.net.optical.OduCltPort) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) ArrayList(java.util.ArrayList) OduCltPort(org.onosproject.net.optical.OduCltPort) OchPort(org.onosproject.net.optical.OchPort)

Example 3 with OtuPort

use of org.onosproject.net.optical.OtuPort in project onos by opennetworkinglab.

the class OtuPortHelper method asOtuPort.

public static Optional<OtuPort> asOtuPort(Port port) {
    if (port instanceof OtuPort) {
        return Optional.of((OtuPort) port);
    }
    try {
        Annotations an = port.annotations();
        OtuSignalType signalType = Enum.valueOf(OtuSignalType.class, an.value(SIGNAL_TYPE));
        // DefaultOtuPort should filter them, if necessary.
        return Optional.of(new DefaultOtuPort(port, signalType));
    } catch (NullPointerException | IllegalArgumentException e) {
        log.warn("{} was not well-formed Otu port.", port, e);
        return Optional.empty();
    }
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) SparseAnnotations(org.onosproject.net.SparseAnnotations) OtuPort(org.onosproject.net.optical.OtuPort) DefaultOtuPort(org.onosproject.net.optical.impl.DefaultOtuPort) DefaultOtuPort(org.onosproject.net.optical.impl.DefaultOtuPort) OtuSignalType(org.onosproject.net.OtuSignalType)

Aggregations

OtuPort (org.onosproject.net.optical.OtuPort)3 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 Annotations (org.onosproject.net.Annotations)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)1 Link (org.onosproject.net.Link)1 OduSignalId (org.onosproject.net.OduSignalId)1 OduSignalType (org.onosproject.net.OduSignalType)1 OtuSignalType (org.onosproject.net.OtuSignalType)1 Port (org.onosproject.net.Port)1 SparseAnnotations (org.onosproject.net.SparseAnnotations)1 TributarySlot (org.onosproject.net.TributarySlot)1 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)1 FlowRule (org.onosproject.net.flow.FlowRule)1 TrafficSelector (org.onosproject.net.flow.TrafficSelector)1 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)1 OchPort (org.onosproject.net.optical.OchPort)1