Search in sources :

Example 1 with OduCltPort

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

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

the class OduCltPortHelper method asOduCltPort.

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

Example 3 with OduCltPort

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

the class OpticalOduIntentCompiler method compile.

@Override
public List<Intent> compile(OpticalOduIntent 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 ODU 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> intentResources = new ArrayList<>();
    intentResources.add(srcPortResource);
    intentResources.add(dstPortResource);
    // Calculate available light paths
    Set<Path> paths = getOpticalPaths(intent);
    if (paths.isEmpty()) {
        throw new OpticalIntentCompilationException("Unable to find suitable lightpath for intent " + intent);
    }
    // Use first path that can be successfully reserved
    for (Path path : paths) {
        // Find available Tributary Slots on both directions of path
        Map<LinkKey, Set<TributarySlot>> slotsMap = findAvailableTributarySlots(intent, path);
        if (slotsMap.isEmpty()) {
            continue;
        }
        List<Resource> tributarySlotResources = convertToResources(slotsMap);
        if (!tributarySlotResources.stream().allMatch(resourceService::isAvailable)) {
            continue;
        }
        intentResources.addAll(tributarySlotResources);
        allocateResources(intent, intentResources);
        List<FlowRule> rules = new LinkedList<>();
        // Create rules for forward and reverse path
        rules = createRules(intent, intent.getSrc(), intent.getDst(), path, slotsMap, false);
        if (intent.isBidirectional()) {
            rules.addAll(createRules(intent, intent.getDst(), intent.getSrc(), path, slotsMap, true));
        }
        return Collections.singletonList(new FlowRuleIntent(appId, intent.key(), rules, ImmutableSet.copyOf(path.links()), PathIntent.ProtectionType.PRIMARY, intent.resourceGroup()));
    }
    throw new OpticalIntentCompilationException("Unable to find suitable lightpath for intent " + intent);
}
Also used : Path(org.onosproject.net.Path) LinkKey(org.onosproject.net.LinkKey) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) Port(org.onosproject.net.Port) OduCltPort(org.onosproject.net.optical.OduCltPort) OtuPort(org.onosproject.net.optical.OtuPort) OduCltPort(org.onosproject.net.optical.OduCltPort) Resource(org.onosproject.net.resource.Resource) ArrayList(java.util.ArrayList) ConnectPoint(org.onosproject.net.ConnectPoint) LinkedList(java.util.LinkedList) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent)

Example 4 with OduCltPort

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

Example 5 with OduCltPort

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

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