Added bi-directional nature to HostToHost intent.
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/AddHostToHostIntentCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/AddHostToHostIntentCommand.java
new file mode 100644
index 0000000..be2e964
--- /dev/null
+++ b/cli/src/main/java/org/onlab/onos/cli/net/AddHostToHostIntentCommand.java
@@ -0,0 +1,48 @@
+package org.onlab.onos.cli.net;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onlab.onos.cli.AbstractShellCommand;
+import org.onlab.onos.net.HostId;
+import org.onlab.onos.net.flow.DefaultTrafficSelector;
+import org.onlab.onos.net.flow.DefaultTrafficTreatment;
+import org.onlab.onos.net.flow.TrafficSelector;
+import org.onlab.onos.net.flow.TrafficTreatment;
+import org.onlab.onos.net.intent.HostToHostIntent;
+import org.onlab.onos.net.intent.IntentId;
+import org.onlab.onos.net.intent.IntentService;
+
+/**
+ * Installs host-to-host connectivity intent.
+ */
+@Command(scope = "onos", name = "add-host-intent",
+ description = "Installs host-to-host connectivity intent")
+public class AddHostToHostIntentCommand extends AbstractShellCommand {
+
+ @Argument(index = 0, name = "one", description = "One host ID",
+ required = true, multiValued = false)
+ String one = null;
+
+ @Argument(index = 1, name = "two", description = "Another host ID",
+ required = true, multiValued = false)
+ String two = null;
+
+ private static long id = 1;
+
+ @Override
+ protected void execute() {
+ IntentService service = get(IntentService.class);
+
+ HostId oneId = HostId.hostId(one);
+ HostId twoId = HostId.hostId(two);
+
+ TrafficSelector selector = DefaultTrafficSelector.builder().build();
+ TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
+
+ HostToHostIntent intent =
+ new HostToHostIntent(new IntentId(id++), oneId, twoId,
+ selector, treatment);
+ service.submit(intent);
+ }
+
+}
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/IntentInstallCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/IntentInstallCommand.java
deleted file mode 100644
index 90b7311..0000000
--- a/cli/src/main/java/org/onlab/onos/cli/net/IntentInstallCommand.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.onlab.onos.cli.net;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.onos.cli.AbstractShellCommand;
-import org.onlab.onos.net.HostId;
-import org.onlab.onos.net.flow.DefaultTrafficSelector;
-import org.onlab.onos.net.flow.DefaultTrafficTreatment;
-import org.onlab.onos.net.flow.TrafficSelector;
-import org.onlab.onos.net.flow.TrafficTreatment;
-import org.onlab.onos.net.host.HostService;
-import org.onlab.onos.net.intent.HostToHostIntent;
-import org.onlab.onos.net.intent.IntentId;
-import org.onlab.onos.net.intent.IntentService;
-
-/**
- * Lists all shortest-paths paths between the specified source and
- * destination devices.
- */
-@Command(scope = "onos", name = "add-intent",
- description = "Installs HostToHostIntent between the specified source and destination devices")
-public class IntentInstallCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "src", description = "Source device ID",
- required = true, multiValued = false)
- String src = null;
-
- @Argument(index = 1, name = "dst", description = "Destination device ID",
- required = true, multiValued = false)
- String dst = null;
-
- private static long id = 1;
-
- @Override
- protected void execute() {
- IntentService service = get(IntentService.class);
- HostService hosts = get(HostService.class);
-
- HostId srcId = HostId.hostId(src);
- HostId dstId = HostId.hostId(dst);
-
- TrafficSelector.Builder builder = DefaultTrafficSelector.builder();
- builder.matchEthSrc(hosts.getHost(srcId).mac())
- .matchEthDst(hosts.getHost(dstId).mac());
-
- TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
-
- HostToHostIntent intent =
- new HostToHostIntent(new IntentId(id++), srcId, dstId,
- builder.build(), treat.build());
-
- log.info("Adding intent {}", intent);
-
- service.submit(intent);
- }
-
-}
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
new file mode 100644
index 0000000..ad17290
--- /dev/null
+++ b/cli/src/main/java/org/onlab/onos/cli/net/IntentsListCommand.java
@@ -0,0 +1,23 @@
+package org.onlab.onos.cli.net;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onlab.onos.cli.AbstractShellCommand;
+import org.onlab.onos.net.intent.Intent;
+import org.onlab.onos.net.intent.IntentService;
+
+/**
+ * Lists the inventory of intents and their states.
+ */
+@Command(scope = "onos", name = "intents",
+ description = "Lists the inventory of intents and their states")
+public class IntentsListCommand extends AbstractShellCommand {
+
+ @Override
+ protected void execute() {
+ IntentService service = get(IntentService.class);
+ for (Intent intent : service.getIntents()) {
+ print("%s", intent);
+ }
+ }
+
+}
diff --git a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index a096735..f0516f7 100644
--- a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -56,12 +56,16 @@
<ref component-id="deviceIdCompleter"/>
</completers>
</command>
+
<command>
- <action class="org.onlab.onos.cli.net.IntentInstallCommand"/>
+ <action class="org.onlab.onos.cli.net.AddHostToHostIntentCommand"/>
<completers>
<ref component-id="hostIdCompleter"/>
</completers>
</command>
+ <command>
+ <action class="org.onlab.onos.cli.net.IntentsListCommand"/>
+ </command>
<command>
<action class="org.onlab.onos.cli.net.ClustersListCommand"/>