Search in sources :

Example 1 with Path

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

the class OpticalPathProvisioner method setupConnectivity.

/*
     * Request packet-layer connectivity between specified ports,
     * over packet-optical multi-layer infrastructure.
     *
     * Functionality-wise this is effectively submitting Packet-Optical
     * multi-layer P2P Intent.
     *
     * It computes multi-layer path meeting specified constraint,
     * and calls setupPath.
     */
@Override
public OpticalConnectivityId setupConnectivity(ConnectPoint ingress, ConnectPoint egress, Bandwidth bandwidth, Duration latency) {
    checkNotNull(ingress);
    checkNotNull(egress);
    log.info("setupConnectivity({}, {}, {}, {})", ingress, egress, bandwidth, latency);
    Bandwidth bw = (bandwidth == null) ? NO_BW_REQUIREMENT : bandwidth;
    Stream<Path> paths = topologyService.getKShortestPaths(topologyService.currentTopology(), ingress.deviceId(), egress.deviceId(), new BandwidthLinkWeight(bandwidth));
    // Path service calculates from node to node, we're only interested in port to port
    Optional<OpticalConnectivityId> id = paths.filter(p -> p.src().equals(ingress) && p.dst().equals(egress)).limit(maxPaths).map(p -> setupPath(p, bw, latency)).filter(Objects::nonNull).findFirst();
    if (id.isPresent()) {
        log.info("Assigned OpticalConnectivityId: {}", id);
    } else {
        log.error("setupConnectivity({}, {}, {}, {}) failed.", ingress, egress, bandwidth, latency);
    }
    return id.orElse(null);
}
Also used : Path(org.onosproject.net.Path) OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth)

Example 2 with Path

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

the class GnpyManager method obtainConnectivity.

@Override
public Pair<IntentId, Double> obtainConnectivity(ConnectPoint ingress, ConnectPoint egress, boolean bidirectional) {
    ByteArrayOutputStream connectivityRequest = createGnpyRequest(ingress, egress, bidirectional);
    String response = gnpyHttpUtil.post(null, "/gnpy-experimental", new ByteArrayInputStream(connectivityRequest.toByteArray()), MediaType.APPLICATION_JSON_TYPE, String.class);
    ObjectMapper om = new ObjectMapper();
    final ObjectReader reader = om.reader();
    JsonNode jsonNode;
    try {
        jsonNode = reader.readTree(response);
        if (jsonNode == null) {
            log.error("JsonNode is null for response {}", response);
            return null;
        }
        log.info("Response {}", response);
        String bestPath;
        try {
            bestPath = getBestOsnrPathKey(jsonNode);
        } catch (IllegalStateException e) {
            log.error("Exception while contacting GNPy", e);
            return null;
        }
        OchSignal ochSignal = createOchSignal(jsonNode);
        Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
        Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
        // TODO this list is currently only populated in the forward direction
        List<DeviceId> deviceIds = getDeviceAndPopulatePowerMap(jsonNode, deviceAtoBPowerMap, deviceBtoAPowerMap, bestPath);
        Path suggestedPath = createSuggestedPath(deviceIds);
        log.info("Suggested path {}", suggestedPath);
        Intent intent = createOpticalIntent(ingress, egress, deviceService, null, appId, bidirectional, ochSignal, suggestedPath);
        intentsPowerMap.put(intent.id(), new GnpyPowerInfo(deviceAtoBPowerMap, deviceBtoAPowerMap, getLaunchPower(jsonNode), suggestedPath.links(), ingress, egress, ochSignal));
        intentService.submit(intent);
        return Pair.of(intent.id(), getOsnr(jsonNode, bestPath));
    } catch (IOException e) {
        log.error("Exception while reading response {}", response, e);
        return null;
    }
}
Also used : Path(org.onosproject.net.Path) DefaultPath(org.onosproject.net.DefaultPath) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) OchSignal(org.onosproject.net.OchSignal) JsonNode(com.fasterxml.jackson.databind.JsonNode) OpticalIntentUtility.createOpticalIntent(org.onosproject.net.optical.util.OpticalIntentUtility.createOpticalIntent) Intent(org.onosproject.net.intent.Intent) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with Path

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

the class GnpyManagerTest method testCreateSuggestedPath.

@Test
public void testCreateSuggestedPath() throws IOException {
    Map<DeviceId, Double> deviceAtoBPowerMap = new HashMap<>();
    Map<DeviceId, Double> deviceBtoAPowerMap = new HashMap<>();
    List<DeviceId> deviceIds = manager.getDeviceAndPopulatePowerMap(reply, deviceAtoBPowerMap, deviceBtoAPowerMap, "second");
    Path path = manager.createSuggestedPath(deviceIds);
    assertTrue(path.links().contains(tx1rdm1Link));
    assertTrue(path.links().contains(rmd1ln1Link));
    assertTrue(path.links().contains(ln1ln2Link));
    assertTrue(path.links().contains(ln2rdm2Link));
    assertTrue(path.links().contains(tx2rmd2Link));
    assertEquals(path.src(), tx2);
    assertEquals(path.dst(), tx1);
}
Also used : Path(org.onosproject.net.Path) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) Test(org.junit.Test)

Example 4 with Path

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

the class ReactiveForwarding method fixBlackhole.

private void fixBlackhole(ConnectPoint egress) {
    Set<FlowEntry> rules = getFlowRulesFrom(egress);
    Set<SrcDstPair> pairs = findSrcDstPairs(rules);
    Map<DeviceId, Set<Path>> srcPaths = new HashMap<>();
    for (SrcDstPair sd : pairs) {
        // get the edge deviceID for the src host
        Host srcHost = hostService.getHost(HostId.hostId(sd.src));
        Host dstHost = hostService.getHost(HostId.hostId(sd.dst));
        if (srcHost != null && dstHost != null) {
            DeviceId srcId = srcHost.location().deviceId();
            DeviceId dstId = dstHost.location().deviceId();
            log.trace("SRC ID is {}, DST ID is {}", srcId, dstId);
            cleanFlowRules(sd, egress.deviceId());
            Set<Path> shortestPaths = srcPaths.get(srcId);
            if (shortestPaths == null) {
                shortestPaths = topologyService.getPaths(topologyService.currentTopology(), egress.deviceId(), srcId);
                srcPaths.put(srcId, shortestPaths);
            }
            backTrackBadNodes(shortestPaths, dstId, sd);
        }
    }
}
Also used : Path(org.onosproject.net.Path) Set(java.util.Set) ImmutableSet(com.google.common.collect.ImmutableSet) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) Host(org.onosproject.net.Host) FlowEntry(org.onosproject.net.flow.FlowEntry)

Example 5 with Path

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

the class OpticalConnectivityIntentCompiler method findFirstAvailableLambda.

/**
 * Find the first available lambda on the given path by checking all the port resources.
 *
 * @param path the path
 * @return list of consecutive and available OChSignals
 */
private List<OchSignal> findFirstAvailableLambda(OpticalConnectivityIntent intent, Path path) {
    if (intent.ochSignal().isPresent()) {
        // create lambdas w.r.t. slotGanularity/slotWidth
        OchSignal ochSignal = intent.ochSignal().get();
        if (ochSignal.gridType() == GridType.FLEX) {
            // multiplier sits in the middle of slots
            int startMultiplier = ochSignal.spacingMultiplier() - (ochSignal.slotGranularity() / 2);
            return IntStream.range(0, ochSignal.slotGranularity()).mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x))).collect(Collectors.toList());
        } else if (ochSignal.gridType() == GridType.DWDM) {
            int startMultiplier = (int) (1 - ochSignal.slotGranularity() + ochSignal.spacingMultiplier() * ochSignal.channelSpacing().frequency().asHz() / ChannelSpacing.CHL_6P25GHZ.frequency().asHz());
            return IntStream.range(0, ochSignal.slotGranularity()).mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x))).collect(Collectors.toList());
        }
        // TODO: add support for other gridTypes
        log.error("Grid type: {} not supported for user defined signal intents", ochSignal.gridType());
        return Collections.emptyList();
    }
    Set<OchSignal> lambdas = findCommonLambdas(path);
    if (lambdas.isEmpty()) {
        return Collections.emptyList();
    }
    return findFirstLambda(lambdas, slotCount());
}
Also used : 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) OchSignal(org.onosproject.net.OchSignal) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

Path (org.onosproject.net.Path)48 DisjointPath (org.onosproject.net.DisjointPath)22 DefaultPath (org.onosproject.net.DefaultPath)19 DeviceId (org.onosproject.net.DeviceId)19 Test (org.junit.Test)16 Link (org.onosproject.net.Link)14 ConnectPoint (org.onosproject.net.ConnectPoint)13 ImmutableSet (com.google.common.collect.ImmutableSet)10 Intent (org.onosproject.net.intent.Intent)10 Topology (org.onosproject.net.topology.Topology)10 Set (java.util.Set)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 Collectors (java.util.stream.Collectors)8 Collections (java.util.Collections)7 Stream (java.util.stream.Stream)7 ScalarWeight (org.onlab.graph.ScalarWeight)7 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)7 Activate (org.osgi.service.component.annotations.Activate)7 Component (org.osgi.service.component.annotations.Component)7