Search in sources :

Example 1 with OduSignalType

use of org.onosproject.net.OduSignalType in project onos by opennetworkinglab.

the class ServiceApplicationComponent method createOpticalIntent.

/**
 * Returns a new optical intent created from the method parameters.
 *
 * @param ingress ingress description (device/port)
 * @param egress egress description (device/port)
 * @param key intent key
 * @param appId application id. As per Intent class, it cannot be null
 *
 * @return created intent
 */
protected Intent createOpticalIntent(ConnectPoint ingress, ConnectPoint egress, Key key, ApplicationId appId) {
    if (ingress == null || egress == null) {
        log.error("Invalid endpoint(s) for optical intent: ingress {}, egress {}", ingress, egress);
        return null;
    }
    DeviceService ds = opticalView(deviceService);
    Port srcPort = ds.getPort(ingress.deviceId(), ingress.port());
    Port dstPort = ds.getPort(egress.deviceId(), egress.port());
    if (srcPort == null || dstPort == null) {
        log.error("Invalid port(s) for optical intent: src {}, dst {}", srcPort, dstPort);
        return null;
    }
    OduSignalType signalType = ((OchPort) srcPort).signalType();
    return OpticalConnectivityIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(// TODO Revisit this.
    true).build();
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) DeviceService(org.onosproject.net.device.DeviceService) OchPort(org.onosproject.net.optical.OchPort)

Example 2 with OduSignalType

use of org.onosproject.net.OduSignalType in project onos by opennetworkinglab.

the class OchPortHelper method asOchPort.

public static Optional<OchPort> asOchPort(Port port) {
    if (port instanceof OchPort) {
        return Optional.of((OchPort) port);
    }
    try {
        Annotations an = port.annotations();
        OduSignalType signalType = Enum.valueOf(OduSignalType.class, an.value(SIGNAL_TYPE));
        boolean isTunable = Boolean.valueOf(an.value(TUNABLE));
        ObjectNode obj = (ObjectNode) MAPPER.readTree(an.value(LAMBDA));
        OchSignal lambda = OchSignalCodec.decode(obj);
        // DefaultOchPort should filter them, if necessary.
        return Optional.of(new DefaultOchPort(port, signalType, isTunable, lambda));
    // TODO: it'll be better to verify each inputs properly
    // instead of catching all these Exceptions.
    } catch (IOException | NullPointerException | IllegalArgumentException | ClassCastException e) {
        log.warn("{} was not well-formed OCh port.", port, e);
        return Optional.empty();
    }
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) SparseAnnotations(org.onosproject.net.SparseAnnotations) OduSignalType(org.onosproject.net.OduSignalType) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) OchSignal(org.onosproject.net.OchSignal) DefaultOchPort(org.onosproject.net.optical.impl.DefaultOchPort) IOException(java.io.IOException) OchPort(org.onosproject.net.optical.OchPort) DefaultOchPort(org.onosproject.net.optical.impl.DefaultOchPort)

Example 3 with OduSignalType

use of org.onosproject.net.OduSignalType in project onos by opennetworkinglab.

the class OpticalOduIntentCompiler method isAvailableTributarySlots.

private boolean isAvailableTributarySlots(OpticalOduIntent intent, Link link) {
    OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
    int requestedTsNum = oduSignalType.tributarySlots();
    Set<TributarySlot> common = findCommonTributarySlotsOnCps(link.src(), link.dst());
    if (common.isEmpty() || (common.size() < requestedTsNum)) {
        log.debug("Not enough available TributarySlots on link {} requestedTsNum={}", link, requestedTsNum);
        return false;
    }
    return true;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) TributarySlot(org.onosproject.net.TributarySlot) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 4 with OduSignalType

use of org.onosproject.net.OduSignalType 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 5 with OduSignalType

use of org.onosproject.net.OduSignalType 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;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OduCltPort(org.onosproject.net.optical.OduCltPort) OduCltPort(org.onosproject.net.optical.OduCltPort) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OduSignalId(org.onosproject.net.OduSignalId) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Aggregations

OduSignalType (org.onosproject.net.OduSignalType)12 OchPort (org.onosproject.net.optical.OchPort)6 Port (org.onosproject.net.Port)5 ConnectPoint (org.onosproject.net.ConnectPoint)4 TributarySlot (org.onosproject.net.TributarySlot)4 DeviceService (org.onosproject.net.device.DeviceService)4 OduCltPort (org.onosproject.net.optical.OduCltPort)4 CltSignalType (org.onosproject.net.CltSignalType)3 OduSignalId (org.onosproject.net.OduSignalId)3 Intent (org.onosproject.net.intent.Intent)3 OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)3 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 LinkedList (java.util.LinkedList)2 Set (java.util.Set)2 Test (org.junit.Test)2 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)2 Device (org.onosproject.net.Device)2 OchSignal (org.onosproject.net.OchSignal)2 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)2