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);
}
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);
}
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);
}
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());
}
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());
}
Aggregations