use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.
the class OpticalPathProvisioner method createIntents.
/**
* Scans the list of cross connection points and returns a list of optical connectivity intents.
* During the process, save information about packet links to given set.
*
* @param crossConnectPoints list of (src, dst) pair between which optical path will be set up
* @return list of optical connectivity intents
*/
private List<Intent> createIntents(List<Pair<ConnectPoint, ConnectPoint>> crossConnectPoints) {
List<Intent> intents = new LinkedList<>();
Iterator<Pair<ConnectPoint, ConnectPoint>> itr = crossConnectPoints.iterator();
while (itr.hasNext()) {
// checkArgument at start ensures we'll always have pairs of connect points
Pair<ConnectPoint, ConnectPoint> next = itr.next();
ConnectPoint src = next.getLeft();
ConnectPoint dst = next.getRight();
Port srcPort = deviceService.getPort(src.deviceId(), src.port());
Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
OduCltPort srcOCPort = (OduCltPort) srcPort;
OduCltPort dstOCPort = (OduCltPort) dstPort;
if (!srcOCPort.signalType().equals(dstOCPort.signalType())) {
continue;
}
// Create OTN circuit
OpticalCircuitIntent circuitIntent = OpticalCircuitIntent.builder().appId(appId).src(src).dst(dst).signalType(srcOCPort.signalType()).bidirectional(false).build();
intents.add(circuitIntent);
} else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
OchPort srcOchPort = (OchPort) srcPort;
OchPort dstOchPort = (OchPort) dstPort;
if (!srcOchPort.signalType().equals(dstOchPort.signalType())) {
continue;
}
// Create lightpath
OpticalConnectivityIntent opticalIntent = OpticalConnectivityIntent.builder().appId(appId).src(src).dst(dst).signalType(srcOchPort.signalType()).bidirectional(false).build();
intents.add(opticalIntent);
} else {
log.warn("Unsupported cross connect point types {} {}", srcPort.type(), dstPort.type());
return Collections.emptyList();
}
}
return intents;
}
use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.
the class OpticalPathProvisioner method setupPath.
/*
* Given a multi-layer path,
* compute a set of segments which requires
* OpticalConnectivity(~=OpticalConnectivityIntent or OpticalCircuitPath)
* to provide packet-layer connectivity.
*/
@Override
public OpticalConnectivityId setupPath(Path path, Bandwidth bandwidth, Duration latency) {
checkNotNull(path);
log.debug("setupPath({}, {}, {})", path, bandwidth, latency);
// map of cross connect points (optical port -> packet port)
Map<ConnectPoint, ConnectPoint> crossConnectPointMap = new HashMap<>();
// list of (src, dst) pair of optical ports between which optical path should be installed
List<Pair<ConnectPoint, ConnectPoint>> crossConnectPoints = new ArrayList<>();
// Scan path to find pairs of connect points between which optical intent is installed
// opticalSrcPort works as a flag parameter to show scanning status
ConnectPoint opticalSrcPort = null;
for (Link link : path.links()) {
if (!isCrossConnectLink(link)) {
continue;
}
if (opticalSrcPort != null) {
// opticalSrcPort!=null means src port was already found
// in this case link.src() is optical layer, and link.dst() is packet layer
// Check if types of src port and dst port matches
Device srcDevice = checkNotNull(deviceService.getDevice(opticalSrcPort.deviceId()), "Unknown device ID");
Device dstDevice = checkNotNull(deviceService.getDevice(link.src().deviceId()), "Unknown device ID");
if (srcDevice.type() != dstDevice.type()) {
log.error("Unsupported mix of cross connect points : {}, {}", srcDevice.type(), dstDevice.type());
return null;
}
// Update cross connect points map
crossConnectPointMap.put(link.src(), link.dst());
// Add optical ports pair to list
crossConnectPoints.add(Pair.of(opticalSrcPort, link.src()));
// Reset flag parameter
opticalSrcPort = null;
} else {
// opticalSrcPort==null means src port was not found yet
// in this case link.src() is packet layer, and link.dst() is optical layer
// Update cross connect points map
crossConnectPointMap.put(link.dst(), link.src());
// Set opticalSrcPort to src of link (optical port)
opticalSrcPort = link.dst();
}
}
// create intents from cross connect points
List<Intent> intents = createIntents(crossConnectPoints);
if (intents.isEmpty()) {
log.error("No intents produced from {}", crossConnectPoints);
return null;
}
// create set of PacketLinkRealizedByOptical
Set<PacketLinkRealizedByOptical> packetLinks = createPacketLinkSet(crossConnectPoints, intents, crossConnectPointMap);
// create OpticalConnectivity object and store information to distributed store
OpticalConnectivity connectivity = createConnectivity(path, bandwidth, latency, packetLinks);
// store cross connect port usage
path.links().stream().filter(this::isCrossConnectLink).forEach(usedCrossConnectLinkSet::add);
// Submit the intents
for (Intent i : intents) {
intentService.submit(i);
log.debug("Submitted an intent: {}", i);
}
return connectivity.id();
}
use of org.onosproject.net.intent.OpticalConnectivityIntent 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.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.
the class PacketLinkRealizedByOpticalTest method testCreateWithConnectivityIntent.
/**
* Checks the construction of OpticalConnectivityId object with OpticalConnectivityIntent.
*/
@Test
public void testCreateWithConnectivityIntent() {
ConnectPoint cp1 = new ConnectPoint(DeviceId.deviceId("of:0000000000000001"), PortNumber.portNumber(1L));
ConnectPoint cp2 = new ConnectPoint(DeviceId.deviceId("of:0000000000000002"), PortNumber.portNumber(2L));
OpticalConnectivityIntent connIntent = OpticalConnectivityIntent.builder().appId(appId).src(cp1).dst(cp2).bidirectional(true).key(Key.of(0, appId)).signalType(OduSignalType.ODU4).build();
PacketLinkRealizedByOptical plink = PacketLinkRealizedByOptical.create(cp1, cp2, connIntent);
assertNotNull(plink);
assertEquals(plink.src(), cp1);
assertEquals(plink.dst(), cp2);
assertEquals((long) plink.bandwidth().bps(), OduSignalType.ODU4.bitRate());
}
use of org.onosproject.net.intent.OpticalConnectivityIntent 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