Fixes for resource-related test CLI commands:
- Tweak to assumptions in base command for ConnectivityIntents
- Check before casting between port types
Change-Id: I5db84ec435029f2de84abb0f3f5ddc726035bf1b
diff --git a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
index 2e88c3a..96fc72e 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
@@ -115,7 +115,7 @@
@Option(name = "-l", aliases = "--lambda", description = "Lambda",
required = false, multiValued = false)
- private boolean lambda = false;
+ private Boolean lambda = null;
@Option(name = "-a", aliases = "--appId", description = "Application Id",
required = false, multiValued = false)
@@ -189,7 +189,7 @@
// Set the default EthType based on the IP version if the matching
// source or destination IP prefixes.
//
- short ethType = EthType.IPV4.value();
+ Short ethType = null;
if ((srcIpPrefix != null) && srcIpPrefix.isIp6()) {
ethType = EthType.IPV6.value();
}
@@ -199,8 +199,9 @@
if (!isNullOrEmpty(ethTypeString)) {
ethType = EthType.parseFromString(ethTypeString);
}
- selectorBuilder.matchEthType(ethType);
-
+ if (ethType != null) {
+ selectorBuilder.matchEthType(ethType);
+ }
if (!isNullOrEmpty(srcMacString)) {
selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString));
}
@@ -312,11 +313,12 @@
}
// Check for a lambda specification
- if (lambda) {
- constraints.add(new LambdaConstraint(null));
+ if (lambda != null) {
+ if (lambda) {
+ constraints.add(new LambdaConstraint(null));
+ }
+ constraints.add(new LinkTypeConstraint(lambda, Link.Type.OPTICAL));
}
- constraints.add(new LinkTypeConstraint(lambda, Link.Type.OPTICAL));
-
return constraints;
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
index 74ec8f7..af9a07e 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
@@ -24,6 +24,7 @@
import org.onlab.util.PositionalParameterStringFormatter;
import org.onosproject.net.Link;
import org.onosproject.net.LinkKey;
+import org.onosproject.net.Port;
import org.onosproject.net.intent.IntentId;
import org.onosproject.net.link.LinkService;
import org.onosproject.net.resource.link.BandwidthResource;
@@ -140,14 +141,15 @@
private Set<LambdaResourceAllocation> getLambdaResourceCapacity(Link link) {
Set<LambdaResourceAllocation> allocations = new HashSet<>();
+ Port port = deviceService.getPort(link.src().deviceId(), link.src().port());
+ if (port instanceof OmsPort) {
+ OmsPort omsPort = (OmsPort) port;
- OmsPort port = (OmsPort) deviceService.getPort(link.src().deviceId(), link.src().port());
-
- // Assume fixed grid for now
- for (int i = 0; i < port.totalChannels(); i++) {
- allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
+ // Assume fixed grid for now
+ for (int i = 0; i < omsPort.totalChannels(); i++) {
+ allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i)));
+ }
}
-
return allocations;
}