Search in sources :

Example 1 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId 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 OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class AddOpticalConnectivityCommand method doExecute.

@Override
protected void doExecute() {
    OpticalPathService opticalPathService = get(OpticalPathService.class);
    ConnectPoint ingress = readConnectPoint(ingressStr);
    ConnectPoint egress = readConnectPoint(egressStr);
    if (ingress == null || egress == null) {
        print("Invalid connect points: %s, %s", ingressStr, egressStr);
        return;
    }
    Bandwidth bandwidth = (bandwidthStr == null || bandwidthStr.isEmpty()) ? null : Bandwidth.bps(Long.valueOf(bandwidthStr));
    print("Trying to setup connectivity between %s and %s.", ingress, egress);
    OpticalConnectivityId id = opticalPathService.setupConnectivity(ingress, egress, bandwidth, null);
    if (id == null) {
        print("Failed. See ONOS log for more details.");
        print(" log:set TRACE org.onosproject.newoptical.OpticalPathProvisioner");
        return;
    }
    // FIXME This is the last chance to know the Optical path ID.
    // there's no other way to know existing Optical Path ID
    print("Optical path ID : %s", id.id());
    log.info("Optical path ID {} for connectivity between {} and {}", id.id(), ingress, egress);
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) OpticalPathService(org.onosproject.newoptical.api.OpticalPathService) Bandwidth(org.onlab.util.Bandwidth) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 3 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class RemoveOpticalConnectivityCommand method doExecute.

@Override
protected void doExecute() {
    OpticalPathService opticalPathService = get(OpticalPathService.class);
    OpticalConnectivityId id = OpticalConnectivityId.of(Long.valueOf(idStr));
    print("Trying to remove connectivity with id %s.", idStr);
    if (opticalPathService.removeConnectivity(id)) {
        print(" -- success");
    } else {
        print(" -- failed");
    }
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) OpticalPathService(org.onosproject.newoptical.api.OpticalPathService)

Example 4 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class OpticalConnectivityTest method testCreate.

/**
 * Checks the construction of OpticalConnectivity object.
 */
@Test
public void testCreate() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    // Mock 3-nodes linear topology
    ConnectPoint cp12 = createConnectPoint(1, 2);
    ConnectPoint cp21 = createConnectPoint(2, 1);
    ConnectPoint cp22 = createConnectPoint(2, 2);
    ConnectPoint cp31 = createConnectPoint(3, 1);
    Link link1 = createLink(cp12, cp21);
    Link link2 = createLink(cp22, cp31);
    List<Link> links = Stream.of(link1, link2).collect(Collectors.toList());
    OpticalConnectivityId cid = OpticalConnectivityId.of(1L);
    OpticalConnectivity oc = new OpticalConnectivity(cid, links, bandwidth, latency, Collections.emptySet(), Collections.emptySet());
    assertNotNull(oc);
    assertEquals(oc.id(), cid);
    assertEquals(oc.links(), links);
    assertEquals(oc.bandwidth(), bandwidth);
    assertEquals(oc.latency(), latency);
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) Duration(java.time.Duration) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) Test(org.junit.Test)

Example 5 with OpticalConnectivityId

use of org.onosproject.newoptical.api.OpticalConnectivityId in project onos by opennetworkinglab.

the class OpticalConnectivityTest method testLinkEstablishedByConnectivityIntent.

/**
 * Checks that isAllRealizingLink(Not)Established works for OpticalConnectivityIntent.
 */
@Test
public void testLinkEstablishedByConnectivityIntent() {
    // Mock 7-nodes linear topology
    ConnectPoint cp12 = createConnectPoint(1, 2);
    ConnectPoint cp21 = createConnectPoint(2, 1);
    ConnectPoint cp22 = createConnectPoint(2, 2);
    ConnectPoint cp31 = createConnectPoint(3, 1);
    ConnectPoint cp32 = createConnectPoint(3, 2);
    ConnectPoint cp41 = createConnectPoint(4, 1);
    ConnectPoint cp42 = createConnectPoint(4, 2);
    ConnectPoint cp51 = createConnectPoint(5, 1);
    ConnectPoint cp52 = createConnectPoint(5, 2);
    ConnectPoint cp61 = createConnectPoint(6, 1);
    ConnectPoint cp62 = createConnectPoint(6, 2);
    ConnectPoint cp71 = createConnectPoint(7, 1);
    Link link1 = createLink(cp12, cp21);
    Link link2 = createLink(cp22, cp31);
    Link link3 = createLink(cp32, cp41);
    Link link4 = createLink(cp42, cp51);
    Link link5 = createLink(cp52, cp61);
    Link link6 = createLink(cp62, cp71);
    List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList());
    // Mocks 2 intents to create OduCtl connectivity
    OpticalConnectivityIntent connIntent1 = createConnectivityIntent(cp21, cp32);
    PacketLinkRealizedByOptical oduLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, connIntent1);
    OpticalConnectivityIntent connIntent2 = createConnectivityIntent(cp51, cp62);
    PacketLinkRealizedByOptical oduLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, connIntent2);
    Set<PacketLinkRealizedByOptical> plinks = ImmutableSet.of(oduLink1, oduLink2);
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    OpticalConnectivityId cid = OpticalConnectivityId.of(1L);
    OpticalConnectivity oc1 = new OpticalConnectivity(cid, links, bandwidth, latency, plinks, Collections.emptySet());
    assertTrue(oc1.isAllRealizingLinkNotEstablished());
    assertFalse(oc1.isAllRealizingLinkEstablished());
    // Sets link realized by connIntent1 to be established
    OpticalConnectivity oc2 = oc1.setLinkEstablished(cp12, cp41, true);
    assertFalse(oc2.isAllRealizingLinkNotEstablished());
    assertFalse(oc2.isAllRealizingLinkEstablished());
    // Sets link realized by connIntent2 to be established
    OpticalConnectivity oc3 = oc2.setLinkEstablished(cp42, cp71, true);
    assertFalse(oc3.isAllRealizingLinkNotEstablished());
    assertTrue(oc3.isAllRealizingLinkEstablished());
}
Also used : OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Duration(java.time.Duration) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) Test(org.junit.Test)

Aggregations

OpticalConnectivityId (org.onosproject.newoptical.api.OpticalConnectivityId)17 Bandwidth (org.onlab.util.Bandwidth)14 Duration (java.time.Duration)12 Test (org.junit.Test)11 Link (org.onosproject.net.Link)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 DefaultLink (org.onosproject.net.DefaultLink)5 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)5 Path (org.onosproject.net.Path)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ScalarWeight (org.onlab.graph.ScalarWeight)2 OpticalCircuitIntent (org.onosproject.net.intent.OpticalCircuitIntent)2 OpticalPathService (org.onosproject.newoptical.api.OpticalPathService)2 Beta (com.google.common.annotations.Beta)1 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableList (com.google.common.collect.ImmutableList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1