Search in sources :

Example 6 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 7 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 8 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)

Example 9 with OchPort

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

Example 10 with OchPort

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

the class OpticalConnectivityIntentCompiler method compile.

@Override
public List<Intent> compile(OpticalConnectivityIntent intent, List<Intent> installable) {
    // Check if source and destination are optical OCh ports
    ConnectPoint src = intent.getSrc();
    ConnectPoint dst = intent.getDst();
    checkArgument(deviceService.getPort(src.deviceId(), src.port()) instanceof OchPort);
    checkArgument(deviceService.getPort(dst.deviceId(), dst.port()) instanceof OchPort);
    List<Resource> resources = new LinkedList<>();
    log.debug("Compiling optical connectivity 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 OCh port availability
    // If ports are not available, compilation fails
    // Else add port to resource reservation list
    Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
    Resource dstPortResource = Resources.discrete(dst.deviceId(), dst.port()).resource();
    if (!Stream.of(srcPortResource, dstPortResource).allMatch(resourceService::isAvailable)) {
        log.error("Ports for the intent are not available. Intent: {}", intent);
        throw new OpticalIntentCompilationException("Ports for the intent are not available. Intent: " + intent);
    }
    resources.add(srcPortResource);
    resources.add(dstPortResource);
    // If there is a suggestedPath, use this path without further checking, otherwise trigger path computation
    Stream<Path> paths;
    if (intent.suggestedPath().isPresent()) {
        paths = Stream.of(intent.suggestedPath().get());
    } else {
        paths = getOpticalPaths(intent);
    }
    // Find first path that has the required resources
    Optional<Map.Entry<Path, List<OchSignal>>> found = paths.map(path -> Maps.immutableEntry(path, findFirstAvailableLambda(intent, path))).filter(entry -> !entry.getValue().isEmpty()).filter(entry -> convertToResources(entry.getKey(), entry.getValue()).stream().allMatch(resourceService::isAvailable)).findFirst();
    // Allocate resources and create optical path intent
    if (found.isPresent()) {
        log.debug("Suitable lightpath FOUND for intent {}", intent);
        resources.addAll(convertToResources(found.get().getKey(), found.get().getValue()));
        allocateResources(intent, resources);
        OchSignal ochSignal = OchSignal.toFixedGrid(found.get().getValue(), ChannelSpacing.CHL_50GHZ);
        return ImmutableList.of(createIntent(intent, found.get().getKey(), ochSignal));
    } else {
        log.error("Unable to find suitable lightpath for intent {}", intent);
        throw new OpticalIntentCompilationException("Unable to find suitable lightpath for intent " + intent);
    }
}
Also used : Path(org.onosproject.net.Path) DefaultPath(org.onosproject.net.DefaultPath) DefaultOchSignalComparator(org.onosproject.net.DefaultOchSignalComparator) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) TopologyService(org.onosproject.net.topology.TopologyService) Link(org.onosproject.net.Link) ResourceService(org.onosproject.net.resource.ResourceService) ConnectPoint(org.onosproject.net.ConnectPoint) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Topology(org.onosproject.net.topology.Topology) Port(org.onosproject.net.Port) Map(java.util.Map) OchPort(org.onosproject.net.optical.OchPort) DefaultLink(org.onosproject.net.DefaultLink) OchSignalType(org.onosproject.net.OchSignalType) ImmutableSet(com.google.common.collect.ImmutableSet) Resources(org.onosproject.net.resource.Resources) Deactivate(org.osgi.service.component.annotations.Deactivate) OpticalPathIntent(org.onosproject.net.intent.OpticalPathIntent) Collection(java.util.Collection) Set(java.util.Set) Resource(org.onosproject.net.resource.Resource) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ResourceAllocation(org.onosproject.net.resource.ResourceAllocation) List(java.util.List) Stream(java.util.stream.Stream) Annotations(org.onosproject.net.Annotations) IntentCompiler(org.onosproject.net.intent.IntentCompiler) Optional(java.util.Optional) Path(org.onosproject.net.Path) ChannelSpacing(org.onosproject.net.ChannelSpacing) DeviceId(org.onosproject.net.DeviceId) IntStream(java.util.stream.IntStream) GridType(org.onosproject.net.GridType) TopologyEdge(org.onosproject.net.topology.TopologyEdge) AnnotationKeys(org.onosproject.net.AnnotationKeys) ArrayList(java.util.ArrayList) Component(org.osgi.service.component.annotations.Component) ImmutableList(com.google.common.collect.ImmutableList) DefaultPath(org.onosproject.net.DefaultPath) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) LinkedList(java.util.LinkedList) Logger(org.slf4j.Logger) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) ProviderId(org.onosproject.net.provider.ProviderId) Maps(com.google.common.collect.Maps) OchSignal(org.onosproject.net.OchSignal) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Weight(org.onlab.graph.Weight) OpticalDeviceServiceView.opticalView(org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView) LinkWeigher(org.onosproject.net.topology.LinkWeigher) Reference(org.osgi.service.component.annotations.Reference) ScalarWeight(org.onlab.graph.ScalarWeight) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Collections(java.util.Collections) Resource(org.onosproject.net.resource.Resource) OchSignal(org.onosproject.net.OchSignal) ConnectPoint(org.onosproject.net.ConnectPoint) OchPort(org.onosproject.net.optical.OchPort) LinkedList(java.util.LinkedList)

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