Brian O'Connor

Fixing add intent commands.

Use empty treatment if there are not explicit modifications.

Change-Id: I9062c592859adcaf3c9bb17f81de83f2778005de
...@@ -29,6 +29,7 @@ import org.onosproject.core.ApplicationId; ...@@ -29,6 +29,7 @@ import org.onosproject.core.ApplicationId;
29 import org.onosproject.core.CoreService; 29 import org.onosproject.core.CoreService;
30 import org.onosproject.net.Link; 30 import org.onosproject.net.Link;
31 import org.onosproject.net.flow.DefaultTrafficSelector; 31 import org.onosproject.net.flow.DefaultTrafficSelector;
32 +import org.onosproject.net.flow.DefaultTrafficTreatment;
32 import org.onosproject.net.flow.TrafficSelector; 33 import org.onosproject.net.flow.TrafficSelector;
33 import org.onosproject.net.flow.TrafficTreatment; 34 import org.onosproject.net.flow.TrafficTreatment;
34 import org.onosproject.net.intent.Constraint; 35 import org.onosproject.net.intent.Constraint;
...@@ -265,24 +266,33 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand { ...@@ -265,24 +266,33 @@ public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
265 */ 266 */
266 protected TrafficTreatment buildTrafficTreatment() { 267 protected TrafficTreatment buildTrafficTreatment() {
267 final TrafficTreatment.Builder treatmentBuilder = builder(); 268 final TrafficTreatment.Builder treatmentBuilder = builder();
269 + boolean emptyTreatment = true;
268 270
269 if (!isNullOrEmpty(setEthSrcString)) { 271 if (!isNullOrEmpty(setEthSrcString)) {
270 treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString)); 272 treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString));
273 + emptyTreatment = false;
271 } 274 }
272 275
273 if (!isNullOrEmpty(setEthDstString)) { 276 if (!isNullOrEmpty(setEthDstString)) {
274 treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString)); 277 treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString));
278 + emptyTreatment = false;
275 } 279 }
276 280
277 if (!isNullOrEmpty(setIpSrcString)) { 281 if (!isNullOrEmpty(setIpSrcString)) {
278 treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString)); 282 treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString));
283 + emptyTreatment = false;
279 } 284 }
280 285
281 if (!isNullOrEmpty(setIpDstString)) { 286 if (!isNullOrEmpty(setIpDstString)) {
282 treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpDstString)); 287 treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpDstString));
288 + emptyTreatment = false;
283 } 289 }
284 290
285 - return treatmentBuilder.build(); 291 + if (emptyTreatment) {
292 + return DefaultTrafficTreatment.emptyTreatment();
293 + } else {
294 + return treatmentBuilder.build();
295 + }
286 } 296 }
287 297
288 /** 298 /**
......