Search in sources :

Example 1 with CltSignalType

use of org.onosproject.net.CltSignalType 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 2 with CltSignalType

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

the class OpticalCircuitIntentCompiler method availableSlotResources.

private List<Resource> availableSlotResources(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) {
    OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(signalType);
    int requestedTsNum = oduSignalType.tributarySlots();
    Set<TributarySlot> commonTributarySlots = findCommonTributarySlotsOnCps(src, dst);
    if (commonTributarySlots.isEmpty()) {
        return Collections.emptyList();
    }
    if (commonTributarySlots.size() < requestedTsNum) {
        return Collections.emptyList();
    }
    Set<TributarySlot> tributarySlots = commonTributarySlots.stream().limit(requestedTsNum).collect(Collectors.toSet());
    final List<ConnectPoint> portsList = ImmutableList.of(src, dst);
    List<Resource> tributarySlotResources = portsList.stream().flatMap(cp -> tributarySlots.stream().map(ts -> Resources.discrete(cp.deviceId(), cp.port()).resource().child(ts))).collect(Collectors.toList());
    if (!tributarySlotResources.stream().allMatch(resourceService::isAvailable)) {
        log.debug("Resource allocation for {} on {} and {} failed (resource request: {})", signalType, src, dst, tributarySlotResources);
        return Collections.emptyList();
    }
    return tributarySlotResources;
}
Also used : Arrays(java.util.Arrays) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) ResourceService(org.onosproject.net.resource.ResourceService) DriverService(org.onosproject.net.driver.DriverService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Pair(org.apache.commons.lang3.tuple.Pair) Port(org.onosproject.net.Port) TributarySlotQuery(org.onosproject.net.behaviour.TributarySlotQuery) ApplicationId(org.onosproject.core.ApplicationId) OchPort(org.onosproject.net.optical.OchPort) Driver(org.onosproject.net.driver.Driver) OduSignalUtils(org.onosproject.net.OduSignalUtils) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Resources(org.onosproject.net.resource.Resources) Deactivate(org.osgi.service.component.annotations.Deactivate) 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) CltSignalType(org.onosproject.net.CltSignalType) List(java.util.List) OduCltPort(org.onosproject.net.optical.OduCltPort) Stream(java.util.stream.Stream) OduSignalId(org.onosproject.net.OduSignalId) FlowRule(org.onosproject.net.flow.FlowRule) IntentCompiler(org.onosproject.net.intent.IntentCompiler) Optional(java.util.Optional) Dictionary(java.util.Dictionary) IntentSetMultimap(org.onosproject.net.intent.IntentSetMultimap) Tools(org.onlab.util.Tools) ComponentContext(org.osgi.service.component.ComponentContext) AnnotationKeys(org.onosproject.net.AnnotationKeys) Strings(com.google.common.base.Strings) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) IntentService(org.onosproject.net.intent.IntentService) Intent(org.onosproject.net.intent.Intent) Activate(org.osgi.service.component.annotations.Activate) Criteria(org.onosproject.net.flow.criteria.Criteria) LinkedList(java.util.LinkedList) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) OduSignalType(org.onosproject.net.OduSignalType) IntentId(org.onosproject.net.intent.IntentId) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PathIntent(org.onosproject.net.intent.PathIntent) Instructions(org.onosproject.net.flow.instructions.Instructions) Logger(org.slf4j.Logger) TributarySlot(org.onosproject.net.TributarySlot) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) MAX_CAPACITY(org.onosproject.net.optical.intent.impl.compiler.OsgiPropertyConstants.MAX_CAPACITY) OpticalDeviceServiceView.opticalView(org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView) Modified(org.osgi.service.component.annotations.Modified) MAX_CAPACITY_DEFAULT(org.onosproject.net.optical.intent.impl.compiler.OsgiPropertyConstants.MAX_CAPACITY_DEFAULT) Reference(org.osgi.service.component.annotations.Reference) Comparator(java.util.Comparator) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Collections(java.util.Collections) OduSignalType(org.onosproject.net.OduSignalType) TributarySlot(org.onosproject.net.TributarySlot) Resource(org.onosproject.net.resource.Resource) ConnectPoint(org.onosproject.net.ConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 3 with CltSignalType

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

Example 4 with CltSignalType

use of org.onosproject.net.CltSignalType 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 5 with CltSignalType

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

the class FujitsuT100DeviceDescription method parseT100OduPort.

private static PortDescription parseT100OduPort(HierarchicalConfiguration cfg, long count) {
    PortNumber portNumber = PortNumber.portNumber(count);
    HierarchicalConfiguration ethernetConfig = cfg.configurationAt("ethernet");
    boolean enabled = "up".equals(ethernetConfig.getString("administrative-state"));
    // Rate is in kbps
    CltSignalType signalType = "100000000".equals(ethernetConfig.getString("rate")) ? CltSignalType.CLT_100GBE : null;
    DefaultAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, cfg.getString("name")).build();
    return oduCltPortDescription(portNumber, enabled, signalType, annotations);
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) CltSignalType(org.onosproject.net.CltSignalType) PortNumber(org.onosproject.net.PortNumber) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration)

Aggregations

CltSignalType (org.onosproject.net.CltSignalType)5 OduCltPort (org.onosproject.net.optical.OduCltPort)4 OduSignalType (org.onosproject.net.OduSignalType)3 Port (org.onosproject.net.Port)3 DeviceService (org.onosproject.net.device.DeviceService)3 Intent (org.onosproject.net.intent.Intent)3 OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)3 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)3 OchPort (org.onosproject.net.optical.OchPort)3 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)2 Device (org.onosproject.net.Device)2 OpticalOduIntent (org.onosproject.net.intent.OpticalOduIntent)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Strings (com.google.common.base.Strings)1 ImmutableList (com.google.common.collect.ImmutableList)1 Sets (com.google.common.collect.Sets)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Comparator (java.util.Comparator)1 Dictionary (java.util.Dictionary)1