Search in sources :

Example 1 with OchPort

use of org.onosproject.net.optical.OchPort 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;
}
Also used : Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OduCltPort(org.onosproject.net.optical.OduCltPort) OduCltPort(org.onosproject.net.optical.OduCltPort) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Intent(org.onosproject.net.intent.Intent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) ConnectPoint(org.onosproject.net.ConnectPoint) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) LinkedList(java.util.LinkedList) OchPort(org.onosproject.net.optical.OchPort) Pair(org.apache.commons.lang3.tuple.Pair)

Example 2 with OchPort

use of org.onosproject.net.optical.OchPort 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 3 with OchPort

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

the class RoadmUtil method createOchSignalFromWavelength.

public static OchSignal createOchSignalFromWavelength(double wavelength, DeviceService deviceService, DeviceId deviceId, PortNumber portNumber) {
    if (wavelength == 0L) {
        return null;
    }
    Port port = deviceService.getPort(deviceId, portNumber);
    Optional<OchPort> ochPortOpt = OchPortHelper.asOchPort(port);
    if (ochPortOpt.isPresent()) {
        OchPort ochPort = ochPortOpt.get();
        GridType gridType = ochPort.lambda().gridType();
        ChannelSpacing channelSpacing = ochPort.lambda().channelSpacing();
        int slotGranularity = ochPort.lambda().slotGranularity();
        int multiplier = getMultiplier(wavelength, gridType, channelSpacing);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } else {
        return null;
    }
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OchSignal(org.onosproject.net.OchSignal) OchPort(org.onosproject.net.optical.OchPort) GridType(org.onosproject.net.GridType)

Example 4 with OchPort

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

the class PortWaveLengthCommand method createOchSignalFromWavelength.

private OchSignal createOchSignalFromWavelength(DeviceService deviceService, ConnectPoint cp) {
    long wavelength = Long.parseLong(parameter);
    if (wavelength == 0L) {
        return null;
    }
    Port port = deviceService.getPort(cp);
    Optional<OchPort> ochPortOpt = OchPortHelper.asOchPort(port);
    if (ochPortOpt.isPresent()) {
        OchPort ochPort = ochPortOpt.get();
        GridType gridType = ochPort.lambda().gridType();
        ChannelSpacing channelSpacing = ochPort.lambda().channelSpacing();
        int slotGranularity = ochPort.lambda().slotGranularity();
        int multiplier = getMultplier(wavelength, gridType, channelSpacing);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } else {
        print("[ERROR] connect point %s is not OChPort", cp);
        return null;
    }
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OchSignal(org.onosproject.net.OchSignal) OchPort(org.onosproject.net.optical.OchPort) ConnectPoint(org.onosproject.net.ConnectPoint) GridType(org.onosproject.net.GridType)

Example 5 with OchPort

use of org.onosproject.net.optical.OchPort 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)

Aggregations

OchPort (org.onosproject.net.optical.OchPort)12 Port (org.onosproject.net.Port)10 OduCltPort (org.onosproject.net.optical.OduCltPort)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 OduSignalType (org.onosproject.net.OduSignalType)5 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)5 DeviceService (org.onosproject.net.device.DeviceService)4 Intent (org.onosproject.net.intent.Intent)4 ChannelSpacing (org.onosproject.net.ChannelSpacing)3 GridType (org.onosproject.net.GridType)3 OchSignal (org.onosproject.net.OchSignal)3 OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Annotations (org.onosproject.net.Annotations)2 CltSignalType (org.onosproject.net.CltSignalType)2 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)2 Device (org.onosproject.net.Device)2 OpticalOduIntent (org.onosproject.net.intent.OpticalOduIntent)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1