Moved CLI options for rewrite actions up to ConnectivityIntentCommand so they
can be used by all connectivity intent commands.
Change-Id: I6cd6b05423479d53313c92491ab636ebd58def43
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/ConnectivityIntentCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/ConnectivityIntentCommand.java
index d1426e2..add9cd3 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/ConnectivityIntentCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/ConnectivityIntentCommand.java
@@ -23,6 +23,7 @@
import org.onlab.onos.net.Link;
import org.onlab.onos.net.flow.DefaultTrafficSelector;
import org.onlab.onos.net.flow.TrafficSelector;
+import org.onlab.onos.net.flow.TrafficTreatment;
import org.onlab.onos.net.intent.Constraint;
import org.onlab.onos.net.intent.constraint.BandwidthConstraint;
import org.onlab.onos.net.intent.constraint.LambdaConstraint;
@@ -33,12 +34,14 @@
import org.onlab.packet.MacAddress;
import static com.google.common.base.Strings.isNullOrEmpty;
+import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
/**
* Base class for command line operations for connectivity based intents.
*/
public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
+ // Selectors
@Option(name = "-s", aliases = "--ethSrc", description = "Source MAC Address",
required = false, multiValued = false)
private String srcMacString = null;
@@ -79,6 +82,16 @@
required = false, multiValued = false)
private boolean lambda = false;
+
+ // Treatments
+ @Option(name = "--setEthSrc", description = "Rewrite Source MAC Address",
+ required = false, multiValued = false)
+ private String setEthSrcString = null;
+
+ @Option(name = "--setEthDst", description = "Rewrite Destination MAC Address",
+ required = false, multiValued = false)
+ private String setEthDstString = null;
+
/**
* Constructs a traffic selector based on the command line arguments
* presented to the command.
@@ -126,6 +139,26 @@
}
/**
+ * Generates a traffic treatment for this intent based on command line
+ * arguments presented to the command.
+ *
+ * @return traffic treatment
+ */
+ protected TrafficTreatment buildTrafficTreatment() {
+ final TrafficTreatment.Builder builder = builder();
+
+ if (!isNullOrEmpty(setEthSrcString)) {
+ final MacAddress setEthSrc = MacAddress.valueOf(setEthSrcString);
+ builder.setEthSrc(setEthSrc);
+ }
+ if (!isNullOrEmpty(setEthDstString)) {
+ final MacAddress setEthDst = MacAddress.valueOf(setEthDstString);
+ builder.setEthDst(setEthDst);
+ }
+ return builder.build();
+ }
+
+ /**
* Builds the constraint list for this command based on the command line
* parameters.
*