Add L2 selector options to connectivity intents

Added --etherType, --etherSrc, and --etherDst to
PointToPointIntent and MultiPontToSinglePointIntent
creation in the ONOS CLI.

Change-Id: Ibccd3c0b331e7f89be6903f264a6889ac1ad5f17
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
new file mode 100644
index 0000000..dca30ca
--- /dev/null
+++ b/cli/src/main/java/org/onlab/onos/cli/net/ConnectivityIntentCommand.java
@@ -0,0 +1,54 @@
+package org.onlab.onos.cli.net;
+
+import org.apache.karaf.shell.commands.Option;
+import org.onlab.onos.cli.AbstractShellCommand;
+import org.onlab.onos.net.flow.DefaultTrafficSelector;
+import org.onlab.onos.net.flow.TrafficSelector;
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.MacAddress;
+
+import com.google.common.base.Strings;
+
+/**
+ * Base class for command line operations for connectivity based intents.
+ */
+public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
+
+    @Option(name = "-s", aliases = "--ethSrc", description = "Source MAC Address",
+            required = false, multiValued = false)
+    private String srcMacString = null;
+
+    @Option(name = "-d", aliases = "--ethDst", description = "Destination MAC Address",
+            required = false, multiValued = false)
+    private String dstMacString = null;
+
+    @Option(name = "-t", aliases = "--ethType", description = "Ethernet Type",
+            required = false, multiValued = false)
+    private String ethTypeString = "";
+
+    /**
+     * Constructs a traffic selector based on the command line arguments
+     * presented to the command.
+     */
+    protected TrafficSelector buildTrafficSelector() {
+        TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
+
+        Short ethType = Ethernet.TYPE_IPV4;
+        if (!Strings.isNullOrEmpty(ethTypeString)) {
+            EthType ethTypeParameter = EthType.valueOf(ethTypeString);
+            ethType = ethTypeParameter.value();
+        }
+        selectorBuilder.matchEthType(ethType);
+
+        if (!Strings.isNullOrEmpty(srcMacString)) {
+            selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString));
+        }
+
+        if (!Strings.isNullOrEmpty(dstMacString)) {
+            selectorBuilder.matchEthDst(MacAddress.valueOf(dstMacString));
+        }
+
+        return selectorBuilder.build();
+    }
+
+}