Search in sources :

Example 1 with Bandwidth

use of org.onlab.util.Bandwidth 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 Bandwidth

use of org.onlab.util.Bandwidth 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 Bandwidth

use of org.onlab.util.Bandwidth 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 4 with Bandwidth

use of org.onlab.util.Bandwidth 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)

Example 5 with Bandwidth

use of org.onlab.util.Bandwidth in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testSetupConnectivity.

/**
 * Checks setupConnectivity method works.
 */
@Test
public void testSetupConnectivity() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency);
    assertNotNull(cid);
    // Checks path computation is called as expected
    assertEquals(1, topologyService.edges.size());
    assertEquals(CP12.deviceId(), topologyService.edges.get(0).getKey());
    assertEquals(CP71.deviceId(), topologyService.edges.get(0).getValue());
    // 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 : 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)

Aggregations

Bandwidth (org.onlab.util.Bandwidth)24 Test (org.junit.Test)15 OpticalConnectivityId (org.onosproject.newoptical.api.OpticalConnectivityId)14 Duration (java.time.Duration)12 ConnectPoint (org.onosproject.net.ConnectPoint)10 Link (org.onosproject.net.Link)6 DefaultLink (org.onosproject.net.DefaultLink)5 Key (org.onosproject.net.intent.Key)5 OpticalConnectivityIntent (org.onosproject.net.intent.OpticalConnectivityIntent)5 ContinuousResource (org.onosproject.net.resource.ContinuousResource)5 Path (org.onosproject.net.Path)4 Constraint (org.onosproject.net.intent.Constraint)4 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)4 ResourceAllocation (org.onosproject.net.resource.ResourceAllocation)4 ResourceService (org.onosproject.net.resource.ResourceService)4 List (java.util.List)3 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)3 MockResourceService (org.onosproject.net.resource.MockResourceService)3 ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2