Search in sources :

Example 11 with OchSignal

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

the class GrooveOpenConfigDeviceDiscovery method parseLogicalChannel.

/**
 * Parses a component XML doc into a PortDescription.
 *
 * @param channel subtree to parse. It must be a component ot type PORT.
 *  case we need to check transceivers or optical channels.
 *
 * @return PortDescription or null if component does not have onos-index
 */
private PortDescription parseLogicalChannel(HierarchicalConfiguration channel) {
    HierarchicalConfiguration config = channel.configurationAt("config");
    String logicalChannelIndex = config.getString("index");
    String description = config.getString("description");
    String rateClass = config.getString("rate-class");
    Map<String, String> annotations = new HashMap<>();
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_LOGICAL_CHANNEL, logicalChannelIndex);
    HierarchicalConfiguration assignment = channel.configurationAt("logical-channel-assignments/assignment[index=1]/config");
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_NAME, assignment.getString("optical-channel"));
    // Store all properties as port properties
    // e.g. 100GE-1-14-C3
    Pattern clientPattern = Pattern.compile(".*-[1]-[1-9][0-4]?-C[3-9]$");
    // e.g. OTUC2-1-1-L2
    Pattern linePattern = Pattern.compile(".*-[1]-[1-9][0-4]?-L[1-2]$");
    Matcher clientMatch = clientPattern.matcher(description);
    Matcher lineMatch = linePattern.matcher(description);
    Pattern portSpeedPattern = Pattern.compile("TRIB_RATE_([0-9.]*)G");
    Matcher portSpeedMatch = portSpeedPattern.matcher(rateClass);
    Builder builder = DefaultPortDescription.builder();
    Long speed = 0L;
    if (portSpeedMatch.find()) {
        speed = Long.parseLong(portSpeedMatch.group(1));
        builder.portSpeed(speed * 1000);
    }
    if (clientMatch.find()) {
        log.info("Parsing CLIENT port {} type {} rate {}", logicalChannelIndex, description, rateClass);
        final String[] split = clientMatch.group(0).split("-");
        Long portNum = (10000 * Long.parseLong(split[1])) + (100 * Long.parseLong(split[2])) + Long.parseLong(split[3].replace("C", ""));
        String connectionId = "connection:" + portNum;
        annotations.putIfAbsent(PORT_TYPE, OdtnPortType.CLIENT.value());
        annotations.putIfAbsent(ONOS_PORT_INDEX, portNum.toString());
        annotations.putIfAbsent(CONNECTION_ID, connectionId);
        builder.withPortNumber(PortNumber.portNumber(portNum));
        builder.type(Type.PACKET);
        builder.annotations(DefaultAnnotations.builder().putAll(annotations).build());
        return builder.build();
    } else if (lineMatch.find()) {
        log.info("Parsing LINE port {} type {} rate {}", logicalChannelIndex, description, rateClass);
        final String[] split = lineMatch.group(0).split("-");
        Long portNum = (10000 * Long.parseLong(split[1])) + (100 * Long.parseLong(split[2])) + Long.parseLong(split[3].replace("L", ""));
        String connectionId = "connection:" + portNum;
        annotations.putIfAbsent(PORT_TYPE, OdtnPortType.LINE.value());
        annotations.putIfAbsent(ONOS_PORT_INDEX, portNum.toString());
        annotations.putIfAbsent(CONNECTION_ID, connectionId);
        OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1);
        return OchPortHelper.ochPortDescription(PortNumber.portNumber(portNum), true, speed == 200 ? OduSignalType.ODUC2 : OduSignalType.ODU4, true, signalId, DefaultAnnotations.builder().putAll(annotations).build());
    } else {
        log.debug("Discarding component: {}", description);
        return null;
    }
}
Also used : Pattern(java.util.regex.Pattern) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) Builder(org.onosproject.net.device.DefaultPortDescription.Builder) OchSignal(org.onosproject.net.OchSignal) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration)

Example 12 with OchSignal

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

the class NokiaOpenConfigDeviceDiscovery method toPortDescriptionInternal.

/**
 * Converts Component subtree to PortDescription.
 *
 * @param component subtree to parse
 * @return PortDescription or null if component is not an ONOS Port
 */
private PortDescription toPortDescriptionInternal(HierarchicalConfiguration component) {
    Map<String, String> annotations = new HashMap<>();
    String name = component.getString("name");
    String type = component.getString("state/type");
    checkNotNull(name, "name not found");
    checkNotNull(type, "state/type not found");
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_NAME, name);
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_TYPE, type);
    component.configurationsAt("properties/property").forEach(property -> {
        String pn = property.getString("name");
        String pv = property.getString("state/value");
        annotations.put(pn, pv);
    });
    if (type.equals("oc-platform-types:PORT")) {
        String subComponentName = component.getString("subcomponents/subcomponent/name");
        String[] textStr = subComponentName.split("-");
        String portComponentType = textStr[0];
        String portComponentIndex = textStr[textStr.length - 1];
        String portNumber = component.getString("name");
        if (portComponentType.equals(OPTICAL_CHANNEL)) {
            annotations.putIfAbsent(PORT_TYPE, OdtnPortType.LINE.value());
            annotations.putIfAbsent(ONOS_PORT_INDEX, portComponentIndex.toString());
            annotations.putIfAbsent(CONNECTION_ID, "connection" + portComponentIndex.toString());
            annotations.putIfAbsent(AnnotationKeys.PORT_NAME, portNumber);
            OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1);
            return OchPortHelper.ochPortDescription(PortNumber.portNumber(Long.parseLong(portComponentIndex)), true, // TODO Client signal to be discovered
            OduSignalType.ODU4, true, signalId, DefaultAnnotations.builder().putAll(annotations).build());
        } else if (portComponentType.equals(TRANSCEIVER)) {
            Builder builder = DefaultPortDescription.builder();
            annotations.putIfAbsent(PORT_TYPE, OdtnPortType.CLIENT.value());
            annotations.putIfAbsent(ONOS_PORT_INDEX, portComponentIndex.toString());
            annotations.putIfAbsent(CONNECTION_ID, "connection" + portComponentIndex.toString());
            annotations.putIfAbsent(AnnotationKeys.PORT_NAME, portNumber);
            builder.withPortNumber(PortNumber.portNumber(Long.parseLong(portComponentIndex), subComponentName));
            builder.type(Type.PACKET);
            builder.annotations(DefaultAnnotations.builder().putAll(annotations).build());
            return builder.build();
        } else {
            log.debug("Unknown port component type {}", type);
            return null;
        }
    } else {
        log.debug("Another component type {}", type);
        return null;
    }
}
Also used : HashMap(java.util.HashMap) Builder(org.onosproject.net.device.DefaultPortDescription.Builder) OchSignal(org.onosproject.net.OchSignal)

Example 13 with OchSignal

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

the class OpenRoadmDeviceDescription method buildSrgPortDesc.

/**
 * Parses a component XML doc into a PortDescription.
 * An Och port description is constructed from XML parsed data.
 *
 * @param nodeId The OpenRoadm nodeId of the current node.
 * @param circuitPackName name of circuit pack containing the port.
 * @param pNum the portNumber of the port.
 * @param reversepNum the portNumber of the partner port.
 * @param port the hierarchical configuration of the port to parse
 * @param extLink Hierarchical configuration for the external links.
 * @return PortDescription or null.
 */
private PortDescription buildSrgPortDesc(String nodeId, String circuitPackName, PortNumber pNum, PortNumber reversepNum, HierarchicalConfiguration port, HierarchicalConfiguration extLink) {
    DefaultAnnotations annotations = createPortAnnotations(nodeId, circuitPackName, pNum, reversepNum, port, extLink);
    OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 3);
    return OchPortHelper.ochPortDescription(pNum, true, /* enabled */
    OduSignalType.ODU4, true, /* tunable */
    signalId, annotations);
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) OchSignal(org.onosproject.net.OchSignal)

Example 14 with OchSignal

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

the class OpenRoadmFlowRuleProgrammable method toOchSignalCenterWidth.

/**
 * Helper method to create an OchSignal for a frequency slot.
 *
 *  @param center the center frequency as per the ITU-grid.
 *  @param width slot width
 * @return OCh signal
 */
public static OchSignal toOchSignalCenterWidth(Frequency center, Frequency width) {
    Frequency radius = width.floorDivision(2);
    // Frequency slot start and end frequency.
    double start = center.subtract(radius).asGHz();
    double end = center.add(radius).asGHz();
    int slots = (int) ((end - start) / ChannelSpacing.CHL_12P5GHZ.frequency().asGHz());
    int multiplier = 0;
    // Conversion for 50 GHz slots
    if (end - start == 50) {
        multiplier = (int) (((end - start) / 2 + start - Spectrum.CENTER_FREQUENCY.asGHz()) / ChannelSpacing.CHL_50GHZ.frequency().asGHz());
        return new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, multiplier, slots);
    }
    // Conversion for 100 GHz slots
    if (end - start == 100) {
        multiplier = (int) (((end - start) / 2 + start - Spectrum.CENTER_FREQUENCY.asGHz()) / ChannelSpacing.CHL_100GHZ.frequency().asGHz());
        return new OchSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, multiplier, slots);
    }
    return null;
}
Also used : Frequency(org.onlab.util.Frequency) OchSignal(org.onosproject.net.OchSignal)

Example 15 with OchSignal

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

the class CassiniTerminalDeviceDiscoveryOld method parseLogicalChannel.

/**
 * Parses a component XML doc into a PortDescription.
 *
 * @param channel subtree to parse. It must be a component ot type PORT.
 *  case we need to check transceivers or optical channels.
 *
 * @return PortDescription or null if component does not have onos-index
 */
private PortDescription parseLogicalChannel(HierarchicalConfiguration channel) {
    HierarchicalConfiguration config = channel.configurationAt("config");
    String logicalChannelIndex = config.getString("index");
    String description = config.getString("description");
    String rateClass = config.getString("rate-class");
    log.info("Parsing Component {} type {} rate {}", logicalChannelIndex, description, rateClass);
    Map<String, String> annotations = new HashMap<>();
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_LOGICAL_CHANNEL, logicalChannelIndex);
    annotations.put(OdtnDeviceDescriptionDiscovery.OC_NAME, description);
    // Store all properties as port properties
    // e.g. xe1/1
    Pattern clientPattern = Pattern.compile("xe(\\d*)/1");
    // e.g. oe1
    Pattern linePattern = Pattern.compile("oe(\\d*)/(\\d*)");
    Matcher clientMatch = clientPattern.matcher(description);
    Matcher lineMatch = linePattern.matcher(description);
    Pattern portSpeedPattern = Pattern.compile("TRIB_RATE_([0-9.]*)G");
    Matcher portSpeedMatch = portSpeedPattern.matcher(rateClass);
    Builder builder = DefaultPortDescription.builder();
    if (portSpeedMatch.find()) {
        Long speed = Long.parseLong(portSpeedMatch.group(1));
        builder.portSpeed(speed * 1000);
    }
    if (clientMatch.find()) {
        Long num = Long.parseLong(clientMatch.group(1));
        Long portNum = 100 + num;
        String connectionId = "connection:" + num.toString();
        annotations.putIfAbsent(PORT_TYPE, OdtnPortType.CLIENT.value());
        annotations.putIfAbsent(ONOS_PORT_INDEX, portNum.toString());
        annotations.putIfAbsent(CONNECTION_ID, connectionId);
        builder.withPortNumber(PortNumber.portNumber(portNum));
        builder.type(Type.PACKET);
        builder.annotations(DefaultAnnotations.builder().putAll(annotations).build());
        return builder.build();
    } else if (lineMatch.find()) {
        Long num = (Long.parseLong(lineMatch.group(1)) - 1) * 2 + Long.parseLong(lineMatch.group(2));
        Long portNum = 200 + num;
        String connectionId = "connection:" + num.toString();
        annotations.putIfAbsent(PORT_TYPE, OdtnPortType.LINE.value());
        annotations.putIfAbsent(ONOS_PORT_INDEX, portNum.toString());
        annotations.putIfAbsent(CONNECTION_ID, connectionId);
        OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1);
        return OchPortHelper.ochPortDescription(PortNumber.portNumber(portNum), true, // TODO Client signal to be discovered
        OduSignalType.ODU4, true, signalId, DefaultAnnotations.builder().putAll(annotations).build());
    } else {
        log.warn("Unexpected component description: {}", description);
        return null;
    }
}
Also used : Pattern(java.util.regex.Pattern) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) Builder(org.onosproject.net.device.DefaultPortDescription.Builder) OchSignal(org.onosproject.net.OchSignal) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration)

Aggregations

OchSignal (org.onosproject.net.OchSignal)63 PortNumber (org.onosproject.net.PortNumber)17 ChannelSpacing (org.onosproject.net.ChannelSpacing)16 GridType (org.onosproject.net.GridType)14 DeviceId (org.onosproject.net.DeviceId)12 ConnectPoint (org.onosproject.net.ConnectPoint)11 DeviceService (org.onosproject.net.device.DeviceService)10 HashMap (java.util.HashMap)9 Set (java.util.Set)9 IntStream (java.util.stream.IntStream)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 Logger (org.slf4j.Logger)8 ArrayList (java.util.ArrayList)7 Port (org.onosproject.net.Port)7 Collectors (java.util.stream.Collectors)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)6 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)6 Collections (java.util.Collections)5 List (java.util.List)5 Frequency (org.onlab.util.Frequency)5