Fixing add intent commands.
Use empty treatment if there are not explicit modifications.
Change-Id: I9062c592859adcaf3c9bb17f81de83f2778005de
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 d21321b..9ddbee1 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
@@ -29,6 +29,7 @@
import org.onosproject.core.CoreService;
import org.onosproject.net.Link;
import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.intent.Constraint;
@@ -265,24 +266,33 @@
*/
protected TrafficTreatment buildTrafficTreatment() {
final TrafficTreatment.Builder treatmentBuilder = builder();
+ boolean emptyTreatment = true;
if (!isNullOrEmpty(setEthSrcString)) {
treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString));
+ emptyTreatment = false;
}
if (!isNullOrEmpty(setEthDstString)) {
treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString));
+ emptyTreatment = false;
}
if (!isNullOrEmpty(setIpSrcString)) {
treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString));
+ emptyTreatment = false;
}
if (!isNullOrEmpty(setIpDstString)) {
treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpDstString));
+ emptyTreatment = false;
}
- return treatmentBuilder.build();
+ if (emptyTreatment) {
+ return DefaultTrafficTreatment.emptyTreatment();
+ } else {
+ return treatmentBuilder.build();
+ }
}
/**