use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.
the class OpticalPathProvisioner method createPacketLinkSet.
private Set<PacketLinkRealizedByOptical> createPacketLinkSet(List<Pair<ConnectPoint, ConnectPoint>> connectPoints, List<Intent> intents, Map<ConnectPoint, ConnectPoint> crossConnectPoints) {
checkArgument(connectPoints.size() == intents.size());
Set<PacketLinkRealizedByOptical> pLinks = new HashSet<>();
Iterator<Pair<ConnectPoint, ConnectPoint>> xcPointsItr = connectPoints.iterator();
Iterator<Intent> intentItr = intents.iterator();
while (xcPointsItr.hasNext()) {
Pair<ConnectPoint, ConnectPoint> xcPoints = xcPointsItr.next();
Intent intent = intentItr.next();
ConnectPoint packetSrc = checkNotNull(crossConnectPoints.get(xcPoints.getLeft()));
ConnectPoint packetDst = checkNotNull(crossConnectPoints.get(xcPoints.getRight()));
if (intent instanceof OpticalConnectivityIntent) {
pLinks.add(PacketLinkRealizedByOptical.create(packetSrc, packetDst, (OpticalConnectivityIntent) intent));
} else if (intent instanceof OpticalCircuitIntent) {
pLinks.add(PacketLinkRealizedByOptical.create(packetSrc, packetDst, (OpticalCircuitIntent) intent));
} else {
log.warn("Unexpected intent type: {}", intent.getClass());
}
}
return pLinks;
}
use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.
the class OpticalPathProvisionerTest method testSetupPath.
/**
* Checks setupPath method works.
*/
@Test
public void testSetupPath() {
Bandwidth bandwidth = Bandwidth.bps(100);
Duration latency = Duration.ofMillis(10);
List<Link> links = Stream.of(LINK1, LINK2, LINK3, LINK4, LINK5, LINK6).collect(Collectors.toList());
Path path = new DefaultPath(PROVIDER_ID, links, new ScalarWeight(0));
OpticalConnectivityId cid = target.setupPath(path, bandwidth, latency);
assertNotNull(cid);
// 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());
}
use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.
the class OpticalPathProvisionerTest method testRemoveConnectivity.
/**
* Checks removeConnectivity method works.
*/
@Test
public void testRemoveConnectivity() {
Bandwidth bandwidth = Bandwidth.bps(100);
Duration latency = Duration.ofMillis(10);
OpticalConnectivityId cid = target.setupConnectivity(CP12, CP71, bandwidth, latency);
// Checks intents are withdrawn
assertTrue(target.removeConnectivity(cid));
assertEquals(1, intentService.withdrawn.size());
assertEquals(OpticalConnectivityIntent.class, intentService.withdrawn.get(0).getClass());
OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.withdrawn.get(0);
assertEquals(CP31, connIntent.getSrc());
assertEquals(CP52, connIntent.getDst());
}
use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.
the class OpticalCircuitIntentCompiler method compile.
@Override
public List<Intent> compile(OpticalCircuitIntent intent, List<Intent> installable) {
// Check if ports are OduClt ports
ConnectPoint src = intent.getSrc();
ConnectPoint dst = intent.getDst();
Port srcPort = deviceService.getPort(src.deviceId(), src.port());
Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
checkArgument(srcPort instanceof OduCltPort);
checkArgument(dstPort instanceof OduCltPort);
log.debug("Compiling optical circuit intent between {} and {}", src, dst);
// Release of intent resources here is only a temporary solution for handling the
// case of recompiling due to intent restoration (when intent state is FAILED).
// TODO: try to release intent resources in IntentManager.
resourceService.release(intent.key());
// Check OduClt ports availability
Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
Resource dstPortResource = Resources.discrete(dst.deviceId(), dst.port()).resource();
// If ports are not available, compilation fails
if (!Stream.of(srcPortResource, dstPortResource).allMatch(resourceService::isAvailable)) {
throw new OpticalIntentCompilationException("Ports for the intent are not available. Intent: " + intent);
}
List<Resource> ports = ImmutableList.of(srcPortResource, dstPortResource);
// Check if both devices support multiplexing (usage of TributarySlots)
boolean multiplexingSupported = isMultiplexingSupported(intent.getSrc()) && isMultiplexingSupported(intent.getDst());
OpticalConnectivityIntent connIntent = findOpticalConnectivityIntent(intent.getSrc(), intent.getDst(), intent.getSignalType(), multiplexingSupported);
if (connIntent != null && !multiplexingSupported) {
return compile(intent, src, dst, Optional.of(connIntent), ports, false);
}
// Create optical connectivity intent if needed - no optical intent or not enough slots available
if (connIntent == null) {
return compile(intent, src, dst, Optional.empty(), ports, multiplexingSupported);
}
List<Resource> slots = availableSlotResources(connIntent.getSrc(), connIntent.getDst(), intent.getSignalType());
if (slots.isEmpty()) {
return compile(intent, src, dst, Optional.empty(), ports, true);
}
return compile(intent, src, dst, Optional.of(connIntent), ImmutableList.<Resource>builder().addAll(ports).addAll(slots).build(), false);
}
use of org.onosproject.net.intent.OpticalConnectivityIntent in project onos by opennetworkinglab.
the class OpticalConnectivityIntentCompiler method compile.
@Override
public List<Intent> compile(OpticalConnectivityIntent intent, List<Intent> installable) {
// Check if source and destination are optical OCh ports
ConnectPoint src = intent.getSrc();
ConnectPoint dst = intent.getDst();
checkArgument(deviceService.getPort(src.deviceId(), src.port()) instanceof OchPort);
checkArgument(deviceService.getPort(dst.deviceId(), dst.port()) instanceof OchPort);
List<Resource> resources = new LinkedList<>();
log.debug("Compiling optical connectivity intent between {} and {}", src, dst);
// Release of intent resources here is only a temporary solution for handling the
// case of recompiling due to intent restoration (when intent state is FAILED).
// TODO: try to release intent resources in IntentManager.
resourceService.release(intent.key());
// Check OCh port availability
// If ports are not available, compilation fails
// Else add port to resource reservation list
Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
Resource dstPortResource = Resources.discrete(dst.deviceId(), dst.port()).resource();
if (!Stream.of(srcPortResource, dstPortResource).allMatch(resourceService::isAvailable)) {
log.error("Ports for the intent are not available. Intent: {}", intent);
throw new OpticalIntentCompilationException("Ports for the intent are not available. Intent: " + intent);
}
resources.add(srcPortResource);
resources.add(dstPortResource);
// If there is a suggestedPath, use this path without further checking, otherwise trigger path computation
Stream<Path> paths;
if (intent.suggestedPath().isPresent()) {
paths = Stream.of(intent.suggestedPath().get());
} else {
paths = getOpticalPaths(intent);
}
// Find first path that has the required resources
Optional<Map.Entry<Path, List<OchSignal>>> found = paths.map(path -> Maps.immutableEntry(path, findFirstAvailableLambda(intent, path))).filter(entry -> !entry.getValue().isEmpty()).filter(entry -> convertToResources(entry.getKey(), entry.getValue()).stream().allMatch(resourceService::isAvailable)).findFirst();
// Allocate resources and create optical path intent
if (found.isPresent()) {
log.debug("Suitable lightpath FOUND for intent {}", intent);
resources.addAll(convertToResources(found.get().getKey(), found.get().getValue()));
allocateResources(intent, resources);
OchSignal ochSignal = OchSignal.toFixedGrid(found.get().getValue(), ChannelSpacing.CHL_50GHZ);
return ImmutableList.of(createIntent(intent, found.get().getKey(), ochSignal));
} else {
log.error("Unable to find suitable lightpath for intent {}", intent);
throw new OpticalIntentCompilationException("Unable to find suitable lightpath for intent " + intent);
}
}
Aggregations