Search in sources :

Example 6 with OduCltPort

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

the class OpticalCircuitIntentCompiler method compile.

@Override
public List<Intent> compile(OpticalCircuitIntent intent, List<Intent> installable) {
    // Check if ports are OduClt ports
    ConnectPoint src = intent.getSrc();
    ConnectPoint dst = intent.getDst();
    Port srcPort = deviceService.getPort(src.deviceId(), src.port());
    Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
    checkArgument(srcPort instanceof OduCltPort);
    checkArgument(dstPort instanceof OduCltPort);
    log.debug("Compiling optical circuit intent between {} and {}", src, dst);
    // Release of intent resources here is only a temporary solution for handling the
    // case of recompiling due to intent restoration (when intent state is FAILED).
    // TODO: try to release intent resources in IntentManager.
    resourceService.release(intent.key());
    // Check OduClt ports availability
    Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
    Resource dstPortResource = Resources.discrete(dst.deviceId(), dst.port()).resource();
    // If ports are not available, compilation fails
    if (!Stream.of(srcPortResource, dstPortResource).allMatch(resourceService::isAvailable)) {
        throw new OpticalIntentCompilationException("Ports for the intent are not available. Intent: " + intent);
    }
    List<Resource> ports = ImmutableList.of(srcPortResource, dstPortResource);
    // Check if both devices support multiplexing (usage of TributarySlots)
    boolean multiplexingSupported = isMultiplexingSupported(intent.getSrc()) && isMultiplexingSupported(intent.getDst());
    OpticalConnectivityIntent connIntent = findOpticalConnectivityIntent(intent.getSrc(), intent.getDst(), intent.getSignalType(), multiplexingSupported);
    if (connIntent != null && !multiplexingSupported) {
        return compile(intent, src, dst, Optional.of(connIntent), ports, false);
    }
    // Create optical connectivity intent if needed - no optical intent or not enough slots available
    if (connIntent == null) {
        return compile(intent, src, dst, Optional.empty(), ports, multiplexingSupported);
    }
    List<Resource> slots = availableSlotResources(connIntent.getSrc(), connIntent.getDst(), intent.getSignalType());
    if (slots.isEmpty()) {
        return compile(intent, src, dst, Optional.empty(), ports, true);
    }
    return compile(intent, src, dst, Optional.of(connIntent), ImmutableList.<Resource>builder().addAll(ports).addAll(slots).build(), false);
}
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) Resource(org.onosproject.net.resource.Resource) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 7 with OduCltPort

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

the class OpticalIntentUtility 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 deviceService device service
 * @param key intent key
 * @param appId application id
 * @param bidirectional if this argument is true, the optical link created
 * will be bidirectional, otherwise the link will be unidirectional.
 * @param signal optical signal
 * @param suggestedPath suggested path
 *
 * @return created intent
 */
public static Intent createOpticalIntent(ConnectPoint ingress, ConnectPoint egress, DeviceService deviceService, Key key, ApplicationId appId, boolean bidirectional, OchSignal signal, Path suggestedPath) {
    Intent intent = null;
    if (ingress == null || egress == null) {
        log.debug("Invalid endpoint(s); could not create optical intent");
        return intent;
    }
    DeviceService ds = opticalView(deviceService);
    Port srcPort = ds.getPort(ingress.deviceId(), ingress.port());
    Port dstPort = ds.getPort(egress.deviceId(), egress.port());
    if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
        Device srcDevice = ds.getDevice(ingress.deviceId());
        Device dstDevice = ds.getDevice(egress.deviceId());
        // continue only if both OduClt port's Devices are of the same type
        if (!(srcDevice.type().equals(dstDevice.type()))) {
            log.debug("Devices without same deviceType: SRC {} and DST={}", srcDevice.type(), dstDevice.type());
            return intent;
        }
        CltSignalType signalType = ((OduCltPort) srcPort).signalType();
        if (Type.ROADM.equals(srcDevice.type()) || Type.ROADM_OTN.equals(srcDevice.type()) || Type.OLS.equals(srcDevice.type()) || Type.TERMINAL_DEVICE.equals(srcDevice.type())) {
            intent = OpticalCircuitIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).ochSignal(Optional.ofNullable(signal)).suggestedPath(Optional.ofNullable(suggestedPath)).build();
        } else if (Type.OTN.equals(srcDevice.type())) {
            intent = OpticalOduIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).build();
        } else {
            log.debug("Wrong Device Type for connect points {} and {}", ingress, egress);
        }
    } else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
        OduSignalType signalType = ((OchPort) srcPort).signalType();
        intent = OpticalConnectivityIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).ochSignal(Optional.ofNullable(signal)).suggestedPath(Optional.ofNullable(suggestedPath)).build();
    } else {
        log.debug("Unable to create optical intent between connect points {} and {}", ingress, egress);
    }
    return intent;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) Device(org.onosproject.net.Device) OduCltPort(org.onosproject.net.optical.OduCltPort) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) DeviceService(org.onosproject.net.device.DeviceService) OduCltPort(org.onosproject.net.optical.OduCltPort) CltSignalType(org.onosproject.net.CltSignalType) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Intent(org.onosproject.net.intent.Intent) OpticalOduIntent(org.onosproject.net.intent.OpticalOduIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) OchPort(org.onosproject.net.optical.OchPort)

Example 8 with OduCltPort

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

the class OpticalIntentUtility method createExplicitOpticalIntent.

/**
 * Returns a new optical intent created from the method parameters, strict suggestedPath is specified.
 *
 * @param ingress ingress description (device/port)
 * @param egress egress description (device/port)
 * @param deviceService device service
 * @param key intent key
 * @param appId application id
 * @param bidirectional if this argument is true, the optical link created
 * will be bidirectional, otherwise the link will be unidirectional.
 * @param signal optical signal
 * @param suggestedPath suggested path for the intent
 *
 * @return created intent
 */
public static Intent createExplicitOpticalIntent(ConnectPoint ingress, ConnectPoint egress, DeviceService deviceService, Key key, ApplicationId appId, boolean bidirectional, OchSignal signal, Path suggestedPath) {
    Intent intent = null;
    if (ingress == null || egress == null) {
        log.error("Invalid endpoint(s); could not create optical intent");
        return intent;
    }
    DeviceService ds = opticalView(deviceService);
    Port srcPort = ds.getPort(ingress.deviceId(), ingress.port());
    Port dstPort = ds.getPort(egress.deviceId(), egress.port());
    if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
        Device srcDevice = ds.getDevice(ingress.deviceId());
        Device dstDevice = ds.getDevice(egress.deviceId());
        // continue only if both OduClt port's Devices are of the same type
        if (!(srcDevice.type().equals(dstDevice.type()))) {
            log.debug("Devices without same deviceType: SRC={} and DST={}", srcDevice.type(), dstDevice.type());
            return intent;
        }
        CltSignalType signalType = ((OduCltPort) srcPort).signalType();
        if (Type.ROADM.equals(srcDevice.type()) || Type.ROADM_OTN.equals(srcDevice.type()) || Type.OLS.equals(srcDevice.type()) || Type.TERMINAL_DEVICE.equals(srcDevice.type())) {
            intent = OpticalCircuitIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).ochSignal(Optional.ofNullable(signal)).suggestedPath(Optional.ofNullable(suggestedPath)).build();
        } else if (Type.OTN.equals(srcDevice.type())) {
            intent = OpticalOduIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).build();
        } else {
            log.error("Wrong Device Type for connect points: " + "ingress {} of type {}; egress {} of type {}", ingress, srcDevice.type(), egress, dstDevice.type());
        }
    } else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
        OduSignalType signalType = ((OchPort) srcPort).signalType();
        intent = OpticalConnectivityIntent.builder().appId(appId).key(key).src(ingress).dst(egress).signalType(signalType).bidirectional(bidirectional).ochSignal(Optional.ofNullable(signal)).suggestedPath(Optional.ofNullable(suggestedPath)).build();
    } else {
        log.error("Unable to create explicit optical intent between connect points {} and {}", ingress, egress);
    }
    return intent;
}
Also used : OduSignalType(org.onosproject.net.OduSignalType) Device(org.onosproject.net.Device) OduCltPort(org.onosproject.net.optical.OduCltPort) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) DeviceService(org.onosproject.net.device.DeviceService) OduCltPort(org.onosproject.net.optical.OduCltPort) CltSignalType(org.onosproject.net.CltSignalType) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Intent(org.onosproject.net.intent.Intent) OpticalOduIntent(org.onosproject.net.intent.OpticalOduIntent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) OchPort(org.onosproject.net.optical.OchPort)

Aggregations

OduCltPort (org.onosproject.net.optical.OduCltPort)8 Port (org.onosproject.net.Port)7 OchPort (org.onosproject.net.optical.OchPort)6 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)4 CltSignalType (org.onosproject.net.CltSignalType)3 ConnectPoint (org.onosproject.net.ConnectPoint)3 OduSignalType (org.onosproject.net.OduSignalType)3 Intent (org.onosproject.net.intent.Intent)3 OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Device (org.onosproject.net.Device)2 DeviceService (org.onosproject.net.device.DeviceService)2 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)2 FlowRule (org.onosproject.net.flow.FlowRule)2 OpticalOduIntent (org.onosproject.net.intent.OpticalOduIntent)2 OtuPort (org.onosproject.net.optical.OtuPort)2 Resource (org.onosproject.net.resource.Resource)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Set (java.util.Set)1