aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/cli
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-09-22 12:49:09 -0700
committerAshlee Young <ashlee@onosfw.com>2015-09-22 12:49:09 -0700
commit81391595dca425ae58e2294898f09f11d9a32dbc (patch)
treef5d65c39a732150b2b29daa8de98a35d1236d3fb /framework/src/onos/cli
parent0aa37e73dcb3a55b8d889b0c32ff74055551b1f3 (diff)
bringing src to commit tag 65d551b50e782b0c1ea76c1a9ed1c5a801a5a7e4
Change-Id: Ib2da78962eaef856f418636c31b0f5c84286244f
Diffstat (limited to 'framework/src/onos/cli')
-rw-r--r--framework/src/onos/cli/pom.xml2
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java8
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java2
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java12
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java15
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java15
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java59
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java47
-rw-r--r--framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml10
9 files changed, 154 insertions, 16 deletions
diff --git a/framework/src/onos/cli/pom.xml b/framework/src/onos/cli/pom.xml
index a9cd180d..3d29a26e 100644
--- a/framework/src/onos/cli/pom.xml
+++ b/framework/src/onos/cli/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java
index 0ab6845f..b0cbbdd6 100644
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java
@@ -25,7 +25,6 @@ import org.onosproject.net.ElementId;
import org.onosproject.net.Port;
import org.onosproject.net.flow.FlowRule;
import org.onosproject.net.group.Group;
-import org.onosproject.net.host.PortAddresses;
import org.onosproject.net.topology.TopologyCluster;
import java.util.Comparator;
@@ -113,13 +112,6 @@ public final class Comparators {
}
};
- public static final Comparator<PortAddresses> ADDRESSES_COMPARATOR = new Comparator<PortAddresses>() {
- @Override
- public int compare(PortAddresses arg0, PortAddresses arg1) {
- return CONNECT_POINT_COMPARATOR.compare(arg0.connectPoint(), arg1.connectPoint());
- }
- };
-
public static final Comparator<Interface> INTERFACES_COMPARATOR = (intf1, intf2) ->
CONNECT_POINT_COMPARATOR.compare(intf1.connectPoint(), intf2.connectPoint());
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java
index f05181f5..5ab15b08 100644
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java
@@ -28,7 +28,7 @@ public class MetricNameCompleter extends AbstractChoicesCompleter {
@Override
protected List<String> choices() {
MetricsService metricsService = AbstractShellCommand.get(MetricsService.class);
- return new ArrayList<String>(metricsService.getMetrics().keySet());
+ return new ArrayList<>(metricsService.getMetrics().keySet());
}
}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java
index 5f2f86ee..d99a1839 100644
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java
@@ -15,6 +15,7 @@
*/
package org.onosproject.cli.cfg;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -52,7 +53,7 @@ public class NetworkConfigCommand extends AbstractShellCommand {
@Override
protected void execute() {
service = get(NetworkConfigService.class);
- JsonNode root = new ObjectMapper().createObjectNode();
+ JsonNode root = mapper.createObjectNode();
if (isNullOrEmpty(subjectKey)) {
addAll((ObjectNode) root);
} else {
@@ -68,14 +69,19 @@ public class NetworkConfigCommand extends AbstractShellCommand {
}
}
}
- print("%s", root.toString());
+
+ try {
+ print("%s", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException("Error writing JSON to string", e);
+ }
}
@SuppressWarnings("unchecked")
private void addAll(ObjectNode root) {
service.getSubjectClasses()
.forEach(sc -> {
- SubjectFactory sf = service.getSubjectFactory((Class) sc);
+ SubjectFactory sf = service.getSubjectFactory(sc);
addSubjectClass(newObject(root, sf.subjectKey()), sf);
});
}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
index 1929b726..a736f99a 100644
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.onosproject.cli.net;
import org.apache.karaf.shell.commands.Argument;
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java
index d68084c7..12e9ab5f 100644
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.onosproject.cli.net;
import java.util.Set;
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java
new file mode 100644
index 00000000..ff66b803
--- /dev/null
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cli.net;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.packet.PacketProcessor;
+import org.onosproject.net.packet.PacketService;
+
+import static org.onosproject.net.packet.PacketProcessor.ADVISOR_MAX;
+import static org.onosproject.net.packet.PacketProcessor.DIRECTOR_MAX;
+
+/**
+ * Lists packet processors.
+ */
+@Command(scope = "onos", name = "packet-processors",
+ description = "Lists packet processors")
+public class PacketProcessorsListCommand extends AbstractShellCommand {
+
+ private static final String FMT = "priority=%s, class=%s";
+
+ @Override
+ protected void execute() {
+ PacketService service = get(PacketService.class);
+ if (outputJson()) {
+ // TODO: implement this
+ print("Not implemented.");
+ } else {
+ service.getProcessors().forEach(this::print);
+ }
+ }
+
+ private void print(int priority, PacketProcessor processor) {
+ print(FMT, priorityFormat(priority), processor.getClass().getName());
+ }
+
+ private String priorityFormat(int priority) {
+ if (priority > DIRECTOR_MAX) {
+ return "observer(" + (priority - DIRECTOR_MAX - 1) + ")";
+ } else if (priority > ADVISOR_MAX) {
+ return "director(" + (priority - ADVISOR_MAX - 1) + ")";
+ }
+ return "advisor(" + (priority - 1) + ")";
+ }
+
+}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java
new file mode 100644
index 00000000..9bdeadb3
--- /dev/null
+++ b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.cli.net;
+
+import org.apache.karaf.shell.commands.Command;
+import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.packet.PacketRequest;
+import org.onosproject.net.packet.PacketService;
+
+/**
+ * Lists packet requests.
+ */
+@Command(scope = "onos", name = "packet-requests",
+ description = "Lists packet requests")
+public class PacketRequestsListCommand extends AbstractShellCommand {
+
+ private static final String FMT = "priority=%s, appId=%s, criteria=%s";
+
+ @Override
+ protected void execute() {
+ PacketService service = get(PacketService.class);
+ if (outputJson()) {
+ // TODO: implement this
+ print("Not implemented.");
+ } else {
+ service.getRequests().forEach(this::print);
+ }
+ }
+
+ private void print(PacketRequest request) {
+ print(FMT, request.priority(), request.appId().name(), request.selector().criteria());
+ }
+
+}
diff --git a/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 640868fa..459ffa96 100644
--- a/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/framework/src/onos/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -331,9 +331,6 @@
</completers>
</command>
<command>
- <action class="org.onosproject.cli.net.AddressBindingsListCommand"/>
- </command>
- <command>
<action class="org.onosproject.cli.net.InterfacesListCommand"/>
</command>
@@ -354,6 +351,13 @@
</command>
<command>
+ <action class="org.onosproject.cli.net.PacketRequestsListCommand"/>
+ </command>
+ <command>
+ <action class="org.onosproject.cli.net.PacketProcessorsListCommand"/>
+ </command>
+
+ <command>
<action class="org.onosproject.cli.net.AddTestFlowsCommand"/>
</command>
<command>