Search in sources :

Example 16 with OpticalConnectivityIntent

use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.

the class OpticalPathProvisioner method createPacketLinkSet.

private Set<PacketLinkRealizedByOptical> createPacketLinkSet(List<Pair<ConnectPoint, ConnectPoint>> connectPoints, List<Intent> intents, Map<ConnectPoint, ConnectPoint> crossConnectPoints) {
    checkArgument(connectPoints.size() == intents.size());
    Set<PacketLinkRealizedByOptical> pLinks = new HashSet<>();
    Iterator<Pair<ConnectPoint, ConnectPoint>> xcPointsItr = connectPoints.iterator();
    Iterator<Intent> intentItr = intents.iterator();
    while (xcPointsItr.hasNext()) {
        Pair<ConnectPoint, ConnectPoint> xcPoints = xcPointsItr.next();
        Intent intent = intentItr.next();
        ConnectPoint packetSrc = checkNotNull(crossConnectPoints.get(xcPoints.getLeft()));
        ConnectPoint packetDst = checkNotNull(crossConnectPoints.get(xcPoints.getRight()));
        if (intent instanceof OpticalConnectivityIntent) {
            pLinks.add(PacketLinkRealizedByOptical.create(packetSrc, packetDst, (OpticalConnectivityIntent) intent));
        } else if (intent instanceof OpticalCircuitIntent) {
            pLinks.add(PacketLinkRealizedByOptical.create(packetSrc, packetDst, (OpticalCircuitIntent) intent));
        } else {
            log.warn("Unexpected intent type: {}", intent.getClass());
        }
    }
    return pLinks;
}
Also used : 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) HashSet(java.util.HashSet) Pair(org.apache.commons.lang3.tuple.Pair)

Example 17 with OpticalConnectivityIntent

use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testSetupPath.

/**
 * Checks setupPath method works.
 */
@Test
public void testSetupPath() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    List<Link> links = Stream.of(LINK1, LINK2, LINK3, LINK4, LINK5, LINK6).collect(Collectors.toList());
    Path path = new DefaultPath(PROVIDER_ID, links, new ScalarWeight(0));
    OpticalConnectivityId cid = target.setupPath(path, bandwidth, latency);
    assertNotNull(cid);
    // Checks intents are installed as expected
    assertEquals(1, intentService.submitted.size());
    assertEquals(OpticalConnectivityIntent.class, intentService.submitted.get(0).getClass());
    OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.submitted.get(0);
    assertEquals(CP31, connIntent.getSrc());
    assertEquals(CP52, connIntent.getDst());
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Duration(java.time.Duration) DefaultPath(org.onosproject.net.DefaultPath) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link) ScalarWeight(org.onlab.graph.ScalarWeight) Test(org.junit.Test)

Example 18 with OpticalConnectivityIntent

use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testRemoveConnectivity.

/**
 * Checks removeConnectivity method works.
 */
@Test
public void testRemoveConnectivity() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency);
    // Checks intents are withdrawn
    assertTrue(target.removeConnectivity(cid));
    assertEquals(1, intentService.withdrawn.size());
    assertEquals(OpticalConnectivityIntent.class, intentService.withdrawn.get(0).getClass());
    OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.withdrawn.get(0);
    assertEquals(CP31, connIntent.getSrc());
    assertEquals(CP52, connIntent.getDst());
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Duration(java.time.Duration) Test(org.junit.Test)

Example 19 with OpticalConnectivityIntent

use of org.onosproject.net.intent.OpticalConnectivityIntent 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 20 with OpticalConnectivityIntent

use of org.onosproject.net.intent.OpticalConnectivityIntent 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

OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)20 ConnectPoint (org.onosproject.net.ConnectPoint)13 Intent (org.onosproject.net.intent.Intent)12 Link (org.onosproject.net.Link)10 ArrayList (java.util.ArrayList)7 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)7 List (java.util.List)6 OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)6 LinkedList (java.util.LinkedList)5 Collectors (java.util.stream.Collectors)5 Test (org.junit.Test)5 DefaultPath (org.onosproject.net.DefaultPath)5 IntentService (org.onosproject.net.intent.IntentService)5 OchPort (org.onosproject.net.optical.OchPort)5 ImmutableList (com.google.common.collect.ImmutableList)4 Duration (java.time.Duration)4 Set (java.util.Set)4 ScalarWeight (org.onlab.graph.ScalarWeight)4 Bandwidth (org.onlab.util.Bandwidth)4 DefaultLink (org.onosproject.net.DefaultLink)4