ONOS-5808: Allocate BW from ConnectivityIntentCompiler and unit tests for partial failure
Change-Id: I2eb3c16efbce619db6d0d2ba415a35752a61ece4
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
index 3b4dca9..7e6cf3d 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java
@@ -38,6 +38,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static org.onosproject.net.intent.constraint.PartialFailureConstraint.intentAllowsPartialFailure;
@@ -85,7 +87,7 @@
continue;
}
- Path path = getPath(intent, ingressPoint.deviceId(), intent.egressPoint().deviceId());
+ Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId());
if (path != null) {
hasPaths = true;
@@ -106,6 +108,23 @@
}
}
+ // Allocate bandwidth on existing paths if a bandwidth constraint is set
+ List<ConnectPoint> ingressCPs =
+ intent.filteredIngressPoints().stream()
+ .map(fcp -> fcp.connectPoint())
+ .collect(Collectors.toList());
+ ConnectPoint egressCP = intent.filteredEgressPoint().connectPoint();
+
+ List<ConnectPoint> pathCPs =
+ links.values().stream()
+ .flatMap(l -> Stream.of(l.src(), l.dst()))
+ .collect(Collectors.toList());
+
+ pathCPs.addAll(ingressCPs);
+ pathCPs.add(egressCP);
+
+ allocateBandwidth(intent, pathCPs);
+
if (!hasPaths) {
throw new IntentException("Cannot find any path between ingress and egress points.");
} else if (!allowMissingPaths && missingSomePaths) {