summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/cli/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/cli/src/main/java')
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractChoicesCompleter.java38
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractCompleter.java39
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractShellCommand.java167
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/BalanceMastersCommand.java33
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/CliComponent.java39
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java131
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/MastersListCommand.java92
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java34
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricsListCommand.java167
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeAddCommand.java50
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeIdCompleter.java48
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeRemoveCommand.java40
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/NodesListCommand.java88
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/PlaceholderCompleter.java40
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/RolesCommand.java101
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/StartStopCompleter.java34
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/SummaryCommand.java89
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/UiViewListCommand.java60
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/UpDownCompleter.java34
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/app/AllApplicationNamesCompleter.java54
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java103
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationCommandCompleter.java34
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationIdListCommand.java66
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationIdWithIntentNameCompleter.java47
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java77
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java100
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/app/package-info.java20
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java182
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommandCompleter.java43
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentNameCompleter.java44
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentPropertyNameCompleter.java55
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java113
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigRegistryCommand.java51
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/package-info.java20
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java69
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMeter.java68
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java106
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java79
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java125
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java73
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java80
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddTestFlowsCommand.java170
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AnnotateDeviceCommand.java104
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterDevicesCommand.java63
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterIdCompleter.java50
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterLinksCommand.java54
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClustersListCommand.java66
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectPointCompleter.java54
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java435
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/CountersListCommand.java107
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceControllersCommand.java47
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceIdCompleter.java49
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicePortStatsCommand.java192
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java177
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceRemoveCommand.java40
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceRoleCommand.java55
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceSetControllersCommand.java72
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicesListCommand.java97
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DriverNameCompleter.java44
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DriversListCommand.java81
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EdgePortsListCommand.java50
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EncapTypeCompleter.java28
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EthType.java84
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EthTypeCompleter.java42
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ExtHeader.java87
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ExtHeaderCompleter.java42
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowObjectiveCompositionCommand.java45
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowRuleStatusCompleter.java45
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java175
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetFlowStatistics.java323
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetStatistics.java85
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java54
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelCommand.java42
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolCreateCommand.java47
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolDestoryCommand.java31
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelReleaseCommand.java48
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GroupsListCommand.java134
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostIdCompleter.java50
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostRemoveCommand.java40
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostsListCommand.java90
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6Code.java102
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6CodeCompleter.java42
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6Type.java100
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6TypeCompleter.java42
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentCycleCommand.java206
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentKeyCompleter.java49
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentPurgeCommand.java40
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java232
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java170
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentsListCommand.java398
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfaceAddCommand.java89
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfaceRemoveCommand.java56
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfacesListCommand.java80
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IpProtocol.java80
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IpProtocolCompleter.java42
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java59
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelPoolCreateCommand.java48
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelPoolDestroyCommand.java36
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelReleaseCommand.java59
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelResourceCommand.java50
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LeaderCommand.java194
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkDstCompleter.java59
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java137
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkSrcCompleter.java48
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinksListCommand.java110
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/MapsListCommand.java84
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Meters.java58
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java61
-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/java/org/onosproject/cli/net/PartitionsListCommand.java109
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PathListCommand.java97
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/RandomIntentCommand.java103
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ResourceAllocationsCommand.java64
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ResourceAvailableCommand.java80
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/RoleCompleter.java42
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TableStatisticsCommand.java145
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TopologyCommand.java122
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TransactionsCommand.java98
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelBorrowCommand.java212
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelCreateCommand.java205
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelQueryCommand.java224
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelQuerySubscriptionCommand.java53
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelRemoveCommand.java203
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelReturnCommand.java198
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelUpdateCommand.java61
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java109
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/net/package-info.java21
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/package-info.java20
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/security/ReviewApplicationNameCompleter.java58
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/security/ReviewCommand.java122
-rw-r--r--framework/src/onos/cli/src/main/java/org/onosproject/cli/security/package-info.java20
131 files changed, 0 insertions, 11576 deletions
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractChoicesCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractChoicesCompleter.java
deleted file mode 100644
index b846fdeb..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractChoicesCompleter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * 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;
-
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Abstraction of a completer with preset choices.
- */
-public abstract class AbstractChoicesCompleter extends AbstractCompleter {
-
- protected abstract List<String> choices();
-
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
- choices().forEach(strings::add);
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractCompleter.java
deleted file mode 100644
index f232596c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractCompleter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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;
-
-import org.apache.felix.service.command.CommandSession;
-import org.apache.karaf.shell.console.CommandSessionHolder;
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.ArgumentCompleter;
-
-/**
- * Abstract argument completer.
- */
-public abstract class AbstractCompleter implements Completer {
-
- /**
- * Returns the argument list.
- *
- * @return argument list
- */
- protected ArgumentCompleter.ArgumentList getArgumentList() {
- CommandSession session = CommandSessionHolder.getSession();
- return (ArgumentCompleter.ArgumentList)
- session.get(ArgumentCompleter.ARGUMENTS_LIST);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractShellCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractShellCommand.java
deleted file mode 100644
index 8945d62a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/AbstractShellCommand.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2014-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;
-
-import org.apache.karaf.shell.commands.Option;
-import org.apache.karaf.shell.console.AbstractAction;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceNotFoundException;
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.CodecService;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.Annotations;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Base abstraction of Karaf shell commands.
- */
-public abstract class AbstractShellCommand extends AbstractAction implements CodecContext {
-
- @Option(name = "-j", aliases = "--json", description = "Output JSON",
- required = false, multiValued = false)
- private boolean json = false;
-
- /**
- * Returns the reference to the implementation of the specified service.
- *
- * @param serviceClass service class
- * @param <T> type of service
- * @return service implementation
- * @throws org.onlab.osgi.ServiceNotFoundException if service is unavailable
- */
- public static <T> T get(Class<T> serviceClass) {
- return DefaultServiceDirectory.getService(serviceClass);
- }
-
- /**
- * Returns application ID for the CLI.
- *
- * @return command-line application identifier
- */
- protected ApplicationId appId() {
- return get(CoreService.class)
- .registerApplication("org.onosproject.cli");
- }
-
- /**
- * Prints the arguments using the specified format.
- *
- * @param format format string; see {@link String#format}
- * @param args arguments
- */
- public void print(String format, Object... args) {
- System.out.println(String.format(format, args));
- }
-
- /**
- * Prints the arguments using the specified format to error stream.
- *
- * @param format format string; see {@link String#format}
- * @param args arguments
- */
- public void error(String format, Object... args) {
- System.err.println(String.format(format, args));
- }
-
- /**
- * Produces a string image of the specified key/value annotations.
- *
- * @param annotations key/value annotations
- * @return string image with ", k1=v1, k2=v2, ..." pairs
- */
- public static String annotations(Annotations annotations) {
- StringBuilder sb = new StringBuilder();
- for (String key : annotations.keys()) {
- sb.append(", ").append(key).append('=').append(annotations.value(key));
- }
- return sb.toString();
- }
-
- /**
- * Produces a JSON object from the specified key/value annotations.
- *
- * @param mapper ObjectMapper to use while converting to JSON
- * @param annotations key/value annotations
- * @return JSON object
- */
- public static ObjectNode annotations(ObjectMapper mapper, Annotations annotations) {
- ObjectNode result = mapper.createObjectNode();
- for (String key : annotations.keys()) {
- result.put(key, annotations.value(key));
- }
- return result;
- }
-
- /**
- * Executes this command.
- */
- protected abstract void execute();
-
- /**
- * Indicates whether JSON format should be output.
- *
- * @return true if JSON is requested
- */
- protected boolean outputJson() {
- return json;
- }
-
- @Override
- protected Object doExecute() throws Exception {
- try {
- execute();
- } catch (ServiceNotFoundException e) {
- error(e.getMessage());
- }
- return null;
- }
-
-
-
- private final ObjectMapper mapper = new ObjectMapper();
-
- @Override
- public ObjectMapper mapper() {
- return mapper;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <T> JsonCodec<T> codec(Class<T> entityClass) {
- return get(CodecService.class).getCodec(entityClass);
- }
-
- @Override
- public <T> T getService(Class<T> serviceClass) {
- return get(serviceClass);
- }
-
- /**
- * Generates a Json representation of an object.
- *
- * @param entity object to generate JSON for
- * @param entityClass class to format with - this chooses which codec to use
- * @param <T> Type of the object being formatted
- * @return JSON object representation
- */
- public <T> ObjectNode jsonForEntity(T entity, Class<T> entityClass) {
- return codec(entityClass).encode(entity, this);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/BalanceMastersCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/BalanceMastersCommand.java
deleted file mode 100644
index 9a35ce34..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/BalanceMastersCommand.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2014 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;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.mastership.MastershipAdminService;
-
-/**
- * Forces device mastership rebalancing.
- */
-@Command(scope = "onos", name = "balance-masters",
- description = "Forces device mastership rebalancing")
-public class BalanceMastersCommand extends AbstractShellCommand {
-
- @Override
- protected void execute() {
- get(MastershipAdminService.class).balanceRoles();
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/CliComponent.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/CliComponent.java
deleted file mode 100644
index 6ae816bd..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/CliComponent.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onosproject.core.CoreService;
-
-/**
- * OSGI Component for the ONOS CLI.
- */
-
-@Component(immediate = true)
-public class CliComponent {
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Activate
- public void activate() {
- coreService
- .registerApplication("org.onosproject.cli");
- }
-}
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
deleted file mode 100644
index 03d25cee..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/Comparators.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright 2014-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;
-
-import org.onosproject.cluster.ControllerNode;
-import org.onosproject.core.Application;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.incubator.net.intf.Interface;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Element;
-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.statistic.TypedFlowEntryWithLoad;
-import org.onosproject.net.topology.TopologyCluster;
-
-import java.util.Comparator;
-
-/**
- * Various comparators.
- */
-public final class Comparators {
-
- // Ban construction
- private Comparators() {
- }
-
- public static final Comparator<ApplicationId> APP_ID_COMPARATOR = new Comparator<ApplicationId>() {
- @Override
- public int compare(ApplicationId id1, ApplicationId id2) {
- return id1.id() - id2.id();
- }
- };
-
- public static final Comparator<Application> APP_COMPARATOR = new Comparator<Application>() {
- @Override
- public int compare(Application app1, Application app2) {
- return app1.id().id() - app2.id().id();
- }
- };
-
- public static final Comparator<ElementId> ELEMENT_ID_COMPARATOR = new Comparator<ElementId>() {
- @Override
- public int compare(ElementId id1, ElementId id2) {
- return id1.toString().compareTo(id2.toString());
- }
- };
-
- public static final Comparator<Element> ELEMENT_COMPARATOR = new Comparator<Element>() {
- @Override
- public int compare(Element e1, Element e2) {
- return e1.id().toString().compareTo(e2.id().toString());
- }
- };
-
- public static final Comparator<FlowRule> FLOW_RULE_COMPARATOR = new Comparator<FlowRule>() {
- @Override
- public int compare(FlowRule f1, FlowRule f2) {
- int tableCompare = Integer.valueOf(f1.tableId()).compareTo(f2.tableId());
- return (tableCompare == 0)
- ? Long.valueOf(f1.id().value()).compareTo(f2.id().value())
- : tableCompare;
- }
- };
-
- public static final Comparator<Group> GROUP_COMPARATOR = new Comparator<Group>() {
- @Override
- public int compare(Group g1, Group g2) {
- return Long.valueOf(g1.id().id()).compareTo(Long.valueOf(g2.id().id()));
- }
- };
-
- public static final Comparator<Port> PORT_COMPARATOR = new Comparator<Port>() {
- @Override
- public int compare(Port p1, Port p2) {
- long delta = p1.number().toLong() - p2.number().toLong();
- return delta == 0 ? 0 : (delta < 0 ? -1 : +1);
- }
- };
-
- public static final Comparator<TopologyCluster> CLUSTER_COMPARATOR = new Comparator<TopologyCluster>() {
- @Override
- public int compare(TopologyCluster c1, TopologyCluster c2) {
- return c1.id().index() - c2.id().index();
- }
- };
-
- public static final Comparator<ControllerNode> NODE_COMPARATOR = new Comparator<ControllerNode>() {
- @Override
- public int compare(ControllerNode ci1, ControllerNode ci2) {
- return ci1.id().toString().compareTo(ci2.id().toString());
- }
- };
-
- public static final Comparator<ConnectPoint> CONNECT_POINT_COMPARATOR = new Comparator<ConnectPoint>() {
- @Override
- public int compare(ConnectPoint o1, ConnectPoint o2) {
- int compareId = ELEMENT_ID_COMPARATOR.compare(o1.elementId(), o2.elementId());
- return (compareId != 0) ?
- compareId :
- Long.signum(o1.port().toLong() - o2.port().toLong());
- }
- };
-
- public static final Comparator<Interface> INTERFACES_COMPARATOR = (intf1, intf2) ->
- CONNECT_POINT_COMPARATOR.compare(intf1.connectPoint(), intf2.connectPoint());
-
- public static final Comparator<TypedFlowEntryWithLoad> TYPEFLOWENTRY_WITHLOAD_COMPARATOR =
- new Comparator<TypedFlowEntryWithLoad>() {
- @Override
- public int compare(TypedFlowEntryWithLoad fe1, TypedFlowEntryWithLoad fe2) {
- long delta = fe1.load().rate() - fe2.load().rate();
- return delta == 0 ? 0 : (delta > 0 ? -1 : +1);
- }
- };
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MastersListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/MastersListCommand.java
deleted file mode 100644
index 8675a3c8..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MastersListCommand.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2014 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;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.google.common.collect.Lists;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.ControllerNode;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.DeviceId;
-
-import java.util.Collections;
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-/**
- * Lists device mastership information.
- */
-@Command(scope = "onos", name = "masters",
- description = "Lists device mastership information")
-public class MastersListCommand extends AbstractShellCommand {
-
- @Override
- protected void execute() {
- ClusterService service = get(ClusterService.class);
- MastershipService mastershipService = get(MastershipService.class);
- List<ControllerNode> nodes = newArrayList(service.getNodes());
- Collections.sort(nodes, Comparators.NODE_COMPARATOR);
-
- if (outputJson()) {
- print("%s", json(service, mastershipService, nodes));
- } else {
- for (ControllerNode node : nodes) {
- List<DeviceId> ids = Lists.newArrayList(mastershipService.getDevicesOf(node.id()));
- Collections.sort(ids, Comparators.ELEMENT_ID_COMPARATOR);
- print("%s: %d devices", node.id(), ids.size());
- for (DeviceId deviceId : ids) {
- print(" %s", deviceId);
- }
- }
- }
- }
-
- // Produces JSON structure.
- private JsonNode json(ClusterService service, MastershipService mastershipService,
- List<ControllerNode> nodes) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- ControllerNode self = service.getLocalNode();
- for (ControllerNode node : nodes) {
- List<DeviceId> ids = Lists.newArrayList(mastershipService.getDevicesOf(node.id()));
- result.add(mapper.createObjectNode()
- .put("id", node.id().toString())
- .put("size", ids.size())
- .set("devices", json(mapper, ids)));
- }
- return result;
- }
-
- /**
- * Produces a JSON array containing the specified device identifiers.
- *
- * @param mapper object mapper
- * @param ids collection of device identifiers
- * @return JSON array
- */
- public static JsonNode json(ObjectMapper mapper, Iterable<DeviceId> ids) {
- ArrayNode result = mapper.createArrayNode();
- for (DeviceId deviceId : ids) {
- result.add(deviceId.toString());
- }
- return result;
- }
-
-}
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
deleted file mode 100644
index 5ab15b08..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricNameCompleter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-import org.onlab.metrics.MetricsService;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Metric name completer.
- */
-public class MetricNameCompleter extends AbstractChoicesCompleter {
-
- @Override
- protected List<String> choices() {
- MetricsService metricsService = AbstractShellCommand.get(MetricsService.class);
- return new ArrayList<>(metricsService.getMetrics().keySet());
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricsListCommand.java
deleted file mode 100644
index 9b80485b..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/MetricsListCommand.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2014 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;
-
-import com.codahale.metrics.Counter;
-import com.codahale.metrics.Gauge;
-import com.codahale.metrics.Histogram;
-import com.codahale.metrics.Meter;
-import com.codahale.metrics.Metric;
-import com.codahale.metrics.MetricFilter;
-import com.codahale.metrics.Snapshot;
-import com.codahale.metrics.Timer;
-import com.google.common.base.Strings;
-import com.google.common.collect.Ordering;
-import com.google.common.collect.TreeMultimap;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.joda.time.LocalDateTime;
-import org.onlab.metrics.MetricsService;
-
-import java.util.Comparator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import static java.lang.String.format;
-
-/**
- * Prints metrics in the system.
- */
-@Command(scope = "onos", name = "metrics",
- description = "Prints metrics in the system")
-public class MetricsListCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "metricName", description = "Name of Metric",
- required = false, multiValued = false)
- String metricName = null;
-
- @Override
- protected void execute() {
- MetricsService metricsService = get(MetricsService.class);
-
- MetricFilter filter = metricName != null ? (name, metric) -> name.equals(metricName) : MetricFilter.ALL;
-
- TreeMultimap<String, Metric> matched = listMetrics(metricsService, filter);
- matched.asMap().forEach((name, metrics) -> {
- for (Metric metric : metrics) {
- printMetric(name, metric);
- }
- });
- }
-
- /**
- * Print metric object.
- *
- * @param name metric name
- * @param metric metric object
- */
- private void printMetric(String name, Metric metric) {
- final String heading;
-
- if (metric instanceof Counter) {
- heading = format("-- %s : [%s] --", name, "Counter");
- print(heading);
- Counter counter = (Counter) metric;
- print(" count = %d", counter.getCount());
-
- } else if (metric instanceof Gauge) {
- heading = format("-- %s : [%s] --", name, "Gauge");
- print(heading);
- @SuppressWarnings("rawtypes")
- Gauge gauge = (Gauge) metric;
- final Object value = gauge.getValue();
- if (name.endsWith("EpochMs") && value instanceof Long) {
- print(" value = %s (%s)", value, new LocalDateTime(value));
- } else {
- print(" value = %s", value);
- }
-
- } else if (metric instanceof Histogram) {
- heading = format("-- %s : [%s] --", name, "Histogram");
- print(heading);
- final Histogram histogram = (Histogram) metric;
- final Snapshot snapshot = histogram.getSnapshot();
- print(" count = %d", histogram.getCount());
- print(" min = %d", snapshot.getMin());
- print(" max = %d", snapshot.getMax());
- print(" mean = %f", snapshot.getMean());
- print(" stddev = %f", snapshot.getStdDev());
-
- } else if (metric instanceof Meter) {
- heading = format("-- %s : [%s] --", name, "Meter");
- print(heading);
- final Meter meter = (Meter) metric;
- print(" count = %d", meter.getCount());
- print(" mean rate = %f", meter.getMeanRate());
- print(" 1-minute rate = %f", meter.getOneMinuteRate());
- print(" 5-minute rate = %f", meter.getFiveMinuteRate());
- print(" 15-minute rate = %f", meter.getFifteenMinuteRate());
-
- } else if (metric instanceof Timer) {
- heading = format("-- %s : [%s] --", name, "Timer");
- print(heading);
- final Timer timer = (Timer) metric;
- final Snapshot snapshot = timer.getSnapshot();
- print(" count = %d", timer.getCount());
- print(" mean rate = %f per second", timer.getMeanRate());
- print(" 1-minute rate = %f per second", timer.getOneMinuteRate());
- print(" 5-minute rate = %f per second", timer.getFiveMinuteRate());
- print(" 15-minute rate = %f per second", timer.getFifteenMinuteRate());
- print(" min = %f ms", nanoToMs(snapshot.getMin()));
- print(" max = %f ms", nanoToMs(snapshot.getMax()));
- print(" mean = %f ms", nanoToMs(snapshot.getMean()));
- print(" stddev = %f ms", nanoToMs(snapshot.getStdDev()));
- } else {
- heading = format("-- %s : [%s] --", name, metric.getClass().getCanonicalName());
- print(heading);
- print("Unknown Metric type:{}", metric.getClass().getCanonicalName());
- }
- print(Strings.repeat("-", heading.length()));
- }
-
- @SuppressWarnings("rawtypes")
- private TreeMultimap<String, Metric> listMetrics(MetricsService metricsService, MetricFilter filter) {
- TreeMultimap<String, Metric> metrics = TreeMultimap.create(Comparator.naturalOrder(), Ordering.arbitrary());
-
- Map<String, Counter> counters = metricsService.getCounters(filter);
- for (Entry<String, Counter> entry : counters.entrySet()) {
- metrics.put(entry.getKey(), entry.getValue());
- }
- Map<String, Gauge> gauges = metricsService.getGauges(filter);
- for (Entry<String, Gauge> entry : gauges.entrySet()) {
- metrics.put(entry.getKey(), entry.getValue());
- }
- Map<String, Histogram> histograms = metricsService.getHistograms(filter);
- for (Entry<String, Histogram> entry : histograms.entrySet()) {
- metrics.put(entry.getKey(), entry.getValue());
- }
- Map<String, Meter> meters = metricsService.getMeters(filter);
- for (Entry<String, Meter> entry : meters.entrySet()) {
- metrics.put(entry.getKey(), entry.getValue());
- }
- Map<String, Timer> timers = metricsService.getTimers(filter);
- for (Entry<String, Timer> entry : timers.entrySet()) {
- metrics.put(entry.getKey(), entry.getValue());
- }
-
- return metrics;
- }
-
- private double nanoToMs(double nano) {
- return nano / 1_000_000D;
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeAddCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeAddCommand.java
deleted file mode 100644
index 37f59918..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeAddCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2014-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;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cluster.ClusterAdminService;
-import org.onosproject.cluster.DefaultControllerNode;
-import org.onosproject.cluster.NodeId;
-import org.onlab.packet.IpAddress;
-
-/**
- * Adds a new controller cluster node.
- */
-@Command(scope = "onos", name = "add-node",
- description = "Adds a new controller cluster node")
-public class NodeAddCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "nodeId", description = "Node ID",
- required = true, multiValued = false)
- String nodeId = null;
-
- @Argument(index = 1, name = "ip", description = "Node IP address",
- required = true, multiValued = false)
- String ip = null;
-
- @Argument(index = 2, name = "tcpPort", description = "Node TCP listen port",
- required = false, multiValued = false)
- int tcpPort = DefaultControllerNode.DEFAULT_PORT;
-
- @Override
- protected void execute() {
- ClusterAdminService service = get(ClusterAdminService.class);
- service.addNode(new NodeId(nodeId), IpAddress.valueOf(ip), tcpPort);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeIdCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeIdCompleter.java
deleted file mode 100644
index 8e6db7f4..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeIdCompleter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2014 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;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.ControllerNode;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Node ID completer.
- */
-public class NodeIdCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- ClusterService service = AbstractShellCommand.get(ClusterService.class);
- Iterator<ControllerNode> it = service.getNodes().iterator();
- SortedSet<String> strings = delegate.getStrings();
- while (it.hasNext()) {
- strings.add(it.next().id().toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeRemoveCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeRemoveCommand.java
deleted file mode 100644
index c2dbb546..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodeRemoveCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2014 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;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cluster.ClusterAdminService;
-import org.onosproject.cluster.NodeId;
-
-/**
- * Removes a controller cluster node.
- */
-@Command(scope = "onos", name = "remove-node",
- description = "Removes a new controller cluster node")
-public class NodeRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "nodeId", description = "Node ID",
- required = true, multiValued = false)
- String nodeId = null;
-
- @Override
- protected void execute() {
- ClusterAdminService service = get(ClusterAdminService.class);
- service.removeNode(new NodeId(nodeId));
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodesListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodesListCommand.java
deleted file mode 100644
index 50e8d534..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/NodesListCommand.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2014-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;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.karaf.shell.commands.Command;
-import org.joda.time.DateTime;
-import org.onlab.util.Tools;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.ControllerNode;
-
-import java.util.Collections;
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-
-/**
- * Lists all controller cluster nodes.
- */
-@Command(scope = "onos", name = "nodes",
- description = "Lists all controller cluster nodes")
-public class NodesListCommand extends AbstractShellCommand {
-
- private static final String FMT =
- "id=%s, address=%s:%s, state=%s, updated=%s %s";
-
- @Override
- protected void execute() {
- ClusterService service = get(ClusterService.class);
- List<ControllerNode> nodes = newArrayList(service.getNodes());
- Collections.sort(nodes, Comparators.NODE_COMPARATOR);
- if (outputJson()) {
- print("%s", json(service, nodes));
- } else {
- ControllerNode self = service.getLocalNode();
- for (ControllerNode node : nodes) {
- DateTime lastUpdated = service.getLastUpdated(node.id());
- String timeAgo = "Never";
- if (lastUpdated != null) {
- timeAgo = Tools.timeAgo(lastUpdated.getMillis());
- }
- print(FMT, node.id(), node.ip(), node.tcpPort(),
- service.getState(node.id()),
- timeAgo,
- node.equals(self) ? "*" : "");
- }
- }
- }
-
- // Produces JSON structure.
- private JsonNode json(ClusterService service, List<ControllerNode> nodes) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- ControllerNode self = service.getLocalNode();
- for (ControllerNode node : nodes) {
- ControllerNode.State nodeState = service.getState(node.id());
- ObjectNode newNode = mapper.createObjectNode()
- .put("id", node.id().toString())
- .put("ip", node.ip().toString())
- .put("tcpPort", node.tcpPort())
- .put("self", node.equals(self));
-
- if (nodeState != null) {
- newNode.put("state", nodeState.toString());
- }
- result.add(newNode);
- }
- return result;
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/PlaceholderCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/PlaceholderCompleter.java
deleted file mode 100644
index dbd2a971..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/PlaceholderCompleter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * A completer that can be used as a placeholder for arguments that don't
- * need/want completers.
- */
-public class PlaceholderCompleter extends AbstractCompleter {
-
- @Override
- public int complete(String s, int i, List<String> list) {
- // Populate a string completer with what the user has typed so far
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
- if (s != null) {
- strings.add(s);
- }
- return delegate.complete(s, i, list);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/RolesCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/RolesCommand.java
deleted file mode 100644
index bc1e9102..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/RolesCommand.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2014 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;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.cluster.RoleInfo;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
-
-import java.util.List;
-
-import static org.onosproject.cli.net.DevicesListCommand.getSortedDevices;
-
-/**
- * Lists mastership roles of nodes for each device.
- */
-@Command(scope = "onos", name = "roles",
- description = "Lists mastership roles of nodes for each device.")
-public class RolesCommand extends AbstractShellCommand {
-
- private static final String FMT_HDR = "%s: master=%s, standbys=[ %s]";
-
- @Override
- protected void execute() {
- DeviceService deviceService = get(DeviceService.class);
- MastershipService roleService = get(MastershipService.class);
-
- if (outputJson()) {
- print("%s", json(roleService, getSortedDevices(deviceService)));
- } else {
- for (Device d : getSortedDevices(deviceService)) {
- DeviceId did = d.id();
- printRoles(roleService, did);
- }
- }
- }
-
- // Produces JSON structure with role information for the given devices.
- private JsonNode json(MastershipService service, List<Device> sortedDevices) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode results = mapper.createArrayNode();
- for (Device device : sortedDevices) {
- results.add(json(service, mapper, device));
- }
- return results;
- }
-
- // Produces JSON structure with role information for the given device.
- private JsonNode json(MastershipService service, ObjectMapper mapper,
- Device device) {
- NodeId master = service.getMasterFor(device.id());
- ObjectNode result = mapper.createObjectNode()
- .put("id", device.id().toString())
- .put("master", master != null ? master.toString() : "none");
- RoleInfo nodes = service.getNodesFor(device.id());
- ArrayNode standbys = mapper.createArrayNode();
- for (NodeId nid : nodes.backups()) {
- standbys.add(nid.toString());
- }
- result.set("standbys", standbys);
- return result;
- }
-
- /**
- * Prints the role information for a device.
- *
- * @param service mastership service
- * @param deviceId the ID of the device
- */
- protected void printRoles(MastershipService service, DeviceId deviceId) {
- RoleInfo nodes = service.getNodesFor(deviceId);
- StringBuilder builder = new StringBuilder();
- for (NodeId nid : nodes.backups()) {
- builder.append(nid).append(" ");
- }
-
- print(FMT_HDR, deviceId,
- nodes.master() == null ? "NONE" : nodes.master(),
- builder.toString());
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/StartStopCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/StartStopCompleter.java
deleted file mode 100644
index b9d9b0f8..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/StartStopCompleter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-import com.google.common.collect.ImmutableList;
-
-import java.util.List;
-
-/**
- * Start/stop command completer.
- */
-public class StartStopCompleter extends AbstractChoicesCompleter {
-
- public static final String START = "start";
- public static final String STOP = "stop";
-
- @Override
- public List<String> choices() {
- return ImmutableList.of(START, STOP);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/SummaryCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/SummaryCommand.java
deleted file mode 100644
index 65f4cf97..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/SummaryCommand.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2014-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;
-
-import java.util.Set;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cluster.ControllerNode;
-import org.onosproject.core.CoreService;
-import org.onosproject.cluster.ClusterService;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.topology.Topology;
-import org.onosproject.net.topology.TopologyService;
-
-/**
- * Provides summary of ONOS model.
- */
-@Command(scope = "onos", name = "summary",
- description = "Provides summary of ONOS model")
-public class SummaryCommand extends AbstractShellCommand {
-
- /**
- * Count the active ONOS controller nodes.
- *
- * @param nodes set of all of the controller nodes in the cluster
- * @return count of active nodes
- */
- private int activeNodes(Set<ControllerNode> nodes) {
- int nodeCount = 0;
-
- for (final ControllerNode node : nodes) {
- final ControllerNode.State nodeState =
- get(ClusterService.class).getState(node.id());
- if (nodeState == ControllerNode.State.ACTIVE) {
- nodeCount++;
- }
- }
- return nodeCount;
- }
-
- @Override
- protected void execute() {
- TopologyService topologyService = get(TopologyService.class);
- Topology topology = topologyService.currentTopology();
- if (outputJson()) {
- print("%s", new ObjectMapper().createObjectNode()
- .put("node", get(ClusterService.class).getLocalNode().ip().toString())
- .put("version", get(CoreService.class).version().toString())
- .put("nodes", get(ClusterService.class).getNodes().size())
- .put("devices", topology.deviceCount())
- .put("links", topology.linkCount())
- .put("hosts", get(HostService.class).getHostCount())
- .put("SCC(s)", topology.clusterCount())
- .put("flows", get(FlowRuleService.class).getFlowRuleCount())
- .put("intents", get(IntentService.class).getIntentCount()));
- } else {
- print("node=%s, version=%s",
- get(ClusterService.class).getLocalNode().ip(),
- get(CoreService.class).version().toString());
- print("nodes=%d, devices=%d, links=%d, hosts=%d, SCC(s)=%s, flows=%d, intents=%d",
- activeNodes(get(ClusterService.class).getNodes()),
- get(DeviceService.class).getDeviceCount(),
- get(LinkService.class).getLinkCount(),
- get(HostService.class).getHostCount(),
- topologyService.getClusters(topology).size(),
- get(FlowRuleService.class).getFlowRuleCount(),
- get(IntentService.class).getIntentCount());
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/UiViewListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/UiViewListCommand.java
deleted file mode 100644
index 33a85e68..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/UiViewListCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.ui.UiExtension;
-import org.onosproject.ui.UiExtensionService;
-
-import java.util.List;
-
-/**
- * Lists all UI views.
- */
-@Command(scope = "onos", name = "ui-views",
- description = "Lists all UI views")
-public class UiViewListCommand extends AbstractShellCommand {
-
- private static final String FMT = "id=%s, category=%s, label=%s, icon=%s";
-
- @Override
- protected void execute() {
- UiExtensionService service = get(UiExtensionService.class);
- if (outputJson()) {
- print("%s", json(service.getExtensions()));
- } else {
- service.getExtensions().forEach(ext -> ext.views()
- .forEach(v -> print(FMT, v.id(), v.category().label(),
- v.label(), v.iconId())));
- }
- }
-
- private JsonNode json(List<UiExtension> extensions) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode node = mapper.createArrayNode();
- extensions.forEach(ext -> ext.views()
- .forEach(v -> node.add(mapper.createObjectNode()
- .put("id", v.id())
- .put("category", v.category().label())
- .put("label", v.label())
- .put("icon", v.iconId()))));
- return node;
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/UpDownCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/UpDownCompleter.java
deleted file mode 100644
index 9d8eda5c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/UpDownCompleter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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;
-
-import com.google.common.collect.ImmutableList;
-
-import java.util.List;
-
-/**
- * Up/down command completer.
- */
-public class UpDownCompleter extends AbstractChoicesCompleter {
-
- public static final String UP = "up";
- public static final String DOWN = "down";
-
- @Override
- public List<String> choices() {
- return ImmutableList.of(UP, DOWN);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/AllApplicationNamesCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/AllApplicationNamesCompleter.java
deleted file mode 100644
index 9006369b..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/AllApplicationNamesCompleter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.app;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Spliterator;
-import java.util.Spliterators;
-import java.util.stream.StreamSupport;
-
-import org.onosproject.app.ApplicationService;
-import org.onosproject.cli.AbstractChoicesCompleter;
-import org.onosproject.core.Application;
-
-import static java.util.stream.Collectors.toList;
-import static org.onosproject.app.ApplicationState.INSTALLED;
-import static org.onosproject.cli.AbstractShellCommand.get;
-
-/**
- * All installed application name completer.
- */
-public class AllApplicationNamesCompleter extends AbstractChoicesCompleter {
- @Override
- public List<String> choices() {
-
- // Fetch the service and return the list of app names
- ApplicationService service = get(ApplicationService.class);
- Iterator<Application> it = service.getApplications().iterator();
-
- // Filter the list of apps, selecting only the installed ones.
- // Add each app name to the list of choices.
- return
- StreamSupport.stream(
- Spliterators.spliteratorUnknownSize(it, Spliterator.ORDERED), false)
- .filter(app -> service.getState(app.id()) == INSTALLED)
- .map(app -> app.id().name())
- .collect(toList());
-
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
deleted file mode 100644
index 9d40c660..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * 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.app;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.app.ApplicationAdminService;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * Manages application inventory.
- */
-@Command(scope = "onos", name = "app",
- description = "Manages application inventory")
-public class ApplicationCommand extends AbstractShellCommand {
-
- static final String INSTALL = "install";
- static final String UNINSTALL = "uninstall";
- static final String ACTIVATE = "activate";
- static final String DEACTIVATE = "deactivate";
-
- @Argument(index = 0, name = "command",
- description = "Command name (install|activate|deactivate|uninstall)",
- required = true, multiValued = false)
- String command = null;
-
- @Argument(index = 1, name = "names", description = "Application name(s) or URL(s)",
- required = true, multiValued = true)
- String[] names = null;
-
- @Override
- protected void execute() {
- ApplicationAdminService service = get(ApplicationAdminService.class);
- if (command.equals(INSTALL)) {
- for (String name : names) {
- if (!installApp(service, name)) {
- return;
- }
- }
-
- } else {
- for (String name : names) {
- if (!manageApp(service, name)) {
- return;
- }
- }
- }
- }
-
- // Installs the application from input of the specified URL
- private boolean installApp(ApplicationAdminService service, String url) {
- try {
- if (url.equals("-")) {
- service.install(System.in);
- } else {
- service.install(new URL(url).openStream());
- }
- } catch (IOException e) {
- error("Unable to get URL: %s", url);
- return false;
- }
- return true;
- }
-
- // Manages the specified application.
- private boolean manageApp(ApplicationAdminService service, String name) {
- ApplicationId appId = service.getId(name);
- if (appId == null) {
- print("No such application: %s", name);
- return false;
- }
-
- if (command.equals(UNINSTALL)) {
- service.uninstall(appId);
- } else if (command.equals(ACTIVATE)) {
- service.activate(appId);
- } else if (command.equals(DEACTIVATE)) {
- service.deactivate(appId);
- } else {
- print("Unsupported command: %s", command);
- return false;
- }
- return true;
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationCommandCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationCommandCompleter.java
deleted file mode 100644
index 51611ff5..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationCommandCompleter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.app;
-
-import com.google.common.collect.ImmutableList;
-import org.onosproject.cli.AbstractChoicesCompleter;
-
-import java.util.List;
-
-import static org.onosproject.cli.app.ApplicationCommand.*;
-
-/**
- * Application command completer.
- */
-public class ApplicationCommandCompleter extends AbstractChoicesCompleter {
- @Override
- public List<String> choices() {
- return ImmutableList.of(INSTALL, UNINSTALL, ACTIVATE, DEACTIVATE);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationIdListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationIdListCommand.java
deleted file mode 100644
index 3088a94c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationIdListCommand.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2014-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.app;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-
-import java.util.Collections;
-import java.util.List;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-/**
- * Lists application ID information.
- */
-@Command(scope = "onos", name = "app-ids",
- description = "Lists application ID information")
-public class ApplicationIdListCommand extends AbstractShellCommand {
-
- @Override
- protected void execute() {
- CoreService service = get(CoreService.class);
- List<ApplicationId> ids = newArrayList(service.getAppIds());
- Collections.sort(ids, Comparators.APP_ID_COMPARATOR);
-
- if (outputJson()) {
- print("%s", json(ids));
- } else {
- for (ApplicationId id : ids) {
- print("id=%d, name=%s", id.id(), id.name());
- }
- }
- }
-
- // ApplicationId
- private JsonNode json(List<ApplicationId> ids) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- for (ApplicationId id : ids) {
- result.add(mapper.createObjectNode()
- .put("id", id.id())
- .put("name", id.name()));
- }
- return result;
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationIdWithIntentNameCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationIdWithIntentNameCompleter.java
deleted file mode 100644
index 2539ca72..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationIdWithIntentNameCompleter.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.app;
-
-import java.util.List;
-import java.util.SortedSet;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.intent.IntentService;
-
-/**
- * Application name completer.
- */
-public class ApplicationIdWithIntentNameCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- IntentService service = AbstractShellCommand.get(IntentService.class);
- SortedSet<String> strings = delegate.getStrings();
-
- service.getIntents()
- .forEach(intent ->
- strings.add(intent.appId().name()));
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java
deleted file mode 100644
index 17461696..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationNameCompleter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.app;
-
-import org.apache.karaf.shell.console.completer.ArgumentCompleter;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.app.ApplicationService;
-import org.onosproject.app.ApplicationState;
-import org.onosproject.cli.AbstractCompleter;
-import org.onosproject.core.Application;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-
-import static org.onosproject.app.ApplicationState.ACTIVE;
-import static org.onosproject.app.ApplicationState.INSTALLED;
-import static org.onosproject.cli.AbstractShellCommand.get;
-
-/**
- * Application name completer.
- */
-public class ApplicationNameCompleter extends AbstractCompleter {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Command name is the second argument.
- ArgumentCompleter.ArgumentList list = getArgumentList();
- String cmd = list.getArguments()[1];
-
- // Grab apps already on the command (to prevent tab-completed duplicates)
- // FIXME: This does not work.
-// final Set previousApps;
-// if (list.getArguments().length > 2) {
-// previousApps = Sets.newHashSet(
-// Arrays.copyOfRange(list.getArguments(), 2, list.getArguments().length));
-// } else {
-// previousApps = Collections.emptySet();
-// }
-
- // Fetch our service and feed it's offerings to the string completer
- ApplicationService service = get(ApplicationService.class);
- Iterator<Application> it = service.getApplications().iterator();
- SortedSet<String> strings = delegate.getStrings();
- while (it.hasNext()) {
- Application app = it.next();
- ApplicationState state = service.getState(app.id());
-// if (previousApps.contains(app.id().name())) {
-// continue;
-// }
- if (cmd.equals("uninstall") ||
- (cmd.equals("activate") && state == INSTALLED) ||
- (cmd.equals("deactivate") && state == ACTIVE)) {
- strings.add(app.id().name());
- }
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java
deleted file mode 100644
index 100f6823..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.app;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.app.ApplicationService;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.core.Application;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-import static com.google.common.collect.Lists.newArrayList;
-import static org.onosproject.app.ApplicationState.ACTIVE;
-
-/**
- * Lists application information.
- */
-@Command(scope = "onos", name = "apps",
- description = "Lists application information")
-public class ApplicationsListCommand extends AbstractShellCommand {
-
- private static final String FMT =
- "%s id=%d, name=%s, version=%s, origin=%s, description=%s, " +
- "features=%s, featuresRepo=%s, apps=%s, permissions=%s";
-
- private static final String SHORT_FMT =
- "%s %3d %-32s %-8s %s";
-
- @Option(name = "-s", aliases = "--short", description = "Show short output only",
- required = false, multiValued = false)
- private boolean shortOnly = false;
-
- @Option(name = "-a", aliases = "--active", description = "Show active only",
- required = false, multiValued = false)
- private boolean activeOnly = false;
-
-
- @Override
- protected void execute() {
- ApplicationService service = get(ApplicationService.class);
- List<Application> apps = newArrayList(service.getApplications());
- Collections.sort(apps, Comparators.APP_COMPARATOR);
-
- if (outputJson()) {
- print("%s", json(service, apps));
- } else {
- for (Application app : apps) {
- boolean isActive = service.getState(app.id()) == ACTIVE;
- if (activeOnly && isActive || !activeOnly) {
- if (shortOnly) {
- print(SHORT_FMT, isActive ? "*" : " ",
- app.id().id(), app.id().name(), app.version(),
- app.description());
- } else {
- print(FMT, isActive ? "*" : " ",
- app.id().id(), app.id().name(), app.version(), app.origin(),
- app.description(), app.features(),
- app.featuresRepo().isPresent() ? app.featuresRepo().get().toString() : "",
- app.requiredApps(), app.permissions());
- }
- }
- }
- }
- }
-
- private JsonNode json(ApplicationService service, List<Application> apps) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- for (Application app : apps) {
- boolean isActive = service.getState(app.id()) == ACTIVE;
- if (activeOnly && isActive || !activeOnly) {
- result.add(jsonForEntity(app, Application.class));
- }
- }
- return result;
- }
-
-
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/package-info.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/package-info.java
deleted file mode 100644
index 37b67fa9..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/app/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * CLI commands for managing distributed inventory of applications.
- */
-package org.onosproject.cli.app; \ No newline at end of file
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
deleted file mode 100644
index 5b9a7283..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommand.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * 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.cfg;
-
-import java.util.Optional;
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cfg.ComponentConfigService;
-import org.onosproject.cfg.ConfigProperty;
-import org.onosproject.cli.AbstractShellCommand;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-/**
- * Manages component configuration.
- */
-@Command(scope = "onos", name = "cfg",
- description = "Manages component configuration")
-public class ComponentConfigCommand extends AbstractShellCommand {
-
- static final String GET = "get";
- static final String SET = "set";
-
- private static final String FMT = " name=%s, type=%s, value=%s, defaultValue=%s, description=%s";
- private static final String SHORT_FMT = " %s=%s";
-
- @Option(name = "-s", aliases = "--short", description = "Show short output only",
- required = false, multiValued = false)
- private boolean shortOnly = false;
-
-
- @Argument(index = 0, name = "command",
- description = "Command name (get|set)",
- required = false, multiValued = false)
- String command = null;
-
- @Argument(index = 1, name = "component", description = "Component name",
- required = false, multiValued = false)
- String component = null;
-
- @Argument(index = 2, name = "name", description = "Property name",
- required = false, multiValued = false)
- String name = null;
-
- @Argument(index = 3, name = "value", description = "Property value",
- required = false, multiValued = false)
- String value = null;
-
- ComponentConfigService service;
-
- @Override
- protected void execute() {
- service = get(ComponentConfigService.class);
- if (isNullOrEmpty(command)) {
- listComponents();
- } else if (command.equals(GET) && isNullOrEmpty(component)) {
- listAllComponentsProperties();
- } else if (command.equals(GET) && isNullOrEmpty(name)) {
- listComponentProperties(component);
- } else if (command.equals(GET)) {
- listComponentProperty(component, name);
- } else if (command.equals(SET) && isNullOrEmpty(value)) {
- service.unsetProperty(component, name);
- } else if (command.equals(SET)) {
- service.setProperty(component, name, value);
- } else {
- error("Illegal usage");
- }
- }
-
- private void listAllComponentsProperties() {
- if (outputJson()) {
- print("%s", jsonComponentProperties());
- } else {
- service.getComponentNames().forEach(this::listComponentProperties);
- }
- }
-
- private JsonNode jsonProperty(ConfigProperty configProperty, ObjectMapper mapper) {
- return mapper.createObjectNode()
- .put("name", configProperty.name())
- .put("type", configProperty.type().toString().toLowerCase())
- .put("value", configProperty.value())
- .put("defaultValue", configProperty.defaultValue())
- .put("description", configProperty.description());
- }
-
- private JsonNode jsonComponent(String component, ObjectMapper mapper) {
- ObjectNode node = mapper.createObjectNode()
- .put("componentName", component);
- final ArrayNode propertiesJson = node.putArray("properties");
- Set<ConfigProperty> properties = service.getProperties(component);
- if (properties != null) {
- properties.forEach(configProperty -> propertiesJson.add(
- jsonProperty(configProperty, mapper)));
- }
- return node;
- }
-
- private JsonNode jsonComponentProperties() {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- service.getComponentNames()
- .forEach(component -> result.add(jsonComponent(component, mapper)));
-
- return result;
- }
-
- private void listComponents() {
- if (outputJson()) {
- ArrayNode node = new ObjectMapper().createArrayNode();
- service.getComponentNames().forEach(node::add);
- print("%s", node);
- } else {
- service.getComponentNames().forEach(n -> print("%s", n));
- }
- }
-
- private void listComponentProperties(String component) {
- if (outputJson()) {
- print("%s", jsonComponent(component, new ObjectMapper()));
- } else {
- Set<ConfigProperty> props = service.getProperties(component);
- print("%s", component);
- if (props == null) {
- print("No properties for component " + component + " found");
- } else if (shortOnly) {
- props.forEach(p -> print(SHORT_FMT, p.name(), p.value()));
- } else {
- props.forEach(p -> print(FMT, p.name(), p.type().toString().toLowerCase(),
- p.value(), p.defaultValue(), p.description()));
- }
- }
- }
-
- private void listComponentProperty(String component, String name) {
- Set<ConfigProperty> props = service.getProperties(component);
-
- if (props == null) {
- return;
- }
- Optional<ConfigProperty> property = props.stream()
- .filter(p -> p.name().equals(name)).findFirst();
- if (outputJson()) {
- print("%s", jsonProperty(property.get(), new ObjectMapper()));
- } else {
- if (!property.isPresent()) {
- print("Property " + name + " for component " + component + " not found");
- return;
- }
- ConfigProperty p = property.get();
- if (shortOnly) {
- print(SHORT_FMT, p.name(), p.value());
- } else {
- print(FMT, p.name(), p.type().toString().toLowerCase(), p.value(),
- p.defaultValue(), p.description());
- }
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommandCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommandCompleter.java
deleted file mode 100644
index 5506d816..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentConfigCommandCompleter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.cfg;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-import java.util.List;
-import java.util.SortedSet;
-
-import static org.onosproject.cli.cfg.ComponentConfigCommand.GET;
-import static org.onosproject.cli.cfg.ComponentConfigCommand.SET;
-
-/**
- * Component configuration command completer.
- */
-public class ComponentConfigCommandCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
- strings.add(GET);
- strings.add(SET);
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentNameCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentNameCompleter.java
deleted file mode 100644
index 4883b991..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentNameCompleter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.cfg;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cfg.ComponentConfigService;
-import org.onosproject.cli.AbstractShellCommand;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Component name completer.
- */
-public class ComponentNameCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- ComponentConfigService service = AbstractShellCommand.get(ComponentConfigService.class);
- SortedSet<String> strings = delegate.getStrings();
- service.getComponentNames().forEach(strings::add);
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentPropertyNameCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentPropertyNameCompleter.java
deleted file mode 100644
index 98e19690..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/ComponentPropertyNameCompleter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.cfg;
-
-import org.apache.karaf.shell.console.completer.ArgumentCompleter;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cfg.ComponentConfigService;
-import org.onosproject.cfg.ConfigProperty;
-import org.onosproject.cli.AbstractCompleter;
-
-import java.util.List;
-import java.util.Set;
-import java.util.SortedSet;
-
-import static org.onosproject.cli.AbstractShellCommand.get;
-
-/**
- * Component property name completer.
- */
-public class ComponentPropertyNameCompleter extends AbstractCompleter {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Component name is the previous argument.
- ArgumentCompleter.ArgumentList list = getArgumentList();
- String componentName = list.getArguments()[list.getCursorArgumentIndex() - 1];
- ComponentConfigService service = get(ComponentConfigService.class);
-
- SortedSet<String> strings = delegate.getStrings();
- Set<ConfigProperty> properties =
- service.getProperties(componentName);
- if (properties != null) {
- properties.forEach(property -> strings.add(property.name()));
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
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
deleted file mode 100644
index 7ce56692..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigCommand.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * 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.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;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.NetworkConfigService;
-import org.onosproject.net.config.SubjectFactory;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-
-/**
- * Manages network configuration.
- */
-@Command(scope = "onos", name = "netcfg",
- description = "Manages network configuration")
-public class NetworkConfigCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "subjectClassKey", description = "Subject class key",
- required = false, multiValued = false)
- String subjectClassKey = null;
-
- @Argument(index = 1, name = "subjectKey", description = "Subject key",
- required = false, multiValued = false)
- String subjectKey = null;
-
- @Argument(index = 2, name = "configKey", description = "Config key",
- required = false, multiValued = false)
- String configKey = null;
-
- private final ObjectMapper mapper = new ObjectMapper();
- private NetworkConfigService service;
-
- @Override
- protected void execute() {
- service = get(NetworkConfigService.class);
- JsonNode root = mapper.createObjectNode();
- if (isNullOrEmpty(subjectClassKey)) {
- addAll((ObjectNode) root);
- } else {
- SubjectFactory subjectFactory = service.getSubjectFactory(subjectClassKey);
- if (isNullOrEmpty(subjectKey)) {
- addSubjectClass((ObjectNode) root, subjectFactory);
- } else {
- Object s = subjectFactory.createSubject(subjectKey);
- if (isNullOrEmpty(configKey)) {
- addSubject((ObjectNode) root, s);
- } else {
- root = getSubjectConfig(getConfig(s, subjectClassKey, configKey));
- }
- }
- }
-
- 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(sc);
- addSubjectClass(newObject(root, sf.subjectClassKey()), sf);
- });
- }
-
- @SuppressWarnings("unchecked")
- private void addSubjectClass(ObjectNode root, SubjectFactory sf) {
- service.getSubjects(sf.subjectClass())
- .forEach(s -> addSubject(newObject(root, sf.subjectKey(s)), s));
- }
-
- private void addSubject(ObjectNode root, Object s) {
- service.getConfigs(s).forEach(c -> root.set(c.key(), c.node()));
- }
-
- private JsonNode getSubjectConfig(Config config) {
- return config != null ? config.node() : null;
- }
-
- private Config getConfig(Object s, String subjectKey, String ck) {
- Class<? extends Config> configClass = service.getConfigClass(subjectKey, ck);
- return configClass != null ? service.getConfig(s, configClass) : null;
- }
-
- private ObjectNode newObject(ObjectNode parent, String key) {
- ObjectNode node = mapper.createObjectNode();
- parent.set(key, node);
- return node;
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigRegistryCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigRegistryCommand.java
deleted file mode 100644
index cf588770..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/NetworkConfigRegistryCommand.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.cfg;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigRegistry;
-
-/**
- * Displays network configuration registry contents.
- */
-@Command(scope = "onos", name = "netcfg-registry",
- description = "Displays network configuration registry contents")
-public class NetworkConfigRegistryCommand extends AbstractShellCommand {
-
- private static final String FMT = "subjectKey=%s, configKey=%s, subjectClass=%s, configClass=%s";
- private static final String SHORT_FMT = "%-12s %-12s %-40s %s";
-
- @Option(name = "-s", aliases = "--short", description = "Show short output only",
- required = false, multiValued = false)
- private boolean shortOnly = false;
-
- @Override
- protected void execute() {
- get(NetworkConfigRegistry.class).getConfigFactories().forEach(this::print);
- }
-
- private void print(ConfigFactory configFactory) {
- print(shortOnly ? SHORT_FMT : FMT,
- configFactory.subjectFactory().subjectClassKey(),
- configFactory.configKey(),
- configFactory.subjectFactory().subjectClass().getName(),
- configFactory.configClass().getName());
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/package-info.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/package-info.java
deleted file mode 100644
index 0891ddb5..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/cfg/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * CLI commands for managing centralized component and network configurations.
- */
-package org.onosproject.cli.cfg; \ No newline at end of file
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
deleted file mode 100644
index cabf0b3a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddHostToHostIntentCommand.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2014-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.List;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.net.HostId;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.HostToHostIntent;
-import org.onosproject.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 ConnectivityIntentCommand {
-
- @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;
-
- @Override
- protected void execute() {
- IntentService service = get(IntentService.class);
-
- HostId oneId = HostId.hostId(one);
- HostId twoId = HostId.hostId(two);
-
- TrafficSelector selector = buildTrafficSelector();
- TrafficTreatment treatment = buildTrafficTreatment();
- List<Constraint> constraints = buildConstraints();
-
- HostToHostIntent intent = HostToHostIntent.builder()
- .appId(appId())
- .key(key())
- .one(oneId)
- .two(twoId)
- .selector(selector)
- .treatment(treatment)
- .constraints(constraints)
- .priority(priority())
- .build();
- service.submit(intent);
- print("Host to Host intent submitted:\n%s", intent.toString());
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMeter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMeter.java
deleted file mode 100644
index 5a431cd4..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMeter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.meter.Band;
-import org.onosproject.net.meter.DefaultBand;
-import org.onosproject.net.meter.DefaultMeterRequest;
-import org.onosproject.net.meter.Meter;
-import org.onosproject.net.meter.MeterRequest;
-import org.onosproject.net.meter.MeterService;
-
-import java.util.Collections;
-
-/**
- * Add a meter.
- */
-@Command(scope = "onos", name = "add-meter",
- description = "Adds a meter to a device (currently for testing)")
-public class AddMeter extends AbstractShellCommand {
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = true, multiValued = false)
- String uri = null;
-
- private final String appId = "org.onosproject.cli.meterCmd";
-
- @Override
- protected void execute() {
- MeterService service = get(MeterService.class);
- CoreService coreService = get(CoreService.class);
-
- DeviceId deviceId = DeviceId.deviceId(uri);
-
- Band band = DefaultBand.builder()
- .ofType(Band.Type.DROP)
- .withRate(500)
- .build();
-
-
- MeterRequest request = DefaultMeterRequest.builder()
- .forDevice(deviceId)
- .fromApp(coreService.registerApplication(appId))
- .withUnit(Meter.Unit.KB_PER_SEC)
- .withBands(Collections.singleton(band))
- .add();
-
- service.submit(request);
-
- }
-}
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
deleted file mode 100644
index a736f99a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMplsIntent.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * 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;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.MplsLabel;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.MplsIntent;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Installs MPLS intents.
- */
-@Command(scope = "onos", name = "add-mpls-intent", description = "Installs mpls connectivity intent")
-public class AddMplsIntent extends ConnectivityIntentCommand {
-
- @Argument(index = 0, name = "ingressDevice",
- description = "Ingress Device/Port Description",
- required = true,
- multiValued = false)
- private String ingressDeviceString = null;
-
- @Option(name = "--ingressLabel",
- description = "Ingress Mpls label",
- required = false,
- multiValued = false)
- private String ingressLabelString = "";
-
- @Argument(index = 1, name = "egressDevice",
- description = "Egress Device/Port Description",
- required = true,
- multiValued = false)
- private String egressDeviceString = null;
-
- @Option(name = "--egressLabel",
- description = "Egress Mpls label",
- required = false,
- multiValued = false)
- private String egressLabelString = "";
-
- @Override
- protected void execute() {
- IntentService service = get(IntentService.class);
-
- ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
- Optional<MplsLabel> ingressLabel = Optional.empty();
- if (!ingressLabelString.isEmpty()) {
- ingressLabel = Optional
- .ofNullable(MplsLabel.mplsLabel(parseInt(ingressLabelString)));
- }
-
- ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
- Optional<MplsLabel> egressLabel = Optional.empty();
- if (!egressLabelString.isEmpty()) {
- egressLabel = Optional
- .ofNullable(MplsLabel.mplsLabel(parseInt(egressLabelString)));
- }
-
- TrafficSelector selector = buildTrafficSelector();
- TrafficTreatment treatment = buildTrafficTreatment();
-
- List<Constraint> constraints = buildConstraints();
-
- MplsIntent intent = MplsIntent.builder()
- .appId(appId())
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(ingress)
- .ingressLabel(ingressLabel)
- .egressPoint(egress)
- .egressLabel(egressLabel)
- .constraints(constraints)
- .priority(priority())
- .build();
- service.submit(intent);
- }
-
- protected Integer parseInt(String value) {
- try {
- return Integer.parseInt(value);
- } catch (NumberFormatException nfe) {
- return null;
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java
deleted file mode 100644
index dc792f49..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddMultiPointToSinglePointIntentCommand.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.MultiPointToSinglePointIntent;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Installs connectivity intent between multiple ingress devices and a single egress device.
- */
-@Command(scope = "onos", name = "add-multi-to-single-intent",
- description = "Installs connectivity intent between multiple ingress devices and a single egress device")
-public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentCommand {
-
- @Argument(index = 0, name = "ingressDevices egressDevice",
- description = "ingressDevice/Port..ingressDevice/Port egressDevice/Port",
- required = true, multiValued = true)
- String[] deviceStrings = null;
-
- @Override
- protected void execute() {
- IntentService service = get(IntentService.class);
-
- if (deviceStrings.length < 2) {
- return;
- }
-
- String egressDeviceString = deviceStrings[deviceStrings.length - 1];
- ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
-
- Set<ConnectPoint> ingressPoints = new HashSet<>();
- for (int index = 0; index < deviceStrings.length - 1; index++) {
- String ingressDeviceString = deviceStrings[index];
- ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
- ingressPoints.add(ingress);
- }
-
- TrafficSelector selector = buildTrafficSelector();
- TrafficTreatment treatment = buildTrafficTreatment();
- List<Constraint> constraints = buildConstraints();
-
- Intent intent = MultiPointToSinglePointIntent.builder()
- .appId(appId())
- .key(key())
- .selector(selector)
- .treatment(treatment)
- .ingressPoints(ingressPoints)
- .egressPoint(egress)
- .constraints(constraints)
- .priority(priority())
- .build();
- service.submit(intent);
- print("Multipoint to single point intent submitted:\n%s", intent.toString());
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
deleted file mode 100644
index 1049d90d..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.OchPort;
-import org.onosproject.net.OduCltPort;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.OduSignalType;
-import org.onosproject.net.Port;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.OpticalCircuitIntent;
-import org.onosproject.net.intent.OpticalConnectivityIntent;
-
-import java.util.List;
-
-import static com.google.common.base.Preconditions.checkArgument;
-
-/**
- * Installs optical connectivity or circuit intents, depending on given port types.
- */
-@Command(scope = "onos", name = "add-optical-intent",
- description = "Installs optical connectivity intent")
-public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
-
- @Argument(index = 0, name = "ingressDevice",
- description = "Ingress Device/Port Description",
- required = true, multiValued = false)
- String ingressDeviceString = "";
-
- @Argument(index = 1, name = "egressDevice",
- description = "Egress Device/Port Description",
- required = true, multiValued = false)
- String egressDeviceString = "";
-
- @Option(name = "-b", aliases = "--bidirectional",
- description = "If this argument is passed the optical link created will be bidirectional, " +
- "else the link will be unidirectional.",
- required = false, multiValued = false)
- private boolean bidirectional = false;
-
-
- private ConnectPoint createConnectPoint(String devicePortString) {
- String[] splitted = devicePortString.split("/");
-
- checkArgument(splitted.length == 2,
- "Connect point must be in \"deviceUri/portNumber\" format");
-
- DeviceId deviceId = DeviceId.deviceId(splitted[0]);
- DeviceService deviceService = get(DeviceService.class);
-
- List<Port> ports = deviceService.getPorts(deviceId);
-
- for (Port port : ports) {
- if (splitted[1].equals(port.number().name())) {
- return new ConnectPoint(deviceId, port.number());
- }
- }
-
- return null;
- }
-
- @Override
- protected void execute() {
- IntentService service = get(IntentService.class);
-
- ConnectPoint ingress = createConnectPoint(ingressDeviceString);
- ConnectPoint egress = createConnectPoint(egressDeviceString);
-
- if (ingress == null || egress == null) {
- print("Invalid endpoint(s); could not create optical intent");
- return;
- }
-
- DeviceService deviceService = get(DeviceService.class);
- Port srcPort = deviceService.getPort(ingress.deviceId(), ingress.port());
- Port dstPort = deviceService.getPort(egress.deviceId(), egress.port());
-
- Intent intent;
- // FIXME: Hardcoded signal types
- if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
- intent = OpticalCircuitIntent.builder()
- .appId(appId())
- .key(key())
- .src(ingress)
- .dst(egress)
- .signalType(OduCltPort.SignalType.CLT_10GBE)
- .bidirectional(bidirectional)
- .build();
- } else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
- intent = OpticalConnectivityIntent.builder()
- .appId(appId())
- .key(key())
- .src(ingress)
- .dst(egress)
- .signalType(OduSignalType.ODU4)
- .bidirectional(bidirectional)
- .build();
- } else {
- print("Unable to create optical intent between connect points {} and {}", ingress, egress);
- return;
- }
-
- service.submit(intent);
- print("Optical intent submitted:\n%s", intent.toString());
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
deleted file mode 100644
index 7c27dd3d..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddPointToPointIntentCommand.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.PointToPointIntent;
-
-import java.util.List;
-
-/**
- * Installs point-to-point connectivity intents.
- */
-@Command(scope = "onos", name = "add-point-intent",
- description = "Installs point-to-point connectivity intent")
-public class AddPointToPointIntentCommand extends ConnectivityIntentCommand {
-
- @Argument(index = 0, name = "ingressDevice",
- description = "Ingress Device/Port Description",
- required = true, multiValued = false)
- String ingressDeviceString = null;
-
- @Argument(index = 1, name = "egressDevice",
- description = "Egress Device/Port Description",
- required = true, multiValued = false)
- String egressDeviceString = null;
-
- @Override
- protected void execute() {
- IntentService service = get(IntentService.class);
-
- ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
-
- ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
-
- TrafficSelector selector = buildTrafficSelector();
- TrafficTreatment treatment = buildTrafficTreatment();
-
- List<Constraint> constraints = buildConstraints();
-
- Intent intent = PointToPointIntent.builder()
- .appId(appId())
- .key(key())
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(ingress)
- .egressPoint(egress)
- .constraints(constraints)
- .priority(priority())
- .build();
- service.submit(intent);
- print("Point to point intent submitted:\n%s", intent.toString());
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
deleted file mode 100644
index 2939afae..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddSinglePointToMultiPointIntentCommand.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.SinglePointToMultiPointIntent;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Installs connectivity intent between a single ingress device and multiple egress devices.
- */
-@Command(scope = "onos", name = "add-single-to-multi-intent",
- description = "Installs connectivity intent between a single ingress device and multiple egress devices")
-public class AddSinglePointToMultiPointIntentCommand extends ConnectivityIntentCommand {
- @Argument(index = 0, name = "ingressDevice egressDevices",
- description = "ingressDevice/Port egressDevice/Port...egressDevice/Port",
- required = true, multiValued = true)
- String[] deviceStrings = null;
-
- @Override
- protected void execute() {
- IntentService service = get(IntentService.class);
-
- if (deviceStrings.length < 2) {
- return;
- }
-
- String ingressDeviceString = deviceStrings[0];
- ConnectPoint ingressPoint = ConnectPoint.deviceConnectPoint(ingressDeviceString);
-
- Set<ConnectPoint> egressPoints = new HashSet<>();
- for (int index = 1; index < deviceStrings.length; index++) {
- String egressDeviceString = deviceStrings[index];
- ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
- egressPoints.add(egress);
- }
-
- TrafficSelector selector = buildTrafficSelector();
- TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
- List<Constraint> constraints = buildConstraints();
-
- SinglePointToMultiPointIntent intent =
- SinglePointToMultiPointIntent.builder()
- .appId(appId())
- .key(key())
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(ingressPoint)
- .egressPoints(egressPoints)
- .constraints(constraints)
- .priority(priority())
- .build();
- service.submit(intent);
- print("Single point to multipoint intent submitted:\n%s", intent.toString());
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddTestFlowsCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddTestFlowsCommand.java
deleted file mode 100644
index e1e158ab..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AddTestFlowsCommand.java
+++ /dev/null
@@ -1,170 +0,0 @@
-
-/*
- * Copyright 2014-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 com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.base.Stopwatch;
-import com.google.common.collect.Lists;
-import org.apache.commons.lang.math.RandomUtils;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.Device;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.DefaultFlowRule;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.flow.FlowRuleOperations;
-import org.onosproject.net.flow.FlowRuleOperationsContext;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-
-import java.util.ArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Installs bulk flows.
- */
-@Command(scope = "onos", name = "add-test-flows",
- description = "Installs a number of test flow rules - for testing only")
-public class AddTestFlowsCommand extends AbstractShellCommand {
-
- private CountDownLatch latch;
-
- @Argument(index = 0, name = "flowPerDevice", description = "Number of flows to add per device",
- required = true, multiValued = false)
- String flows = null;
-
- @Argument(index = 1, name = "numOfRuns", description = "Number of iterations",
- required = true, multiValued = false)
- String numOfRuns = null;
-
- @Override
- protected void execute() {
- FlowRuleService flowService = get(FlowRuleService.class);
- DeviceService deviceService = get(DeviceService.class);
- CoreService coreService = get(CoreService.class);
-
- ApplicationId appId = coreService.registerApplication("onos.test.flow.installer");
-
- int flowsPerDevice = Integer.parseInt(flows);
- int num = Integer.parseInt(numOfRuns);
-
- ArrayList<Long> results = Lists.newArrayList();
- Iterable<Device> devices = deviceService.getDevices();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(PortNumber.portNumber(RandomUtils.nextInt())).build();
- TrafficSelector.Builder sbuilder;
- FlowRuleOperations.Builder rules = FlowRuleOperations.builder();
- FlowRuleOperations.Builder remove = FlowRuleOperations.builder();
-
- for (Device d : devices) {
- for (int i = 0; i < flowsPerDevice; i++) {
- sbuilder = DefaultTrafficSelector.builder();
-
- sbuilder.matchEthSrc(MacAddress.valueOf(RandomUtils.nextInt() * i))
- .matchEthDst(MacAddress.valueOf((Integer.MAX_VALUE - i) * RandomUtils.nextInt()));
-
-
- int randomPriority = RandomUtils.nextInt();
-
- FlowRule addRule = DefaultFlowRule.builder()
- .forDevice(d.id())
- .withSelector(sbuilder.build())
- .withTreatment(treatment)
- .withPriority(randomPriority)
- .fromApp(appId)
- .makeTemporary(10)
- .build();
- FlowRule removeRule = DefaultFlowRule.builder()
- .forDevice(d.id())
- .withSelector(sbuilder.build())
- .withTreatment(treatment)
- .withPriority(randomPriority)
- .fromApp(appId)
- .makeTemporary(10)
- .build();
-
- rules.add(addRule);
- remove.remove(removeRule);
-
- }
- }
-
- for (int i = 0; i < num; i++) {
- latch = new CountDownLatch(2);
- flowService.apply(rules.build(new FlowRuleOperationsContext() {
-
- private final Stopwatch timer = Stopwatch.createStarted();
-
- @Override
- public void onSuccess(FlowRuleOperations ops) {
-
- timer.stop();
- results.add(timer.elapsed(TimeUnit.MILLISECONDS));
- if (results.size() == num) {
- if (outputJson()) {
- print("%s", json(new ObjectMapper(), true, results));
- } else {
- printTime(true, results);
- }
- }
- latch.countDown();
- }
- }));
-
- flowService.apply(remove.build(new FlowRuleOperationsContext() {
- @Override
- public void onSuccess(FlowRuleOperations ops) {
- latch.countDown();
- }
- }));
- try {
- latch.await();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- }
- }
-
- private Object json(ObjectMapper mapper, boolean isSuccess, ArrayList<Long> elapsed) {
- ObjectNode result = mapper.createObjectNode();
- result.put("Success", isSuccess);
- ArrayNode node = result.putArray("elapsed-time");
- for (Long v : elapsed) {
- node.add(v);
- }
- return result;
- }
-
- private void printTime(boolean isSuccess, ArrayList<Long> elapsed) {
- print("Run is %s.", isSuccess ? "success" : "failure");
- for (int i = 0; i < elapsed.size(); i++) {
- print(" Run %s : %s", i, elapsed.get(i));
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AnnotateDeviceCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AnnotateDeviceCommand.java
deleted file mode 100644
index 113fe316..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/AnnotateDeviceCommand.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.device.DefaultDeviceDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceProvider;
-import org.onosproject.net.device.DeviceProviderRegistry;
-import org.onosproject.net.device.DeviceProviderService;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.provider.AbstractProvider;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Annotates network device model.
- */
-@Command(scope = "onos", name = "annotate-device",
- description = "Annotates network model entities")
-public class AnnotateDeviceCommand extends AbstractShellCommand {
-
- static final ProviderId PID = new ProviderId("cli", "org.onosproject.cli", true);
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = true, multiValued = false)
- String uri = null;
-
- @Argument(index = 1, name = "key", description = "Annotation key",
- required = true, multiValued = false)
- String key = null;
-
- @Argument(index = 2, name = "value",
- description = "Annotation value (null to remove)",
- required = false, multiValued = false)
- String value = null;
-
- @Override
- protected void execute() {
- DeviceService service = get(DeviceService.class);
- Device device = service.getDevice(DeviceId.deviceId(uri));
-
- DeviceProviderRegistry registry = get(DeviceProviderRegistry.class);
- DeviceProvider provider = new AnnotationProvider();
- try {
- DeviceProviderService providerService = registry.register(provider);
- providerService.deviceConnected(device.id(), description(device, key, value));
- } finally {
- registry.unregister(provider);
- }
- }
-
- private DeviceDescription description(Device device, String key, String value) {
- DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
- if (value != null) {
- builder.set(key, value);
- } else {
- builder.remove(key);
- }
- return new DefaultDeviceDescription(device.id().uri(), device.type(),
- device.manufacturer(), device.hwVersion(),
- device.swVersion(), device.serialNumber(),
- device.chassisId(), builder.build());
- }
-
- // Token provider entity
- private static final class AnnotationProvider
- extends AbstractProvider implements DeviceProvider {
- private AnnotationProvider() {
- super(PID);
- }
-
- @Override
- public void triggerProbe(DeviceId deviceId) {
- }
-
- @Override
- public void roleChanged(DeviceId deviceId, MastershipRole newRole) {
- }
-
- @Override
- public boolean isReachable(DeviceId deviceId) {
- return false;
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterDevicesCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterDevicesCommand.java
deleted file mode 100644
index 88c8a8bd..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterDevicesCommand.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2014-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 com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.Comparators;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.topology.TopologyCluster;
-
-import java.util.Collections;
-import java.util.List;
-
-import static org.onosproject.cli.MastersListCommand.json;
-import static org.onosproject.net.topology.ClusterId.clusterId;
-
-/**
- * Lists devices of the specified topology cluster in the current topology.
- */
-@Command(scope = "onos", name = "cluster-devices",
- description = "Lists devices of the specified topology cluster in the current topology")
-public class ClusterDevicesCommand extends ClustersListCommand {
-
- @Argument(index = 0, name = "id", description = "Cluster ID",
- required = true, multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- int cid = Integer.parseInt(id);
- init();
- TopologyCluster cluster = service.getCluster(topology, clusterId(cid));
- if (cluster == null) {
- error("No such cluster %s", cid);
- } else {
- List<DeviceId> ids = Lists.newArrayList(service.getClusterDevices(topology, cluster));
- Collections.sort(ids, Comparators.ELEMENT_ID_COMPARATOR);
- if (outputJson()) {
- print("%s", json(new ObjectMapper(), ids));
- } else {
- for (DeviceId deviceId : ids) {
- print("%s", deviceId);
- }
- }
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterIdCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterIdCompleter.java
deleted file mode 100644
index 73e8acba..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterIdCompleter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2014 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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.topology.Topology;
-import org.onosproject.net.topology.TopologyCluster;
-import org.onosproject.net.topology.TopologyService;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Cluster ID completer.
- */
-public class ClusterIdCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- TopologyService service = AbstractShellCommand.get(TopologyService.class);
- Topology topology = service.currentTopology();
-
- SortedSet<String> strings = delegate.getStrings();
- for (TopologyCluster cluster : service.getClusters(topology)) {
- strings.add(Integer.toString(cluster.id().index()));
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterLinksCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterLinksCommand.java
deleted file mode 100644
index dc63bff9..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClusterLinksCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.net.Link;
-import org.onosproject.net.topology.TopologyCluster;
-
-import static org.onosproject.cli.net.LinksListCommand.json;
-import static org.onosproject.cli.net.LinksListCommand.linkString;
-import static org.onosproject.net.topology.ClusterId.clusterId;
-
-/**
- * Lists links of the specified topology cluster in the current topology.
- */
-@Command(scope = "onos", name = "cluster-links",
- description = "Lists links of the specified topology cluster in the current topology")
-public class ClusterLinksCommand extends ClustersListCommand {
-
- @Argument(index = 0, name = "id", description = "Cluster ID",
- required = true, multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- int cid = Integer.parseInt(id);
- init();
- TopologyCluster cluster = service.getCluster(topology, clusterId(cid));
- if (cluster == null) {
- error("No such cluster %s", cid);
- } else if (outputJson()) {
- print("%s", json(this, service.getClusterLinks(topology, cluster)));
- } else {
- for (Link link : service.getClusterLinks(topology, cluster)) {
- print(linkString(link));
- }
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClustersListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClustersListCommand.java
deleted file mode 100644
index 21c27324..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ClustersListCommand.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2014 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 com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.google.common.collect.Lists;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.Comparators;
-import org.onosproject.net.topology.TopologyCluster;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Lists all clusters in the current topology.
- */
-@Command(scope = "onos", name = "clusters",
- description = "Lists all clusters in the current topology")
-public class ClustersListCommand extends TopologyCommand {
-
- private static final String FMT =
- "id=%d, devices=%d, links=%d";
-
- @Override
- protected void execute() {
- init();
- List<TopologyCluster> clusters = Lists.newArrayList(service.getClusters(topology));
- Collections.sort(clusters, Comparators.CLUSTER_COMPARATOR);
-
- if (outputJson()) {
- print("%s", json(clusters));
- } else {
- for (TopologyCluster cluster : clusters) {
- print(FMT, cluster.id().index(), cluster.deviceCount(), cluster.linkCount());
- }
- }
- }
-
- // Produces a JSON result.
- private JsonNode json(Iterable<TopologyCluster> clusters) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
-
- clusters.spliterator()
- .forEachRemaining(cluster ->
- result.add(jsonForEntity(cluster, TopologyCluster.class)));
-
- return result;
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectPointCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectPointCompleter.java
deleted file mode 100644
index 5e2727cf..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectPointCompleter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014 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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.Device;
-import org.onosproject.net.Port;
-import org.onosproject.net.device.DeviceService;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * ConnectPoint completer.
- */
-public class ConnectPointCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- DeviceService service = AbstractShellCommand.get(DeviceService.class);
-
- // Generate the device ID/port number identifiers
- for (Device device : service.getDevices()) {
- SortedSet<String> strings = delegate.getStrings();
- for (Port port : service.getPorts(device.id())) {
- if (!port.number().isLogical()) {
- strings.add(device.id().toString() + "/" + port.number());
- }
- }
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
deleted file mode 100644
index 713b4b5a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ConnectivityIntentCommand.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Copyright 2014-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.Option;
-import org.onlab.packet.Ip6Address;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.TpPort;
-import org.onlab.packet.VlanId;
-import org.onlab.util.Bandwidth;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.EncapsulationType;
-import org.onosproject.net.Link;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.constraint.BandwidthConstraint;
-import org.onosproject.net.intent.constraint.EncapsulationConstraint;
-import org.onosproject.net.intent.constraint.LambdaConstraint;
-import org.onosproject.net.intent.constraint.LinkTypeConstraint;
-import org.onosproject.net.intent.constraint.PartialFailureConstraint;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onosproject.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;
-
- @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 = null;
-
- @Option(name = "-v", aliases = "--vlan", description = "VLAN ID",
- required = false, multiValued = false)
- private String vlanString = null;
-
- @Option(name = "--ipProto", description = "IP Protocol",
- required = false, multiValued = false)
- private String ipProtoString = null;
-
- @Option(name = "--ipSrc", description = "Source IP Prefix",
- required = false, multiValued = false)
- private String srcIpString = null;
-
- @Option(name = "--ipDst", description = "Destination IP Prefix",
- required = false, multiValued = false)
- private String dstIpString = null;
-
- @Option(name = "--fLabel", description = "IPv6 Flow Label",
- required = false, multiValued = false)
- private String fLabelString = null;
-
- @Option(name = "--icmp6Type", description = "ICMPv6 Type",
- required = false, multiValued = false)
- private String icmp6TypeString = null;
-
- @Option(name = "--icmp6Code", description = "ICMPv6 Code",
- required = false, multiValued = false)
- private String icmp6CodeString = null;
-
- @Option(name = "--ndTarget", description = "IPv6 Neighbor Discovery Target Address",
- required = false, multiValued = false)
- private String ndTargetString = null;
-
- @Option(name = "--ndSLL", description = "IPv6 Neighbor Discovery Source Link-Layer",
- required = false, multiValued = false)
- private String ndSllString = null;
-
- @Option(name = "--ndTLL", description = "IPv6 Neighbor Discovery Target Link-Layer",
- required = false, multiValued = false)
- private String ndTllString = null;
-
- @Option(name = "--tcpSrc", description = "Source TCP Port",
- required = false, multiValued = false)
- private String srcTcpString = null;
-
- @Option(name = "--tcpDst", description = "Destination TCP Port",
- required = false, multiValued = false)
- private String dstTcpString = null;
-
- @Option(name = "--extHdr", description = "IPv6 Extension Header Pseudo-field",
- required = false, multiValued = true)
- private List<String> extHdrStringList = null;
-
- @Option(name = "-a", aliases = "--appId", description = "Application Id",
- required = false, multiValued = false)
- private String appId = null;
-
- @Option(name = "-k", aliases = "--key", description = "Intent Key",
- required = false, multiValued = false)
- private String intentKey = null;
-
-
- // 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;
-
- @Option(name = "--setIpSrc", description = "Rewrite Source IP Address",
- required = false, multiValued = false)
- private String setIpSrcString = null;
-
- @Option(name = "--setIpDst", description = "Rewrite Destination IP Address",
- required = false, multiValued = false)
- private String setIpDstString = null;
-
- @Option(name = "--setVlan", description = "Rewrite VLAN ID",
- required = false, multiValued = false)
- private String setVlan = null;
-
- @Option(name = "--popVlan", description = "Pop VLAN Tag",
- required = false, multiValued = false)
- private boolean popVlan = false;
-
- @Option(name = "--pushVlan", description = "Push VLAN ID",
- required = false, multiValued = false)
- private String pushVlan = null;
-
- @Option(name = "--setQueue", description = "Set Queue ID (for OpenFlow 1.0, " +
- "also the port has to be specified, i.e., <port>/<queue>",
- required = false, multiValued = false)
- private String setQueue = null;
-
- // Priorities
- @Option(name = "-p", aliases = "--priority", description = "Priority",
- required = false, multiValued = false)
- private int priority = Intent.DEFAULT_INTENT_PRIORITY;
-
- // Constraints
- @Option(name = "-b", aliases = "--bandwidth", description = "Bandwidth",
- required = false, multiValued = false)
- private String bandwidthString = null;
-
- @Option(name = "-l", aliases = "--lambda", description = "Lambda",
- required = false, multiValued = false)
- private boolean lambda = false;
-
- @Option(name = "--partial", description = "Allow partial installation",
- required = false, multiValued = false)
- private boolean partial = false;
-
- @Option(name = "-e", aliases = "--encapsulation", description = "Encapsulation type",
- required = false, multiValued = false)
- private String encapsulationString = null;
-
-
- /**
- * Constructs a traffic selector based on the command line arguments
- * presented to the command.
- * @return traffic selector
- */
- protected TrafficSelector buildTrafficSelector() {
- IpPrefix srcIpPrefix = null;
- IpPrefix dstIpPrefix = null;
-
- TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
-
- if (!isNullOrEmpty(srcIpString)) {
- srcIpPrefix = IpPrefix.valueOf(srcIpString);
- if (srcIpPrefix.isIp4()) {
- selectorBuilder.matchIPSrc(srcIpPrefix);
- } else {
- selectorBuilder.matchIPv6Src(srcIpPrefix);
- }
- }
-
- if (!isNullOrEmpty(dstIpString)) {
- dstIpPrefix = IpPrefix.valueOf(dstIpString);
- if (dstIpPrefix.isIp4()) {
- selectorBuilder.matchIPDst(dstIpPrefix);
- } else {
- selectorBuilder.matchIPv6Dst(dstIpPrefix);
- }
- }
-
- if ((srcIpPrefix != null) && (dstIpPrefix != null) &&
- (srcIpPrefix.version() != dstIpPrefix.version())) {
- // ERROR: IP src/dst version mismatch
- throw new IllegalArgumentException(
- "IP source and destination version mismatch");
- }
-
- //
- // Set the default EthType based on the IP version if the matching
- // source or destination IP prefixes.
- //
- Short ethType = null;
- if ((srcIpPrefix != null) && srcIpPrefix.isIp6()) {
- ethType = EthType.IPV6.value();
- }
- if ((dstIpPrefix != null) && dstIpPrefix.isIp6()) {
- ethType = EthType.IPV6.value();
- }
- if (!isNullOrEmpty(ethTypeString)) {
- ethType = EthType.parseFromString(ethTypeString);
- }
- if (ethType != null) {
- selectorBuilder.matchEthType(ethType);
- }
- if (!isNullOrEmpty(vlanString)) {
- selectorBuilder.matchVlanId(VlanId.vlanId(Short.parseShort(vlanString)));
- }
- if (!isNullOrEmpty(srcMacString)) {
- selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString));
- }
-
- if (!isNullOrEmpty(dstMacString)) {
- selectorBuilder.matchEthDst(MacAddress.valueOf(dstMacString));
- }
-
- if (!isNullOrEmpty(ipProtoString)) {
- short ipProtoShort = IpProtocol.parseFromString(ipProtoString);
- selectorBuilder.matchIPProtocol((byte) ipProtoShort);
- }
-
- if (!isNullOrEmpty(fLabelString)) {
- selectorBuilder.matchIPv6FlowLabel(Integer.parseInt(fLabelString));
- }
-
- if (!isNullOrEmpty(icmp6TypeString)) {
- byte icmp6Type = Icmp6Type.parseFromString(icmp6TypeString);
- selectorBuilder.matchIcmpv6Type(icmp6Type);
- }
-
- if (!isNullOrEmpty(icmp6CodeString)) {
- byte icmp6Code = Icmp6Code.parseFromString(icmp6CodeString);
- selectorBuilder.matchIcmpv6Code(icmp6Code);
- }
-
- if (!isNullOrEmpty(ndTargetString)) {
- selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString));
- }
-
- if (!isNullOrEmpty(ndSllString)) {
- selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSllString));
- }
-
- if (!isNullOrEmpty(ndTllString)) {
- selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTllString));
- }
-
- if (!isNullOrEmpty(srcTcpString)) {
- selectorBuilder.matchTcpSrc(TpPort.tpPort(Integer.parseInt(srcTcpString)));
- }
-
- if (!isNullOrEmpty(dstTcpString)) {
- selectorBuilder.matchTcpDst(TpPort.tpPort(Integer.parseInt(dstTcpString)));
- }
-
- if (extHdrStringList != null) {
- short extHdr = 0;
- for (String extHdrString : extHdrStringList) {
- extHdr = (short) (extHdr | ExtHeader.parseFromString(extHdrString));
- }
- selectorBuilder.matchIPv6ExthdrFlags(extHdr);
- }
-
- return selectorBuilder.build();
- }
-
- /**
- * 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 treatmentBuilder = builder();
- boolean emptyTreatment = true;
-
- if (!isNullOrEmpty(setEthSrcString)) {
- treatmentBuilder.setEthSrc(MacAddress.valueOf(setEthSrcString));
- emptyTreatment = false;
- }
-
- if (!isNullOrEmpty(setEthDstString)) {
- treatmentBuilder.setEthDst(MacAddress.valueOf(setEthDstString));
- emptyTreatment = false;
- }
-
- if (!isNullOrEmpty(setIpSrcString)) {
- treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpSrcString));
- emptyTreatment = false;
- }
-
- if (!isNullOrEmpty(setIpDstString)) {
- treatmentBuilder.setIpSrc(IpAddress.valueOf(setIpDstString));
- emptyTreatment = false;
- }
- if (!isNullOrEmpty(setVlan)) {
- treatmentBuilder.setVlanId(VlanId.vlanId(Short.parseShort(setVlan)));
- emptyTreatment = false;
- }
- if (popVlan) {
- treatmentBuilder.popVlan();
- emptyTreatment = false;
- }
- if (!isNullOrEmpty(pushVlan)) {
- treatmentBuilder.pushVlan();
- treatmentBuilder.setVlanId(VlanId.vlanId(Short.parseShort(pushVlan)));
- emptyTreatment = false;
- }
- if (!isNullOrEmpty(setQueue)) {
- // OpenFlow 1.0 notation (for ENQUEUE): <port>/<queue>
- if (setQueue.contains("/")) {
- String[] queueConfig = setQueue.split("/");
- PortNumber port = PortNumber.portNumber(Long.parseLong(queueConfig[0]));
- long queueId = Long.parseLong(queueConfig[1]);
- treatmentBuilder.setQueue(queueId, port);
- } else {
- treatmentBuilder.setQueue(Long.parseLong(setQueue));
- }
- emptyTreatment = false;
- }
-
- if (emptyTreatment) {
- return DefaultTrafficTreatment.emptyTreatment();
- } else {
- return treatmentBuilder.build();
- }
- }
-
- /**
- * Builds the constraint list for this command based on the command line
- * parameters.
- *
- * @return List of constraint objects describing the constraints requested
- */
- protected List<Constraint> buildConstraints() {
- final List<Constraint> constraints = new LinkedList<>();
-
- // Check for a bandwidth specification
- if (!isNullOrEmpty(bandwidthString)) {
- final Bandwidth bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
- constraints.add(new BandwidthConstraint(bandwidth));
- }
-
- // Check for a lambda specification
- if (lambda) {
- constraints.add(new LambdaConstraint(null));
- }
- constraints.add(new LinkTypeConstraint(lambda, Link.Type.OPTICAL));
-
- // Check for partial failure specification
- if (partial) {
- constraints.add(new PartialFailureConstraint());
- }
-
- // Check for encapsulation specification
- if (!isNullOrEmpty(encapsulationString)) {
- final EncapsulationType encapType = EncapsulationType.valueOf(encapsulationString);
- constraints.add(new EncapsulationConstraint(encapType));
- }
-
- return constraints;
- }
-
- @Override
- protected ApplicationId appId() {
- ApplicationId appIdForIntent;
- if (appId == null) {
- appIdForIntent = super.appId();
- } else {
- CoreService service = get(CoreService.class);
- appIdForIntent = service.getAppId(appId);
- }
- return appIdForIntent;
- }
-
- /**
- * Creates a key for an intent based on command line arguments. If a key
- * has been specified, it is returned. If no key is specified, null
- * is returned.
- *
- * @return intent key if specified, null otherwise
- */
- protected Key key() {
- Key key = null;
- ApplicationId appIdForIntent;
-
- if (intentKey != null) {
- key = Key.of(intentKey, appId());
- }
- return key;
- }
-
- /**
- * Gets the priority to use for the intent.
- *
- * @return priority
- */
- protected int priority() {
- return priority;
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/CountersListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/CountersListCommand.java
deleted file mode 100644
index a44fdc9f..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/CountersListCommand.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.Map;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.service.StorageAdminService;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Command to list the various counters in the system.
- */
-@Command(scope = "onos", name = "counters",
- description = "Lists information about atomic counters in the system")
-public class CountersListCommand extends AbstractShellCommand {
-
- private static final String FMT = "name=%s value=%d";
-
- /**
- * Displays counters as text.
- *
- * @param counters counter info
- */
- private void displayCounters(Map<String, Long> counters) {
- counters.forEach((name, value) -> print(FMT, name, value));
- }
-
- /**
- * Converts info for counters into a JSON object.
- *
- * @param counters counter info
- */
- private JsonNode json(Map<String, Long> counters) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode jsonCounters = mapper.createArrayNode();
-
- // Create a JSON node for each counter
- counters.forEach((name, value) -> {
- ObjectNode jsonCounter = mapper.createObjectNode();
- jsonCounter.put("name", name)
- .put("value", value);
- jsonCounters.add(jsonCounter);
- });
-
- return jsonCounters;
- }
-
- /**
- * Converts info for counters from different databases into a JSON object.
- *
- * @param partitionedDbCounters counters info
- * @param inMemoryDbCounters counters info
- */
- private JsonNode jsonAllCounters(Map<String, Long> partitionedDbCounters,
- Map<String, Long> inMemoryDbCounters) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode jsonCounters = mapper.createArrayNode();
-
- // Create a JSON node for partitioned database counter
- ObjectNode jsonPartitionedDatabaseCounters = mapper.createObjectNode();
- jsonPartitionedDatabaseCounters.set("partitionedDatabaseCounters",
- json(partitionedDbCounters));
- jsonCounters.add(jsonPartitionedDatabaseCounters);
- // Create a JSON node for in-memory database counter
- ObjectNode jsonInMemoryDatabseCounters = mapper.createObjectNode();
- jsonInMemoryDatabseCounters.set("inMemoryDatabaseCounters",
- json(inMemoryDbCounters));
- jsonCounters.add(jsonInMemoryDatabseCounters);
-
- return jsonCounters;
- }
-
-
- @Override
- protected void execute() {
- StorageAdminService storageAdminService = get(StorageAdminService.class);
- Map<String, Long> partitionedDatabaseCounters = storageAdminService.getPartitionedDatabaseCounters();
- Map<String, Long> inMemoryDatabaseCounters = storageAdminService.getInMemoryDatabaseCounters();
- if (outputJson()) {
- print("%s", jsonAllCounters(partitionedDatabaseCounters, inMemoryDatabaseCounters));
- } else {
- print("Partitioned database counters:");
- displayCounters(partitionedDatabaseCounters);
- print("In-memory database counters:");
- displayCounters(inMemoryDatabaseCounters);
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceControllersCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceControllersCommand.java
deleted file mode 100644
index 328d4700..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceControllersCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.behaviour.ControllerConfig;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-
-/**
- * Sets role of the controller node for the given infrastructure device.
- */
-@Command(scope = "onos", name = "device-controllers",
- description = "gets the list of controllers for the given infrastructure device")
-public class DeviceControllersCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = true, multiValued = false)
- String uri = null;
- private DeviceId deviceId;
-
- @Override
- protected void execute() {
- DriverService service = get(DriverService.class);
- deviceId = DeviceId.deviceId(uri);
- DriverHandler h = service.createHandler(deviceId);
- ControllerConfig config = h.behaviour(ControllerConfig.class);
- config.getControllers().forEach(c -> print(c.target()));
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceIdCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceIdCompleter.java
deleted file mode 100644
index 82ef5edf..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceIdCompleter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2014 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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.Device;
-import org.onosproject.net.device.DeviceService;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Device ID completer.
- */
-public class DeviceIdCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- DeviceService service = AbstractShellCommand.get(DeviceService.class);
- Iterator<Device> it = service.getDevices().iterator();
- SortedSet<String> strings = delegate.getStrings();
- while (it.hasNext()) {
- strings.add(it.next().id().toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicePortStatsCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicePortStatsCommand.java
deleted file mode 100644
index 2e804545..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicePortStatsCommand.java
+++ /dev/null
@@ -1,192 +0,0 @@
-package org.onosproject.cli.net;
-
-/*
- * 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.
- */
-
-import static org.onosproject.net.DeviceId.deviceId;
-
-import java.util.concurrent.TimeUnit;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.device.PortStatistics;
-
-/**
- * Lists port statistic of all ports in the system.
- */
-@Command(scope = "onos", name = "portstats",
- description = "Lists statistics of all ports in the system")
-public class DevicePortStatsCommand extends DevicesListCommand {
-
- @Option(name = "-d", aliases = "--delta", description = "Show Delta Port Statistics,"
- + "only for the last polling interval",
- required = false, multiValued = false)
- private boolean delta = false;
-
- @Option(name = "-t", aliases = "--table", description = "Show human readable table format for statistics",
- required = false, multiValued = false)
- private boolean table = false;
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = false, multiValued = false)
- String uri = null;
-
- private static final String FORMAT =
- " port=%s, pktRx=%s, pktTx=%s, bytesRx=%s, bytesTx=%s, pktRxDrp=%s, pktTxDrp=%s, Dur=%s";
-
- @Override
- protected void execute() {
- DeviceService deviceService = get(DeviceService.class);
-
- if (uri == null) {
- for (Device d : getSortedDevices(deviceService)) {
- if (delta) {
- if (table) {
- printPortStatsDeltaTable(d.id(), deviceService.getPortDeltaStatistics(d.id()));
- } else {
- printPortStatsDelta(d.id(), deviceService.getPortDeltaStatistics(d.id()));
- }
- } else {
- printPortStats(d.id(), deviceService.getPortStatistics(d.id()));
- }
- }
- } else {
- Device d = deviceService.getDevice(deviceId(uri));
- if (d == null) {
- error("No such device %s", uri);
- } else if (delta) {
- if (table) {
- printPortStatsDeltaTable(d.id(), deviceService.getPortDeltaStatistics(d.id()));
- } else {
- printPortStatsDelta(d.id(), deviceService.getPortDeltaStatistics(d.id()));
- }
- } else {
- printPortStats(d.id(), deviceService.getPortStatistics(d.id()));
- }
- }
- }
-
- /**
- * Prints Port Statistics.
- *
- * @param deviceId
- * @param portStats
- */
- private void printPortStats(DeviceId deviceId, Iterable<PortStatistics> portStats) {
-
- print("deviceId=%s", deviceId);
- for (PortStatistics stat : portStats) {
- print(FORMAT, stat.port(), stat.packetsReceived(), stat.packetsSent(), stat.bytesReceived(),
- stat.bytesSent(), stat.packetsRxDropped(), stat.packetsTxDropped(), stat.durationSec());
- }
- }
- /**
- * Prints Port delta statistics.
- *
- * @param deviceId
- * @param portStats
- */
- private void printPortStatsDelta(DeviceId deviceId, Iterable<PortStatistics> portStats) {
- final String formatDelta = " port=%s, pktRx=%s, pktTx=%s, bytesRx=%s, bytesTx=%s,"
- + " rateRx=%s, rateTx=%s, pktRxDrp=%s, pktTxDrp=%s, interval=%s";
- print("deviceId=%s", deviceId);
- for (PortStatistics stat : portStats) {
- float duration = ((float) stat.durationSec()) +
- (((float) stat.durationNano()) / TimeUnit.SECONDS.toNanos(1));
- float rateRx = stat.bytesReceived() * 8 / duration;
- float rateTx = stat.bytesSent() * 8 / duration;
- print(formatDelta, stat.port(),
- stat.packetsReceived(),
- stat.packetsSent(),
- stat.bytesReceived(),
- stat.bytesSent(),
- String.format("%.1f", rateRx),
- String.format("%.1f", rateTx),
- stat.packetsRxDropped(),
- stat.packetsTxDropped(),
- String.format("%.3f", duration));
- }
- }
-
- /**
- * Prints human readable table with delta Port Statistics for specific device.
- *
- * @param deviceId
- * @param portStats
- */
- private void printPortStatsDeltaTable(DeviceId deviceId, Iterable<PortStatistics> portStats) {
- final String formatDeltaTable = "|%5s | %7s | %7s | %7s | %7s | %7s | %7s | %7s | %7s |%9s |";
- print("+---------------------------------------------------------------------------------------------------+");
- print("| DeviceId = %s |", deviceId);
- print("|---------------------------------------------------------------------------------------------------|");
- print("| | Receive | Transmit | Time [s] |");
- print("| Port | Packets | Bytes | Rate bps | Drop | Packets | Bytes | Rate bps | Drop | Interval |");
- print("|---------------------------------------------------------------------------------------------------|");
-
- for (PortStatistics stat : portStats) {
- float duration = ((float) stat.durationSec()) +
- (((float) stat.durationNano()) / TimeUnit.SECONDS.toNanos(1));
- float rateRx = stat.bytesReceived() * 8 / duration;
- float rateTx = stat.bytesSent() * 8 / duration;
- print(formatDeltaTable, stat.port(),
- humanReadable(stat.packetsReceived()),
- humanReadable(stat.bytesReceived()),
- humanReadableBps(rateRx),
- humanReadable(stat.packetsRxDropped()),
- humanReadable(stat.packetsSent()),
- humanReadable(stat.bytesSent()),
- humanReadableBps(rateTx),
- humanReadable(stat.packetsTxDropped()),
- String.format("%.3f", duration));
- }
- print("+---------------------------------------------------------------------------------------------------+");
- }
-
- /**
- * Converts bytes to human readable string with Kilo, Mega, Giga, etc.
- *
- * @param bytes input byte array
- * @return human readble string
- */
- public static String humanReadable(long bytes) {
- int unit = 1000;
- if (bytes < unit) {
- return String.format("%s ", bytes);
- }
- int exp = (int) (Math.log(bytes) / Math.log(unit));
- Character pre = ("KMGTPE").charAt(exp - 1);
- return String.format("%.2f%s", bytes / Math.pow(unit, exp), pre);
- }
- /**
- * Converts bps to human readable format.
- *
- * @param bps input rate
- * @return human readble string
- */
- public static String humanReadableBps(float bps) {
- int unit = 1000;
- if (bps < unit) {
- return String.format("%.0f ", (float) bps);
- }
- int exp = (int) (Math.log(bps) / Math.log(unit));
- Character pre = ("KMGTPE").charAt(exp - 1);
- return String.format("%.2f%s", bps / Math.pow(unit, exp), pre);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
deleted file mode 100644
index e2d3e6d6..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicePortsListCommand.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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 com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.util.Frequency;
-import org.onosproject.cli.Comparators;
-import org.onosproject.net.Device;
-import org.onosproject.net.OchPort;
-import org.onosproject.net.OduCltPort;
-import org.onosproject.net.OmsPort;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceService;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import static org.onosproject.net.DeviceId.deviceId;
-
-/**
- * Lists all ports or all ports of a device.
- */
-@Command(scope = "onos", name = "ports",
- description = "Lists all ports or all ports of a device")
-public class DevicePortsListCommand extends DevicesListCommand {
-
- private static final String FMT = " port=%s, state=%s, type=%s, speed=%s %s";
- private static final String FMT_OCH = " port=%s, state=%s, type=%s, signalType=%s, isTunable=%s %s";
- private static final String FMT_ODUCLT = " port=%s, state=%s, type=%s, signalType=%s %s";
- private static final String FMT_OMS = " port=%s, state=%s, type=%s, Freqs= %s / %s / %s GHz, totalChannels=%s %s";
-
- @Option(name = "-e", aliases = "--enabled", description = "Show only enabled ports",
- required = false, multiValued = false)
- private boolean enabled = false;
-
- @Option(name = "-d", aliases = "--disabled", description = "Show only disabled ports",
- required = false, multiValued = false)
- private boolean disabled = false;
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = false, multiValued = false)
- String uri = null;
-
- @Override
- protected void execute() {
- DeviceService service = get(DeviceService.class);
- if (uri == null) {
- if (outputJson()) {
- print("%s", jsonPorts(service, getSortedDevices(service)));
- } else {
- for (Device device : getSortedDevices(service)) {
- printDevice(service, device);
- }
- }
-
- } else {
- Device device = service.getDevice(deviceId(uri));
- if (device == null) {
- error("No such device %s", uri);
- } else if (outputJson()) {
- print("%s", jsonPorts(service, new ObjectMapper(), device));
- } else {
- printDevice(service, device);
- }
- }
- }
-
- /**
- * Produces JSON array containing ports of the specified devices.
- *
- * @param service device service
- * @param devices collection of devices
- * @return JSON array
- */
- public JsonNode jsonPorts(DeviceService service, Iterable<Device> devices) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- for (Device device : devices) {
- result.add(jsonPorts(service, mapper, device));
- }
- return result;
- }
-
- /**
- * Produces JSON array containing ports of the specified device.
- *
- * @param service device service
- * @param mapper object mapper
- * @param device infrastructure devices
- * @return JSON array
- */
- public JsonNode jsonPorts(DeviceService service, ObjectMapper mapper, Device device) {
- ObjectNode result = mapper.createObjectNode();
- ArrayNode ports = mapper.createArrayNode();
- for (Port port : service.getPorts(device.id())) {
- if (isIncluded(port)) {
- ports.add(mapper.createObjectNode()
- .put("port", portName(port.number()))
- .put("isEnabled", port.isEnabled())
- .put("type", port.type().toString().toLowerCase())
- .put("portSpeed", port.portSpeed())
- .set("annotations", annotations(mapper, port.annotations())));
- }
- }
- result.set("device", jsonForEntity(device, Device.class));
- result.set("ports", ports);
- return result;
- }
-
- private String portName(PortNumber port) {
- return port.equals(PortNumber.LOCAL) ? "local" : port.toString();
- }
-
- // Determines if a port should be included in output.
- private boolean isIncluded(Port port) {
- return enabled && port.isEnabled() || disabled && !port.isEnabled() ||
- !enabled && !disabled;
- }
-
- @Override
- protected void printDevice(DeviceService service, Device device) {
- super.printDevice(service, device);
- List<Port> ports = new ArrayList<>(service.getPorts(device.id()));
- Collections.sort(ports, Comparators.PORT_COMPARATOR);
- for (Port port : ports) {
- if (!isIncluded(port)) {
- continue;
- }
- String portName = portName(port.number());
- Object portIsEnabled = port.isEnabled() ? "enabled" : "disabled";
- String portType = port.type().toString().toLowerCase();
- String annotations = annotations(port.annotations());
- switch (port.type()) {
- case OCH:
- print(FMT_OCH, portName, portIsEnabled, portType,
- ((OchPort) port).signalType().toString(),
- ((OchPort) port).isTunable() ? "yes" : "no", annotations);
- break;
- case ODUCLT:
- print(FMT_ODUCLT, portName, portIsEnabled, portType,
- ((OduCltPort) port).signalType().toString(), annotations);
- break;
- case OMS:
- print(FMT_OMS, portName, portIsEnabled, portType,
- ((OmsPort) port).minFrequency().asHz() / Frequency.ofGHz(1).asHz(),
- ((OmsPort) port).maxFrequency().asHz() / Frequency.ofGHz(1).asHz(),
- ((OmsPort) port).grid().asHz() / Frequency.ofGHz(1).asHz(),
- ((OmsPort) port).totalChannels(), annotations);
- break;
- default:
- print(FMT, portName, portIsEnabled, portType, port.portSpeed(), annotations);
- break;
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceRemoveCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceRemoveCommand.java
deleted file mode 100644
index 1226e436..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceRemoveCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceAdminService;
-
-/**
- * Removes an infrastructure device.
- */
-@Command(scope = "onos", name = "device-remove",
- description = "Removes an infrastructure device")
-public class DeviceRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = true, multiValued = false)
- String uri = null;
-
- @Override
- protected void execute() {
- get(DeviceAdminService.class).removeDevice(DeviceId.deviceId(uri));
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceRoleCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceRoleCommand.java
deleted file mode 100644
index 17fc87a3..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceRoleCommand.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.mastership.MastershipAdminService;
-import org.onosproject.net.MastershipRole;
-
-import com.google.common.util.concurrent.Futures;
-
-import static org.onosproject.net.DeviceId.deviceId;
-
-/**
- * Sets role of the controller node for the given infrastructure device.
- */
-@Command(scope = "onos", name = "device-role",
- description = "Sets role of the controller node for the given infrastructure device")
-public class DeviceRoleCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = true, multiValued = false)
- String uri = null;
-
- @Argument(index = 1, name = "node", description = "Node ID",
- required = true, multiValued = false)
- String node = null;
-
- @Argument(index = 2, name = "role", description = "Mastership role",
- required = true, multiValued = false)
- String role = null;
-
- @Override
- protected void execute() {
- MastershipAdminService service = get(MastershipAdminService.class);
- MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase());
- Futures.getUnchecked(service.setRole(new NodeId(node), deviceId(uri), mastershipRole));
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceSetControllersCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceSetControllersCommand.java
deleted file mode 100644
index cb4ff04a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DeviceSetControllersCommand.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.behaviour.ControllerConfig;
-import org.onosproject.net.behaviour.ControllerInfo;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Sets role of the controller node for the given infrastructure device.
- */
-@Command(scope = "onos", name = "device-setcontrollers",
- description = "sets the list of controllers for the given infrastructure device")
-public class DeviceSetControllersCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = true, multiValued = false)
- String uri = null;
-
- @Argument(index = 1, name = "controllersListStrings", description = "list of " +
- "controllers to set for the specified device",
- required = true, multiValued = true)
- String[] controllersListStrings = null;
-
- private DeviceId deviceId;
- private List<ControllerInfo> newControllers = new ArrayList<>();
-
- @Override
- protected void execute() {
-
- Arrays.asList(controllersListStrings).forEach(
- cInfoString -> newControllers.add(new ControllerInfo(cInfoString)));
- DriverService service = get(DriverService.class);
- deviceId = DeviceId.deviceId(uri);
- DriverHandler h = service.createHandler(deviceId);
- ControllerConfig config = h.behaviour(ControllerConfig.class);
- print("before:");
- config.getControllers().forEach(c -> print(c.target()));
- try {
- config.setControllers(newControllers);
- } catch (NullPointerException e) {
- print("No Device with requested parameters {} ", uri);
- }
- print("after:");
- config.getControllers().forEach(c -> print(c.target()));
- print("size %d", config.getControllers().size());
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicesListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicesListCommand.java
deleted file mode 100644
index e40bcad6..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DevicesListCommand.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2014 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.Collections;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.net.Device;
-import org.onosproject.net.device.DeviceService;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-/**
- * Lists all infrastructure devices.
- */
-@Command(scope = "onos", name = "devices",
- description = "Lists all infrastructure devices")
-public class DevicesListCommand extends AbstractShellCommand {
-
- private static final String FMT =
- "id=%s, available=%s, role=%s, type=%s, mfr=%s, hw=%s, sw=%s, serial=%s%s";
-
- @Override
- protected void execute() {
- DeviceService service = get(DeviceService.class);
- if (outputJson()) {
- print("%s", json(getSortedDevices(service)));
- } else {
- for (Device device : getSortedDevices(service)) {
- printDevice(service, device);
- }
- }
- }
-
- /**
- * Returns JSON node representing the specified devices.
- *
- * @param devices collection of devices
- * @return JSON node
- */
- private JsonNode json(Iterable<Device> devices) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- for (Device device : devices) {
- result.add(jsonForEntity(device, Device.class));
- }
- return result;
- }
-
- /**
- * Returns the list of devices sorted using the device ID URIs.
- *
- * @param service device service
- * @return sorted device list
- */
- public static List<Device> getSortedDevices(DeviceService service) {
- List<Device> devices = newArrayList(service.getDevices());
- Collections.sort(devices, Comparators.ELEMENT_COMPARATOR);
- return devices;
- }
-
- /**
- * Prints information about the specified device.
- *
- * @param service device service
- * @param device infrastructure device
- */
- protected void printDevice(DeviceService service, Device device) {
- if (device != null) {
- print(FMT, device.id(), service.isAvailable(device.id()),
- service.getRole(device.id()), device.type(),
- device.manufacturer(), device.hwVersion(), device.swVersion(),
- device.serialNumber(), annotations(device.annotations()));
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DriverNameCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DriverNameCompleter.java
deleted file mode 100644
index 2ba8a20a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DriverNameCompleter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.driver.DriverAdminService;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Device driver name completer.
- */
-public class DriverNameCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
-
- // Fetch our service and feed it's offerings to the string completer
- DriverAdminService service = AbstractShellCommand.get(DriverAdminService.class);
- service.getDrivers().forEach(d -> strings.add(d.name()));
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DriversListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DriversListCommand.java
deleted file mode 100644
index 05d9e957..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/DriversListCommand.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.driver.Driver;
-import org.onosproject.net.driver.DriverAdminService;
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-/**
- * Lists device drivers.
- */
-@Command(scope = "onos", name = "drivers",
- description = "Lists device drivers")
-public class DriversListCommand extends AbstractShellCommand {
-
- private static final String FMT = "driver=%s, extends=%s, mfr=%s, hw=%s, sw=%s";
- private static final String FMT_B = " %s via %s";
- private static final String FMT_P = " %s=%s";
-
- @Argument(index = 0, name = "driverName", description = "Driver name",
- required = false, multiValued = false)
- String driverName = null;
-
- @Override
- protected void execute() {
- DriverAdminService service = get(DriverAdminService.class);
-
- if (driverName != null) {
- printDriver(service.getDriver(driverName));
- } else {
- if (outputJson()) {
- json(service.getDrivers());
- } else {
- service.getDrivers().forEach(this::printDriver);
- }
- }
- }
-
- private void json(Driver driver) {
- print("%s", jsonForEntity(driver, Driver.class));
- }
-
- private void json(Set<Driver> drivers) {
- ArrayNode result = mapper().createArrayNode();
- drivers.forEach(driver -> result.add(jsonForEntity(driver, Driver.class)));
- print("%s", result.toString());
- }
-
- private void printDriver(Driver driver) {
- if (outputJson()) {
- json(driver);
- } else {
- Driver parent = driver.parent();
- print(FMT, driver.name(), parent != null ? parent.name() : "none",
- driver.manufacturer(), driver.hwVersion(), driver.swVersion());
- driver.behaviours().forEach(b -> print(FMT_B, b.getCanonicalName(),
- driver.implementation(b).getCanonicalName()));
- driver.properties().forEach((k, v) -> print(FMT_P, k, v));
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EdgePortsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EdgePortsListCommand.java
deleted file mode 100644
index 1a9235e6..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EdgePortsListCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.edge.EdgePortService;
-
-import static org.onosproject.net.DeviceId.deviceId;
-
-/**
- * Lists all edge ports.
- */
-@Command(scope = "onos", name = "edge-ports",
- description = "Lists all edge ports.")
-public class EdgePortsListCommand extends AbstractShellCommand {
-
- private static final String FMT = "%s/%s";
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = false, multiValued = false)
- String uri = null;
-
-
-
- @Override
- protected void execute() {
- EdgePortService service = get(EdgePortService.class);
- if (uri == null) {
- service.getEdgePoints().forEach(e -> print(FMT, e.deviceId(), e.port()));
- } else {
- service.getEdgePoints(deviceId(uri)).forEach(e -> print(FMT, e.deviceId(), e.port()));
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EncapTypeCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EncapTypeCompleter.java
deleted file mode 100644
index b14615d4..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EncapTypeCompleter.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.onosproject.cli.net;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.net.EncapsulationType;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Encapsulation type completer.
- */
-public class EncapTypeCompleter implements Completer {
-
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
-
- for (EncapsulationType encapType : EncapsulationType.values()) {
- strings.add(encapType.toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EthType.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EthType.java
deleted file mode 100644
index 02c97b8f..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EthType.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2014-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.onlab.packet.Ethernet;
-
-/**
- * Allowed values for Ethernet types. Used by the CLI completer for
- * connectivity based intent L2 parameters.
- */
-public enum EthType {
- /** ARP. */
- ARP(Ethernet.TYPE_ARP),
- /** RARP. */
- RARP(Ethernet.TYPE_RARP),
- /** IPV4. */
- IPV4(Ethernet.TYPE_IPV4),
- /** IPV6. */
- IPV6(Ethernet.TYPE_IPV6),
- /** LLDP. */
- LLDP(Ethernet.TYPE_LLDP),
- /** BSN. */
- BSN(Ethernet.TYPE_BSN);
-
- private short value;
-
- /**
- * Constructs an EthType with the given value.
- *
- * @param value value to use when this EthType is seen
- */
- private EthType(short value) {
- this.value = value;
- }
-
- /**
- * Gets the value to use for this EthType.
- *
- * @return short value to use for this EthType
- */
- public short value() {
- return this.value;
- }
-
- /**
- * Parse a string input that could contain an EthType value. The value
- * may appear in the string either as a known protocol name (one of the
- * values of this enum), or a numeric protocol value.
- *
- * @param input the input string to parse
- * @return the numeric value of the parsed Ethernet type
- * @throws IllegalArgumentException if the input string does not contain a
- * value that can be parsed into an Ethernet type
- */
- public static short parseFromString(String input) {
- try {
- return valueOf(input).value();
- } catch (IllegalArgumentException e) {
- // The input is not a known Ethernet type name, let's see if it's an
- // Ethernet type value (short). We parse with Integer to handle
- // unsigned values correctly.
- try {
- return (short) Integer.parseInt(input);
- } catch (NumberFormatException e1) {
- throw new IllegalArgumentException(
- "EthType value must be either a string protocol name"
- + " or a 16-bit protocol value");
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EthTypeCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EthTypeCompleter.java
deleted file mode 100644
index b6a2285c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/EthTypeCompleter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014 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.List;
-import java.util.SortedSet;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-/**
- * Ethernet type completer.
- */
-public class EthTypeCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
-
- for (EthType eth : EthType.values()) {
- strings.add(eth.toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ExtHeader.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ExtHeader.java
deleted file mode 100644
index e27332e1..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ExtHeader.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2014 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;
-
-/**
- * Known values for IPv6 extension header field that can be supplied to the CLI.
- */
-public enum ExtHeader {
- /** No next header. */
- NOEXT((short) (1 << 0)),
- /** Encapsulated Security Payload. */
- ESP((short) (1 << 1)),
- /** Authentication header. */
- AUTH((short) (1 << 2)),
- /** Destination header. */
- DEST((short) (1 << 3)),
- /** Fragment header. */
- FRAG((short) (1 << 4)),
- /** Router header. */
- ROUTE((short) (1 << 5)),
- /** Hop-by-hop header. */
- HOP((short) (1 << 6)),
- /** Unexpected repeats encountered. */
- UNREP((short) (1 << 7)),
- /** Unexpected sequencing encountered. */
- UNSEQ((short) (1 << 8));
-
- private short value;
-
- /**
- * Constructs an ExtHeader with the given value.
- *
- * @param value value to use when this ExtHeader is seen
- */
- private ExtHeader(short value) {
- this.value = value;
- }
-
- /**
- * Gets the value to use for this ExtHeader.
- *
- * @return short value to use for this ExtHeader
- */
- public short value() {
- return this.value;
- }
-
- /**
- * Parse a string input that could contain an ExtHeader value. The value
- * may appear in the string either as a known exntension header name (one of the
- * values of this enum), or a numeric extension header value.
- *
- * @param input the input string to parse
- * @return the numeric value of the parsed IPv6 extension header
- * @throws IllegalArgumentException if the input string does not contain a
- * value that can be parsed into an IPv6 extension header
- */
- public static short parseFromString(String input) {
- try {
- return valueOf(input).value();
- } catch (IllegalArgumentException e) {
- // The input is not a known IPv6 extension header name, let's see if
- // it's an IPv6 extension header value (short).
- // We parse with Short to handle unsigned values correctly.
- try {
- return Short.parseShort(input);
- } catch (NumberFormatException e1) {
- throw new IllegalArgumentException(
- "ExtHeader value must be either a string extension header name"
- + " or an 8-bit extension header value");
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ExtHeaderCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ExtHeaderCompleter.java
deleted file mode 100644
index 1242e119..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ExtHeaderCompleter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014 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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * IPv6 extension header completer.
- */
-public class ExtHeaderCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
-
- for (ExtHeader extHeader : ExtHeader.values()) {
- strings.add(extHeader.toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowObjectiveCompositionCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowObjectiveCompositionCommand.java
deleted file mode 100644
index 9bacc7ae..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowObjectiveCompositionCommand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-
-/**
- * Manages FlowObjectiveComposition policy.
- */
-@Command(scope = "onos", name = "policy",
- description = "Manages FlowObjectiveComposition policy")
-public class FlowObjectiveCompositionCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "command",
- description = "Command name (install)",
- required = true, multiValued = false)
- String command = null;
-
- @Argument(index = 1, name = "names", description = "policy string",
- required = true, multiValued = true)
- String[] policies = null;
-
- @Override
- protected void execute() {
- FlowObjectiveService service = get(FlowObjectiveService.class);
- service.initPolicy(policies[0]);
- print("Policy %s installed", policies[0]);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowRuleStatusCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowRuleStatusCompleter.java
deleted file mode 100644
index ce910c95..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowRuleStatusCompleter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2014 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.List;
-import java.util.SortedSet;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.net.flow.FlowEntry.FlowEntryState;
-
-/**
- * Flow rule status completer.
- */
-public class FlowRuleStatusCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- FlowEntryState[] states = FlowEntryState.values();
- SortedSet<String> strings = delegate.getStrings();
- for (int i = 0; i < states.length; i++) {
- strings.add(states[i].toString().toLowerCase());
- }
- strings.add(FlowsListCommand.ANY);
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
deleted file mode 100644
index 331cca17..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/FlowsListCommand.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 2014-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 static com.google.common.collect.Lists.newArrayList;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.FlowEntry;
-import org.onosproject.net.flow.FlowEntry.FlowEntryState;
-import org.onosproject.net.flow.FlowRuleService;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Lists all currently-known flows.
- */
-@Command(scope = "onos", name = "flows",
- description = "Lists all currently-known flows.")
-public class FlowsListCommand extends AbstractShellCommand {
-
- public static final String ANY = "any";
-
- private static final String FMT =
- " id=%s, state=%s, bytes=%s, packets=%s, duration=%s, priority=%s, tableId=%s appId=%s, payLoad=%s";
- private static final String TFMT = " treatment=%s";
- private static final String SFMT = " selector=%s";
-
- @Argument(index = 1, name = "uri", description = "Device ID",
- required = false, multiValued = false)
- String uri = null;
-
- @Argument(index = 0, name = "state", description = "Flow Rule state",
- required = false, multiValued = false)
- String state = null;
-
- @Override
- protected void execute() {
- CoreService coreService = get(CoreService.class);
- DeviceService deviceService = get(DeviceService.class);
- FlowRuleService service = get(FlowRuleService.class);
- SortedMap<Device, List<FlowEntry>> flows = getSortedFlows(deviceService, service);
-
- if (outputJson()) {
- print("%s", json(flows.keySet(), flows));
- } else {
- flows.forEach((device, flow) -> printFlows(device, flow, coreService));
- }
- }
-
- /**
- * Produces a JSON array of flows grouped by the each device.
- *
- * @param devices collection of devices to group flow by
- * @param flows collection of flows per each device
- * @return JSON array
- */
- private JsonNode json(Iterable<Device> devices,
- Map<Device, List<FlowEntry>> flows) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- for (Device device : devices) {
- result.add(json(mapper, device, flows.get(device)));
- }
- return result;
- }
-
- // Produces JSON object with the flows of the given device.
- private ObjectNode json(ObjectMapper mapper,
- Device device, List<FlowEntry> flows) {
- ObjectNode result = mapper.createObjectNode();
- ArrayNode array = mapper.createArrayNode();
-
- flows.forEach(flow -> array.add(jsonForEntity(flow, FlowEntry.class)));
-
- result.put("device", device.id().toString())
- .put("flowCount", flows.size())
- .set("flows", array);
- return result;
- }
-
- /**
- * Returns the list of devices sorted using the device ID URIs.
- *
- * @param deviceService device service
- * @param service flow rule service
- * @return sorted device list
- */
- protected SortedMap<Device, List<FlowEntry>> getSortedFlows(DeviceService deviceService,
- FlowRuleService service) {
- SortedMap<Device, List<FlowEntry>> flows = new TreeMap<>(Comparators.ELEMENT_COMPARATOR);
- List<FlowEntry> rules;
- FlowEntryState s = null;
- if (state != null && !state.equals("any")) {
- s = FlowEntryState.valueOf(state.toUpperCase());
- }
- Iterable<Device> devices = null;
- if (uri == null) {
- devices = deviceService.getDevices();
- } else {
- Device dev = deviceService.getDevice(DeviceId.deviceId(uri));
- devices = (dev == null) ? deviceService.getDevices()
- : Collections.singletonList(dev);
- }
- for (Device d : devices) {
- if (s == null) {
- rules = newArrayList(service.getFlowEntries(d.id()));
- } else {
- rules = newArrayList();
- for (FlowEntry f : service.getFlowEntries(d.id())) {
- if (f.state().equals(s)) {
- rules.add(f);
- }
- }
- }
- rules.sort(Comparators.FLOW_RULE_COMPARATOR);
- flows.put(d, rules);
- }
- return flows;
- }
-
- /**
- * Prints flows.
- *
- * @param d the device
- * @param flows the set of flows for that device
- * @param coreService core system service
- */
- protected void printFlows(Device d, List<FlowEntry> flows,
- CoreService coreService) {
- boolean empty = flows == null || flows.isEmpty();
- print("deviceId=%s, flowRuleCount=%d", d.id(), empty ? 0 : flows.size());
- if (!empty) {
- for (FlowEntry f : flows) {
- ApplicationId appId = coreService.getAppId(f.appId());
- print(FMT, Long.toHexString(f.id().value()), f.state(),
- f.bytes(), f.packets(), f.life(), f.priority(), f.tableId(),
- appId != null ? appId.name() : "<none>",
- f.payLoad() == null ? null : f.payLoad().payLoad().toString());
- print(SFMT, f.selector().criteria());
- print(TFMT, f.treatment());
- }
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetFlowStatistics.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetFlowStatistics.java
deleted file mode 100644
index 4bbf4f10..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetFlowStatistics.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * 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;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.TypedStoredFlowEntry;
-import org.onosproject.net.flow.instructions.Instruction;
-import org.onosproject.net.statistic.FlowStatisticService;
-import org.onosproject.net.statistic.SummaryFlowEntryWithLoad;
-import org.onosproject.net.statistic.TypedFlowEntryWithLoad;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.PortNumber.portNumber;
-
-/**
- * Fetches flow statistics with a flow type and instruction type.
- */
-@Command(scope = "onos", name = "get-flow-stats",
- description = "Fetches flow stats for a connection point with given flow type and instruction type")
-public class GetFlowStatistics extends AbstractShellCommand {
- @Argument(index = 0, name = "devicePort",
- description = "Device[/Port] connectPoint Description",
- required = true, multiValued = false)
- String devicePort = null;
-
- @Option(name = "-s", aliases = "--summary",
- description = "Show flow stats summary",
- required = false, multiValued = false)
- boolean showSummary = true; // default summary
-
- @Option(name = "-a", aliases = "--all",
- description = "Show flow stats all",
- required = false, multiValued = false)
- boolean showAll = false;
-
- @Option(name = "-t", aliases = "--topn",
- description = "Show flow stats topn",
- required = false, multiValued = false)
- String showTopn = null;
-
- @Option(name = "-f", aliases = "--flowType",
- description = "Flow live type, It includes IMMEDIATE, SHORT, MID, LONG, UNKNOWN"
- + ", and is valid with -a or -t option only",
- required = false, multiValued = false)
- String flowLiveType = null;
-
- @Option(name = "-i", aliases = "--instructionType",
- description = "Flow instruction type, It includes DROP, OUTPUT, GROUP, L0MODIFICATION, L2MODIFICATION,"
- + " TABLE, L3MODIFICATION, METADATA"
- + ", and is valid with -a or -t option only",
- required = false, multiValued = false)
- String instructionType = null;
-
- @Override
- protected void execute() {
- DeviceService deviceService = get(DeviceService.class);
- FlowStatisticService flowStatsService = get(FlowStatisticService.class);
-
- String deviceUri = getDeviceId(devicePort);
- String portUri = getPortNumber(devicePort);
-
- DeviceId ingressDeviceId = deviceId(deviceUri);
- PortNumber ingressPortNumber;
- if (portUri.length() == 0) {
- ingressPortNumber = null;
- } else {
- ingressPortNumber = portNumber(portUri);
- }
-
- Device device = deviceService.getDevice(ingressDeviceId);
- if (device == null) {
- error("No such device %s", ingressDeviceId.uri());
- return;
- }
-
- if (ingressPortNumber != null) {
- Port port = deviceService.getPort(ingressDeviceId, ingressPortNumber);
- if (port == null) {
- error("No such port %s on device %s", portUri, ingressDeviceId.uri());
- return;
- }
- }
-
- if (flowLiveType != null) {
- flowLiveType = flowLiveType.toUpperCase();
- }
- if (instructionType != null) {
- instructionType = instructionType.toUpperCase();
- }
-
- // convert String to FlowLiveType and check validity
- TypedStoredFlowEntry.FlowLiveType inLiveType;
- if (flowLiveType == null) {
- inLiveType = null;
- } else {
- inLiveType = getFlowLiveType(flowLiveType);
- if (inLiveType == null) {
- error("Invalid flow live type [%s] error", flowLiveType);
- return;
- }
- }
- // convert String to InstructionType and check validity
- Instruction.Type inInstructionType;
- if (instructionType == null) {
- inInstructionType = null;
- } else {
- inInstructionType = getInstructionType(instructionType);
- if (inInstructionType == null) {
- error("Invalid instruction type [%s] error", instructionType);
- return;
- }
- }
-
- if (showTopn != null) {
- int topn = Integer.parseInt(showTopn);
-
- if (topn <= 0) {
- topn = 100; //default value
- } else if (topn > 1000) {
- topn = 1000; //max value
- }
-
- // print show topn head line with type
- print("deviceId=%s, show TOPN=%s flows, live type=%s, instruction type=%s",
- deviceUri,
- Integer.toString(topn),
- flowLiveType == null ? "ALL" : flowLiveType,
- instructionType == null ? "ALL" : instructionType);
- if (ingressPortNumber == null) {
- Map<ConnectPoint, List<TypedFlowEntryWithLoad>> typedFlowLoadMap =
- flowStatsService.loadTopnByType(device, inLiveType, inInstructionType, topn);
- // print all ports topn flows load for a given device
- for (ConnectPoint cp : typedFlowLoadMap.keySet()) {
- printPortFlowsLoad(cp, typedFlowLoadMap.get(cp));
- }
- } else {
- List<TypedFlowEntryWithLoad> typedFlowLoad =
- flowStatsService.loadTopnByType(device, ingressPortNumber, inLiveType, inInstructionType, topn);
- // print device/port topn flows load
- ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber);
- printPortFlowsLoad(cp, typedFlowLoad);
- }
- } else if (showAll) { // is true?
- // print show all head line with type
- print("deviceId=%s, show ALL flows, live type=%s, instruction type=%s",
- deviceUri,
- flowLiveType == null ? "ALL" : flowLiveType,
- instructionType == null ? "ALL" : instructionType);
- if (ingressPortNumber == null) {
- Map<ConnectPoint, List<TypedFlowEntryWithLoad>> typedFlowLoadMap =
- flowStatsService.loadAllByType(device, inLiveType, inInstructionType);
- // print all ports all flows load for a given device
- for (ConnectPoint cp : typedFlowLoadMap.keySet()) {
- printPortFlowsLoad(cp, typedFlowLoadMap.get(cp));
- }
- } else {
- List<TypedFlowEntryWithLoad> typedFlowLoad =
- flowStatsService.loadAllByType(device, ingressPortNumber, inLiveType, inInstructionType);
- // print device/port all flows load
- ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber);
- printPortFlowsLoad(cp, typedFlowLoad);
- }
- } else { // if (showSummary == true) //always is true
- // print show summary head line
- print("deviceId=%s, show SUMMARY flows", deviceUri);
- if (ingressPortNumber == null) {
- Map<ConnectPoint, SummaryFlowEntryWithLoad> summaryFlowLoadMap =
- flowStatsService.loadSummary(device);
- // print all ports flow load summary for a given device
- for (ConnectPoint cp : summaryFlowLoadMap.keySet()) {
- printPortSummaryLoad(cp, summaryFlowLoadMap.get(cp));
- }
- } else {
- SummaryFlowEntryWithLoad summaryFlowLoad =
- flowStatsService.loadSummary(device, ingressPortNumber);
- // print device/port flow load summary
- ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber);
- printPortSummaryLoad(cp, summaryFlowLoad);
- }
- }
- }
-
- /**
- * Extracts the port number portion of the ConnectPoint.
- *
- * @param deviceString string representing the device/port
- * @return port number as a string, empty string if the port is not found
- */
- private String getPortNumber(String deviceString) {
- if (deviceString == null) {
- return "";
- }
-
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return ""; // return when no port number
- }
- return deviceString.substring(slash + 1, deviceString.length());
- }
-
- /**
- * Extracts the device ID portion of the ConnectPoint.
- *
- * @param deviceString string representing the device/port
- * @return device ID string
- */
- private String getDeviceId(String deviceString) {
- if (deviceString == null) {
- return "";
- }
-
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return deviceString; // return only included device ID
- }
- return deviceString.substring(0, slash);
- }
-
- /**
- * converts string of flow live type to FloeLiveType enum.
- *
- * @param liveType string representing the flow live type
- * @return TypedStoredFlowEntry.FlowLiveType
- */
- private TypedStoredFlowEntry.FlowLiveType getFlowLiveType(String liveType) {
- String liveTypeUC = liveType.toUpperCase();
-
- if (liveTypeUC.equals("IMMEDIATE")) {
- return TypedStoredFlowEntry.FlowLiveType.IMMEDIATE_FLOW;
- } else if (liveTypeUC.equals("SHORT")) {
- return TypedStoredFlowEntry.FlowLiveType.SHORT_FLOW;
- } else if (liveTypeUC.equals("MID")) {
- return TypedStoredFlowEntry.FlowLiveType.MID_FLOW;
- } else if (liveTypeUC.equals("LONG")) {
- return TypedStoredFlowEntry.FlowLiveType.LONG_FLOW;
- } else if (liveTypeUC.equals("UNKNOWN")) {
- return TypedStoredFlowEntry.FlowLiveType.UNKNOWN_FLOW;
- } else {
- return null; // flow live type error
- }
- }
-
- /**
- * converts string of instruction type to Instruction type enum.
- *
- * @param instType string representing the instruction type
- * @return Instruction.Type
- */
- private Instruction.Type getInstructionType(String instType) {
- String instTypeUC = instType.toUpperCase();
-
- if (instTypeUC.equals("DROP")) {
- return Instruction.Type.DROP;
- } else if (instTypeUC.equals("OUTPUT")) {
- return Instruction.Type.OUTPUT;
- } else if (instTypeUC.equals("GROUP")) {
- return Instruction.Type.GROUP;
- } else if (instTypeUC.equals("L0MODIFICATION")) {
- return Instruction.Type.L0MODIFICATION;
- } else if (instTypeUC.equals("L2MODIFICATION")) {
- return Instruction.Type.L2MODIFICATION;
- } else if (instTypeUC.equals("TABLE")) {
- return Instruction.Type.TABLE;
- } else if (instTypeUC.equals("L3MODIFICATION")) {
- return Instruction.Type.L3MODIFICATION;
- } else if (instTypeUC.equals("METADATA")) {
- return Instruction.Type.METADATA;
- } else {
- return null; // instruction type error
- }
- }
-
- private void printPortFlowsLoad(ConnectPoint cp, List<TypedFlowEntryWithLoad> typedFlowLoad) {
- print(" deviceId/Port=%s/%s, %s flows", cp.elementId(), cp.port(), typedFlowLoad.size());
- for (TypedFlowEntryWithLoad tfel: typedFlowLoad) {
- TypedStoredFlowEntry tfe = tfel.typedStoredFlowEntry();
- print(" flowId=%s, state=%s, liveType=%s, life=%s -> %s",
- Long.toHexString(tfe.id().value()),
- tfe.state(),
- tfe.flowLiveType(),
- tfe.life(),
- tfel.load().isValid() ? tfel.load() : "Load{rate=0, NOT VALID}");
- }
- }
-
- private void printPortSummaryLoad(ConnectPoint cp, SummaryFlowEntryWithLoad summaryFlowLoad) {
- print(" deviceId/Port=%s/%s, Total=%s, Immediate=%s, Short=%s, Mid=%s, Long=%s, Unknown=%s",
- cp.elementId(),
- cp.port(),
- summaryFlowLoad.totalLoad().isValid() ? summaryFlowLoad.totalLoad() : "Load{rate=0, NOT VALID}",
- summaryFlowLoad.immediateLoad().isValid() ? summaryFlowLoad.immediateLoad() : "Load{rate=0, NOT VALID}",
- summaryFlowLoad.shortLoad().isValid() ? summaryFlowLoad.shortLoad() : "Load{rate=0, NOT VALID}",
- summaryFlowLoad.midLoad().isValid() ? summaryFlowLoad.midLoad() : "Load{rate=0, NOT VALID}",
- summaryFlowLoad.longLoad().isValid() ? summaryFlowLoad.longLoad() : "Load{rate=0, NOT VALID}",
- summaryFlowLoad.unknownLoad().isValid() ? summaryFlowLoad.unknownLoad() : "Load{rate=0, NOT VALID}");
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetStatistics.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetStatistics.java
deleted file mode 100644
index 911e03c2..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GetStatistics.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-
-import org.onosproject.net.statistic.Load;
-import org.onosproject.net.statistic.StatisticService;
-
-
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.PortNumber.portNumber;
-
-/**
- * Fetches statistics.
- */
-@Command(scope = "onos", name = "get-stats",
- description = "Fetches stats for a connection point")
-public class GetStatistics extends AbstractShellCommand {
-
- @Argument(index = 0, name = "connectPoint",
- description = "Device/Port Description",
- required = true, multiValued = false)
- String connectPoint = null;
-
-
- @Override
- protected void execute() {
- StatisticService service = get(StatisticService.class);
-
- DeviceId ingressDeviceId = deviceId(getDeviceId(connectPoint));
- PortNumber ingressPortNumber = portNumber(getPortNumber(connectPoint));
- ConnectPoint cp = new ConnectPoint(ingressDeviceId, ingressPortNumber);
-
- Load load = service.load(cp);
-
- print("Load on %s -> %s", cp, load);
- }
-
- /**
- * Extracts the port number portion of the ConnectPoint.
- *
- * @param deviceString string representing the device/port
- * @return port number as a string, empty string if the port is not found
- */
- private String getPortNumber(String deviceString) {
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return "";
- }
- return deviceString.substring(slash + 1, deviceString.length());
- }
-
- /**
- * Extracts the device ID portion of the ConnectPoint.
- *
- * @param deviceString string representing the device/port
- * @return device ID string
- */
- private String getDeviceId(String deviceString) {
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return "";
- }
- return deviceString.substring(0, slash);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java
deleted file mode 100644
index a8e8f2e0..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelApplyCommand.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2014-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.Collection;
-import java.util.Iterator;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-
-@Command(scope = "onos", name = "global-label-apply",
- description = "Apply global labels from global resource pool")
-public class GlobalLabelApplyCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "applyNum",
- description = "Applying number means how many labels applications want to use.",
- required = true, multiValued = false)
- String applyNum = null;
-
- private static final String FMT = "deviceid=%s, labelresourceid=%s";
-
- @Override
- protected void execute() {
- LabelResourceService lrs = get(LabelResourceService.class);
- Collection<LabelResource> result =
- lrs.applyFromGlobalPool(Long.parseLong(applyNum));
- if (result.size() > 0) {
- for (Iterator<LabelResource> iterator = result.iterator(); iterator
- .hasNext();) {
- DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator
- .next();
- print(FMT, defaultLabelResource.deviceId().toString(),
- defaultLabelResource.labelResourceId().toString());
- }
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelCommand.java
deleted file mode 100644
index 92f39ccd..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelCommand.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014-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.incubator.net.resource.label.LabelResourcePool;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-
-@Command(scope = "onos", name = "global-label-pool",
- description = "Gets global label resource pool information.")
-public class GlobalLabelCommand extends AbstractShellCommand {
- private static final String FMT = "deviceid=%s, beginLabel=%s,"
- + "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s,"
- + "releaseLabelIds=%s";
-
- @Override
- protected void execute() {
- LabelResourceService lrs = get(LabelResourceService.class);
- LabelResourcePool pool = lrs.getGlobalLabelResourcePool();
- if (pool != null) {
- print(FMT, pool.deviceId().toString(), pool.beginLabel(),
- pool.endLabel(), pool.totalNum(), pool.usedNum(),
- pool.currentUsedMaxLabelId(), pool.releaseLabelId()
- .toString());
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolCreateCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolCreateCommand.java
deleted file mode 100644
index 3e226678..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolCreateCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-
-/**
- * create label resource pool by specific device id.
- */
-@Command(scope = "onos", name = "global-label-pool-create",
-description = "Creates global label resource pool.")
-public class GlobalLabelPoolCreateCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "beginLabel",
- description = "The first label of global label resource pool.",
- required = true, multiValued = false)
- String beginLabel = null;
- @Argument(index = 1, name = "endLabel",
- description = "The last label of global label resource pool.",
- required = true, multiValued = false)
- String endLabel = null;
-
- @Override
- protected void execute() {
- LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
- lrs.createGlobalPool(LabelResourceId.labelResourceId(Long
- .parseLong(beginLabel)), LabelResourceId.labelResourceId(Long
- .parseLong(endLabel)));
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolDestoryCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolDestoryCommand.java
deleted file mode 100644
index ae1bee64..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelPoolDestoryCommand.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2014-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.incubator.net.resource.label.LabelResourceAdminService;
-
-@Command(scope = "onos", name = "global-label-pool-destroy",
-description = "Destroys global label resource pool")
-public class GlobalLabelPoolDestoryCommand extends AbstractShellCommand {
- @Override
- protected void execute() {
- LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
- lrs.destroyGlobalPool();
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelReleaseCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelReleaseCommand.java
deleted file mode 100644
index 737f7961..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GlobalLabelReleaseCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2014-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.HashSet;
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-
-@Command(scope = "onos", name = "global-label-release",
-description = "Releases labels to global label resource pool.")
-public class GlobalLabelReleaseCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "releaseLabelIds",
- description = "Represents for the label ids that are released. They are splited by dot symbol",
- required = true, multiValued = false)
- String releaseLabelIds = null;
-
- @Override
- protected void execute() {
- LabelResourceService lrs = get(LabelResourceService.class);
- Set<LabelResourceId> release = new HashSet<LabelResourceId>();
- String[] labelIds = releaseLabelIds.split(",");
- LabelResourceId resource = null;
- for (int i = 0; i < labelIds.length; i++) {
- resource = LabelResourceId.labelResourceId(Long.parseLong(labelIds[i]));
- release.add(resource);
- }
- lrs.releaseToGlobalPool(release);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GroupsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GroupsListCommand.java
deleted file mode 100644
index 2b25744b..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/GroupsListCommand.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.group.Group;
-import org.onosproject.net.group.Group.GroupState;
-import org.onosproject.net.group.GroupBucket;
-import org.onosproject.net.group.GroupService;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-/**
- * Lists all groups in the system.
- */
-@Command(scope = "onos", name = "groups",
- description = "Lists all groups in the system")
-public class GroupsListCommand extends AbstractShellCommand {
-
- private static final String FORMAT =
- " id=0x%s, state=%s, type=%s, bytes=%s, packets=%s, appId=%s";
- private static final String BUCKET_FORMAT =
- " id=0x%s, bucket=%s, bytes=%s, packets=%s, actions=%s";
-
- @Argument(index = 1, name = "uri", description = "Device ID",
- required = false, multiValued = false)
- String uri = null;
-
- @Argument(index = 0, name = "state", description = "Group state",
- required = false, multiValued = false)
- String state;
-
- private JsonNode json(Map<Device, List<Group>> sortedGroups) {
- ArrayNode result = mapper().createArrayNode();
-
- sortedGroups.forEach((device, groups) ->
- groups.forEach(group ->
- result.add(jsonForEntity(group, Group.class))));
-
- return result;
- }
-
- @Override
- protected void execute() {
- DeviceService deviceService = get(DeviceService.class);
- GroupService groupService = get(GroupService.class);
- SortedMap<Device, List<Group>> sortedGroups =
- getSortedGroups(deviceService, groupService);
-
- if (outputJson()) {
- print("%s", json(sortedGroups));
- } else {
- sortedGroups.forEach((device, groups) -> printGroups(device.id(), groups));
- }
- }
-
- /**
- * Returns the list of devices sorted using the device ID URIs.
- *
- * @param deviceService device service
- * @param groupService group service
- * @return sorted device list
- */
- protected SortedMap<Device, List<Group>>
- getSortedGroups(DeviceService deviceService,
- GroupService groupService) {
- SortedMap<Device, List<Group>> sortedGroups =
- new TreeMap<>(Comparators.ELEMENT_COMPARATOR);
- List<Group> groups;
- GroupState s = null;
- if (state != null && !state.equals("any")) {
- s = GroupState.valueOf(state.toUpperCase());
- }
- Iterable<Device> devices = (uri == null) ? deviceService.getDevices() :
- Collections.singletonList(deviceService.getDevice(DeviceId.deviceId(uri)));
- for (Device d : devices) {
- if (s == null) {
- groups = newArrayList(groupService.getGroups(d.id()));
- } else {
- groups = newArrayList();
- for (Group g : groupService.getGroups(d.id())) {
- if (g.state().equals(s)) {
- groups.add(g);
- }
- }
- }
- groups.sort(Comparators.GROUP_COMPARATOR);
- sortedGroups.put(d, groups);
- }
- return sortedGroups;
- }
-
- private void printGroups(DeviceId deviceId, List<Group> groups) {
- print("deviceId=%s, groupCount=%s", deviceId, groups.size());
- for (Group group : groups) {
- print(FORMAT, Integer.toHexString(group.id().id()), group.state(), group.type(),
- group.bytes(), group.packets(), group.appId().name());
- int i = 0;
- for (GroupBucket bucket:group.buckets().buckets()) {
- print(BUCKET_FORMAT, Integer.toHexString(group.id().id()), ++i,
- bucket.bytes(), bucket.packets(),
- bucket.treatment().allInstructions());
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostIdCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostIdCompleter.java
deleted file mode 100644
index 4694425f..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostIdCompleter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2014 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.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.Host;
-import org.onosproject.net.host.HostService;
-
-/**
- * Host ID completer.
- */
-public class HostIdCompleter implements Completer {
-
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- HostService service = AbstractShellCommand.get(HostService.class);
- Iterator<Host> it = service.getHosts().iterator();
- SortedSet<String> strings = delegate.getStrings();
- while (it.hasNext()) {
- strings.add(it.next().id().toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
-
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostRemoveCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostRemoveCommand.java
deleted file mode 100644
index c0db07db..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostRemoveCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.HostId;
-import org.onosproject.net.host.HostAdminService;
-
-/**
- * Removes an end-station host.
- */
-@Command(scope = "onos", name = "host-remove",
- description = "Removes an end-station host")
-public class HostRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Host ID",
- required = true, multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- get(HostAdminService.class).removeHost(HostId.hostId(id));
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostsListCommand.java
deleted file mode 100644
index a90627e4..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/HostsListCommand.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright 2014 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.Collections;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.net.Host;
-import org.onosproject.net.host.HostService;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-import static com.google.common.collect.Lists.newArrayList;
-
-/**
- * Lists all currently-known hosts.
- */
-@Command(scope = "onos", name = "hosts",
- description = "Lists all currently-known hosts.")
-public class HostsListCommand extends AbstractShellCommand {
-
- private static final String FMT =
- "id=%s, mac=%s, location=%s/%s, vlan=%s, ip(s)=%s%s";
-
- @Override
- protected void execute() {
- HostService service = get(HostService.class);
- if (outputJson()) {
- print("%s", json(getSortedHosts(service)));
- } else {
- for (Host host : getSortedHosts(service)) {
- printHost(host);
- }
- }
- }
-
- // Produces JSON structure.
- private JsonNode json(Iterable<Host> hosts) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
-
- hosts.forEach(host -> result.add(jsonForEntity(host, Host.class)));
- return result;
- }
-
- /**
- * Returns the list of devices sorted using the device ID URIs.
- *
- * @param service device service
- * @return sorted device list
- */
- protected List<Host> getSortedHosts(HostService service) {
- List<Host> hosts = newArrayList(service.getHosts());
- Collections.sort(hosts, Comparators.ELEMENT_COMPARATOR);
- return hosts;
- }
-
- /**
- * Prints information about a host.
- *
- * @param host end-station host
- */
- protected void printHost(Host host) {
- if (host != null) {
- print(FMT, host.id(), host.mac(),
- host.location().deviceId(),
- host.location().port(),
- host.vlan(), host.ipAddresses(),
- annotations(host.annotations()));
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6Code.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6Code.java
deleted file mode 100644
index 8568ec62..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6Code.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2014 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.onlab.packet.ICMP6;
-
-/**
- * Known values for ICMPv6 code field that can be supplied to the CLI.
- */
-public enum Icmp6Code {
- // Code for DEST_UNREACH
- /** No route to destination. */
- NO_ROUTE(ICMP6.NO_ROUTE),
- /** Communication with destination administratively prohibited. */
- COMM_PROHIBIT(ICMP6.COMM_PROHIBIT),
- /** Beyond scope of source address. */
- BEYOND_SCOPE(ICMP6.BEYOND_SCOPE),
- /** Address unreachable. */
- ADDR_UNREACH(ICMP6.ADDR_UNREACH),
- /** Port unreachable. */
- PORT_UNREACH(ICMP6.PORT_UNREACH),
- /** Source address failed ingress/egress policy. */
- FAIL_POLICY(ICMP6.FAIL_POLICY),
- /** Reject route to destination. */
- REJECT_ROUTE(ICMP6.REJECT_ROUTE),
- /** Error in Source Routing Header. */
- SRC_ROUTING_HEADER_ERR(ICMP6.SRC_ROUTING_HEADER_ERR),
-
- // Code for TIME_EXCEED
- /** Hop limit exceeded in transit. */
- HOP_LIMIT_EXCEED(ICMP6.HOP_LIMIT_EXCEED),
- /** Fragment reassembly time exceeded. */
- DEFRAG_TIME_EXCEED(ICMP6.DEFRAG_TIME_EXCEED),
-
- // Code for PARAM_ERR
- /** Erroneous header field encountered. */
- HDR_FIELD_ERR(ICMP6.HDR_FIELD_ERR),
- /** Unrecognized Next Header type encountered. */
- NEXT_HEADER_ERR(ICMP6.NEXT_HEADER_ERR),
- /** Unrecognized IPv6 option encountered. */
- IPV6_OPT_ERR(ICMP6.IPV6_OPT_ERR);
-
- private byte value;
-
- /**
- * Constructs an Icmp6Code with the given value.
- *
- * @param value value to use when this Icmp6Code is seen
- */
- private Icmp6Code(byte value) {
- this.value = value;
- }
-
- /**
- * Gets the value to use for this Icmp6Code.
- *
- * @return short value to use for this Icmp6Code
- */
- public byte value() {
- return this.value;
- }
-
- /**
- * Parse a string input that could contain an Icmp6Code value. The value
- * may appear in the string either as a known code name (one of the
- * values of this enum), or a numeric code value.
- *
- * @param input the input string to parse
- * @return the numeric value of the parsed ICMPv6 code
- * @throws IllegalArgumentException if the input string does not contain a
- * value that can be parsed into an ICMPv6 code
- */
- public static byte parseFromString(String input) {
- try {
- return valueOf(input).value();
- } catch (IllegalArgumentException e) {
- // The input is not a known ICMPv6 code name, let's see if it's an ICMP6
- // code value (byte). We parse with Byte to handle unsigned values
- // correctly.
- try {
- return Byte.parseByte(input);
- } catch (NumberFormatException e1) {
- throw new IllegalArgumentException(
- "Icmp6Code value must be either a string code name"
- + " or an 8-bit code value");
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6CodeCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6CodeCompleter.java
deleted file mode 100644
index bf32d4f8..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6CodeCompleter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014 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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * ICMPv6 type completer.
- */
-public class Icmp6CodeCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
-
- for (Icmp6Code code : Icmp6Code.values()) {
- strings.add(code.toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6Type.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6Type.java
deleted file mode 100644
index a9bffd0a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6Type.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2014 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.onlab.packet.ICMP6;
-
-/**
- * Known values for ICMPv6 type field that can be supplied to the CLI.
- */
-public enum Icmp6Type {
- /** Destination Unreachable. */
- DEST_UNREACH(ICMP6.DEST_UNREACH),
- /** Packet Too Big. */
- PKT_TOO_BIG(ICMP6.PKT_TOO_BIG),
- /** Time Exceeded. */
- TIME_EXCEED(ICMP6.TIME_EXCEED),
- /** Parameter Problem. */
- PARAM_ERR(ICMP6.PARAM_ERR),
- /** Echo Request. */
- ECHO_REQUEST(ICMP6.ECHO_REQUEST),
- /** Echo Reply. */
- ECHO_REPLY(ICMP6.ECHO_REPLY),
- /** Multicast Listener Query. */
- MCAST_QUERY(ICMP6.MCAST_QUERY),
- /** Multicast Listener Report. */
- MCAST_REPORT(ICMP6.MCAST_REPORT),
- /** Multicast Listener Done. */
- MCAST_DONE(ICMP6.MCAST_DONE),
- /** Router Solicitation. */
- ROUTER_SOLICITATION(ICMP6.ROUTER_SOLICITATION),
- /** Router Advertisement. */
- ROUTER_ADVERTISEMENT(ICMP6.ROUTER_ADVERTISEMENT),
- /** Neighbor Solicitation. */
- NEIGHBOR_SOLICITATION(ICMP6.NEIGHBOR_SOLICITATION),
- /** Neighbor Advertisement. */
- NEIGHBOR_ADVERTISEMENT(ICMP6.NEIGHBOR_ADVERTISEMENT),
- /** Redirect Message. */
- REDIRECT(ICMP6.REDIRECT);
-
-
- private byte value;
-
- /**
- * Constructs an Icmp6Type with the given value.
- *
- * @param value value to use when this Icmp6Type is seen
- */
- private Icmp6Type(byte value) {
- this.value = value;
- }
-
- /**
- * Gets the value to use for this Icmp6Type.
- *
- * @return short value to use for this Icmp6Type
- */
- public byte value() {
- return this.value;
- }
-
- /**
- * Parse a string input that could contain an Icmp6Type value. The value
- * may appear in the string either as a known type name (one of the
- * values of this enum), or a numeric type value.
- *
- * @param input the input string to parse
- * @return the numeric value of the parsed ICMPv6 type
- * @throws IllegalArgumentException if the input string does not contain a
- * value that can be parsed into an ICMPv6 type
- */
- public static byte parseFromString(String input) {
- try {
- return valueOf(input).value();
- } catch (IllegalArgumentException e) {
- // The input is not a known ICMPv6 type name, let's see if it's an ICMP6
- // type value (byte). We parse with Byte to handle unsigned values
- // correctly.
- try {
- return Byte.parseByte(input);
- } catch (NumberFormatException e1) {
- throw new IllegalArgumentException(
- "Icmp6Type value must be either a string type name"
- + " or an 8-bit type value");
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6TypeCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6TypeCompleter.java
deleted file mode 100644
index 8871388e..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Icmp6TypeCompleter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014 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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * ICMPv6 type completer.
- */
-public class Icmp6TypeCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
-
- for (Icmp6Type type : Icmp6Type.values()) {
- strings.add(type.toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentCycleCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentCycleCommand.java
deleted file mode 100644
index 1c01c5ba..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentCycleCommand.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * 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.EnumSet;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentEvent;
-import org.onosproject.net.intent.IntentEvent.Type;
-import org.onosproject.net.intent.IntentListener;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.PointToPointIntent;
-
-import com.google.common.collect.Lists;
-
-import static org.onlab.util.Tools.delay;
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.PortNumber.portNumber;
-
-/**
- * Installs point-to-point connectivity intents.
- */
-@Command(scope = "onos", name = "cycle-intents",
- description = "Installs random intents to test throughput")
-public class IntentCycleCommand extends AbstractShellCommand
- implements IntentListener {
-
- @Argument(index = 0, name = "ingressDevice",
- description = "Ingress Device/Port Description",
- required = true, multiValued = false)
- String ingressDeviceString = null;
-
- @Argument(index = 1, name = "egressDevice",
- description = "Egress Device/Port Description",
- required = true, multiValued = false)
- String egressDeviceString = null;
-
- @Argument(index = 2, name = "numberOfIntents",
- description = "Number of intents to install/withdraw",
- required = true, multiValued = false)
- String numberOfIntents = null;
-
- @Argument(index = 3, name = "keyOffset",
- description = "Starting point for first key (default: 1)",
- required = false, multiValued = false)
- String keyOffsetStr = null;
-
- private IntentService service;
- private CountDownLatch latch;
- private volatile long start, end;
- private int count;
- private int keyOffset;
- private long submitCounter = 0;
- private AtomicLong eventCounter = new AtomicLong(0);
- private boolean add;
-
- @Override
- protected void execute() {
- service = get(IntentService.class);
-
-
- DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
- PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
- ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
-
- DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
- PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
- ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
-
- count = Integer.parseInt(numberOfIntents);
- keyOffset = (keyOffsetStr != null) ? Integer.parseInt(keyOffsetStr) : 1;
-
- service.addListener(this);
-
- List<Intent> operations = generateIntents(ingress, egress);
-
- add = true;
- start = System.currentTimeMillis();
- while (start + 10000 > System.currentTimeMillis()) {
- submitIntents(operations);
- }
- delay(5000);
- printResults();
-
- add = false;
- submitIntents(operations);
-
- service.removeListener(this);
- }
-
- private List<Intent> generateIntents(ConnectPoint ingress, ConnectPoint egress) {
- TrafficSelector.Builder selectorBldr = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4);
- TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
-
- List<Intent> intents = Lists.newArrayList();
- for (int i = 0; i < count; i++) {
- TrafficSelector selector = selectorBldr
- .matchEthSrc(MacAddress.valueOf(i + keyOffset))
- .build();
- intents.add(
- PointToPointIntent.builder()
- .appId(appId())
- .key(Key.of(i + keyOffset, appId()))
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(ingress)
- .egressPoint(egress)
- .build());
-
-
- }
- return intents;
- }
-
- private void submitIntents(List<Intent> intents) {
- for (Intent intent : intents) {
- if (add) {
- submitCounter++;
- service.submit(intent);
- } else {
- service.withdraw(intent);
- }
- }
- }
-
- private void printResults() {
- //long delta = end - start;
- //String text = add ? "install" : "withdraw";
- print("count: %s / %s", eventCounter, Long.valueOf(submitCounter));
- //print("Time to %s %d intents: %d ms", text, count, delta);
- }
-
- /**
- * Extracts the port number portion of the ConnectPoint.
- *
- * @param deviceString string representing the device/port
- * @return port number as a string, empty string if the port is not found
- */
- private String getPortNumber(String deviceString) {
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return "";
- }
- return deviceString.substring(slash + 1, deviceString.length());
- }
-
- /**
- * Extracts the device ID portion of the ConnectPoint.
- *
- * @param deviceString string representing the device/port
- * @return device ID string
- */
- private String getDeviceId(String deviceString) {
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return "";
- }
- return deviceString.substring(0, slash);
- }
-
- private static final EnumSet<Type> IGNORE_EVENT
- = EnumSet.of(Type.INSTALL_REQ, Type.WITHDRAW_REQ);
- @Override
- public synchronized void event(IntentEvent event) {
- if (!appId().equals(event.subject().appId())) {
- // not my event, ignore
- return;
- }
- Type expected = add ? Type.INSTALLED : Type.WITHDRAWN;
- if (event.type() == expected) {
- eventCounter.getAndIncrement();
- } else if (IGNORE_EVENT.contains(event.type())) {
- log.info("Unexpected intent event: {}", event);
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentKeyCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentKeyCompleter.java
deleted file mode 100644
index e3f647b4..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentKeyCompleter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2014-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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Intent Key completer.
- */
-public class IntentKeyCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- IntentService service = AbstractShellCommand.get(IntentService.class);
- Iterator<Intent> it = service.getIntents().iterator();
- SortedSet<String> strings = delegate.getStrings();
- while (it.hasNext()) {
- strings.add(it.next().key().toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentPurgeCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentPurgeCommand.java
deleted file mode 100644
index 61174e70..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentPurgeCommand.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-
-import static org.onosproject.net.intent.IntentState.WITHDRAWN;
-
-/**
- * Purges all WITHDRAWN intents.
- */
-@Command(scope = "onos", name = "purge-intents",
- description = "Purges all WITHDRAWN intents")
-public class IntentPurgeCommand extends AbstractShellCommand {
- @Override
- protected void execute() {
- IntentService intentService = get(IntentService.class);
- for (Intent intent: intentService.getIntents()) {
- if (intentService.getIntentState(intent.key()) == WITHDRAWN) {
- intentService.purge(intent);
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java
deleted file mode 100644
index 15921fed..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentPushTestCommand.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2014-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.EnumSet;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentEvent;
-import org.onosproject.net.intent.IntentEvent.Type;
-import org.onosproject.net.intent.IntentListener;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.Key;
-import org.onosproject.net.intent.PointToPointIntent;
-
-import com.google.common.collect.Lists;
-
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.PortNumber.portNumber;
-
-/**
- * Installs bulk point-to-point connectivity intents between given ingress/egress devices.
- */
-@Command(scope = "onos", name = "push-test-intents",
- description = "Installs random intents to test throughput")
-public class IntentPushTestCommand extends AbstractShellCommand
- implements IntentListener {
-
- @Argument(index = 0, name = "ingressDevice",
- description = "Ingress Device/Port Description",
- required = true, multiValued = false)
- String ingressDeviceString = null;
-
- @Argument(index = 1, name = "egressDevice",
- description = "Egress Device/Port Description",
- required = true, multiValued = false)
- String egressDeviceString = null;
-
- @Argument(index = 2, name = "numberOfIntents",
- description = "Number of intents to install/withdraw",
- required = true, multiValued = false)
- String numberOfIntents = null;
-
- @Argument(index = 3, name = "keyOffset",
- description = "Starting point for first key (default: 1)",
- required = false, multiValued = false)
- String keyOffsetStr = null;
-
- @Option(name = "-i", aliases = "--install",
- description = "Install intents",
- required = false, multiValued = false)
- private boolean installOnly = false;
-
- @Option(name = "-w", aliases = "--withdraw",
- description = "Withdraw intents",
- required = false, multiValued = false)
- private boolean withdrawOnly = false;
-
- private IntentService service;
- private CountDownLatch latch;
- private volatile long start, end;
- private int count;
- private int keyOffset;
- private boolean add;
-
- @Override
- protected void execute() {
- service = get(IntentService.class);
-
-
- DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
- PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
- ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
-
- DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
- PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
- ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
-
- count = Integer.parseInt(numberOfIntents);
- keyOffset = (keyOffsetStr != null) ? Integer.parseInt(keyOffsetStr) : 1;
-
- service.addListener(this);
-
- List<Intent> operations = generateIntents(ingress, egress);
-
- boolean both = !(installOnly ^ withdrawOnly);
-
- if (installOnly || both) {
- add = true;
- submitIntents(operations);
- }
-
- if (withdrawOnly || both) {
- add = false;
- submitIntents(operations);
- }
-
- service.removeListener(this);
- }
-
- private List<Intent> generateIntents(ConnectPoint ingress, ConnectPoint egress) {
- TrafficSelector.Builder selectorBldr = DefaultTrafficSelector.builder()
- .matchEthType(Ethernet.TYPE_IPV4);
- TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
-
- List<Intent> intents = Lists.newArrayList();
- for (int i = 0; i < count; i++) {
- TrafficSelector selector = selectorBldr
- .matchEthSrc(MacAddress.valueOf(i + keyOffset))
- .build();
- intents.add(PointToPointIntent.builder()
- .appId(appId())
- .key(Key.of(i + keyOffset, appId()))
- .selector(selector)
- .treatment(treatment)
- .ingressPoint(ingress)
- .egressPoint(egress)
- .build());
-
-
- }
- return intents;
- }
-
- private void submitIntents(List<Intent> intents) {
- latch = new CountDownLatch(count);
- start = System.currentTimeMillis();
- for (Intent intent : intents) {
- if (add) {
- service.submit(intent);
- } else {
- service.withdraw(intent);
- }
- }
-
- try {
- if (latch.await(500 + count * 30, TimeUnit.MILLISECONDS)) {
- printResults(count);
- } else {
- print("Failure: %d intents not installed", latch.getCount());
- }
- } catch (InterruptedException e) {
- print(e.toString());
- }
- }
-
- private void printResults(int count) {
- long delta = end - start;
- String text = add ? "install" : "withdraw";
- print("Time to %s %d intents: %d ms", text, count, delta);
- }
-
- /**
- * Extracts the port number portion of the ConnectPoint.
- *
- * @param deviceString string representing the device/port
- * @return port number as a string, empty string if the port is not found
- */
- private String getPortNumber(String deviceString) {
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return "";
- }
- return deviceString.substring(slash + 1, deviceString.length());
- }
-
- /**
- * Extracts the device ID portion of the ConnectPoint.
- *
- * @param deviceString string representing the device/port
- * @return device ID string
- */
- private String getDeviceId(String deviceString) {
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return "";
- }
- return deviceString.substring(0, slash);
- }
-
- private static final EnumSet<IntentEvent.Type> IGNORE_EVENT
- = EnumSet.of(Type.INSTALL_REQ, Type.WITHDRAW_REQ);
- @Override
- public synchronized void event(IntentEvent event) {
- if (!appId().equals(event.subject().appId())) {
- // not my event, ignore
- return;
- }
- Type expected = add ? Type.INSTALLED : Type.WITHDRAWN;
- if (event.type() == expected) {
- end = Math.max(end, event.time());
- if (latch != null) {
- if (latch.getCount() == 0) {
- log.warn("Latch was already 0 before counting down?");
- }
- latch.countDown();
- } else {
- log.warn("install event latch is null");
- }
- } else if (IGNORE_EVENT.contains(event.type())) {
- log.debug("Unexpected intent event: {}", event);
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java
deleted file mode 100644
index 492b3a27..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentRemoveCommand.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.IntentListener;
-import org.onosproject.net.intent.IntentEvent;
-import org.onosproject.net.intent.Key;
-
-import java.math.BigInteger;
-import java.util.EnumSet;
-import java.util.Objects;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static com.google.common.base.Strings.isNullOrEmpty;
-import static org.onosproject.net.intent.IntentState.FAILED;
-import static org.onosproject.net.intent.IntentState.WITHDRAWN;
-
-/**
- * Removes an intent.
- */
-@Command(scope = "onos", name = "remove-intent",
- description = "Removes the specified intent")
-public class IntentRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "app",
- description = "Application ID",
- required = false, multiValued = false)
- String applicationIdString = null;
-
- @Argument(index = 1, name = "key",
- description = "Intent Key",
- required = false, multiValued = false)
- String keyString = null;
-
- @Option(name = "-p", aliases = "--purge",
- description = "Purge the intent from the store after removal",
- required = false, multiValued = false)
- private boolean purgeAfterRemove = false;
-
- @Option(name = "-s", aliases = "--sync",
- description = "Waits for the removal before returning",
- required = false, multiValued = false)
- private boolean sync = false;
-
- private static final EnumSet<IntentState> CAN_PURGE = EnumSet.of(WITHDRAWN, FAILED);
-
- @Override
- protected void execute() {
- IntentService intentService = get(IntentService.class);
- CoreService coreService = get(CoreService.class);
-
- if (purgeAfterRemove || sync) {
- print("Using \"sync\" to remove/purge intents - this may take a while...");
- print("Check \"summary\" to see remove/purge progress.");
- }
-
- ApplicationId appId = appId();
- if (!isNullOrEmpty(applicationIdString)) {
- appId = coreService.getAppId(applicationIdString);
- if (appId == null) {
- print("Cannot find application Id %s", applicationIdString);
- return;
- }
- }
-
- if (isNullOrEmpty(keyString)) {
- for (Intent intent : intentService.getIntents()) {
- if (intent.appId().equals(appId)) {
- removeIntent(intentService, intent);
- }
- }
-
- } else {
- final Key key;
- if (keyString.startsWith("0x")) {
- // The intent uses a LongKey
- keyString = keyString.replaceFirst("0x", "");
- key = Key.of(new BigInteger(keyString, 16).longValue(), appId);
- } else {
- // The intent uses a StringKey
- key = Key.of(keyString, appId);
- }
-
- Intent intent = intentService.getIntent(key);
- if (intent != null) {
- removeIntent(intentService, intent);
- }
- }
- }
-
- private void removeIntent(IntentService intentService, Intent intent) {
- IntentListener listener = null;
- Key key = intent.key();
- final CountDownLatch withdrawLatch, purgeLatch;
- if (purgeAfterRemove || sync) {
- // set up latch and listener to track uninstall progress
- withdrawLatch = new CountDownLatch(1);
- purgeLatch = purgeAfterRemove ? new CountDownLatch(1) : null;
- listener = (IntentEvent event) -> {
- if (Objects.equals(event.subject().key(), key)) {
- if (event.type() == IntentEvent.Type.WITHDRAWN ||
- event.type() == IntentEvent.Type.FAILED) {
- withdrawLatch.countDown();
- } else if (purgeAfterRemove &&
- event.type() == IntentEvent.Type.PURGED) {
- purgeLatch.countDown();
- }
- }
- };
- intentService.addListener(listener);
- } else {
- purgeLatch = null;
- withdrawLatch = null;
- }
-
- // request the withdraw
- intentService.withdraw(intent);
-
- if (purgeAfterRemove || sync) {
- try { // wait for withdraw event
- withdrawLatch.await(5, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- print("Timed out waiting for intent {} withdraw", key);
- }
- if (purgeAfterRemove && CAN_PURGE.contains(intentService.getIntentState(key))) {
- intentService.purge(intent);
- if (sync) { // wait for purge event
- /* TODO
- Technically, the event comes before map.remove() is called.
- If we depend on sync and purge working together, we will
- need to address this.
- */
- try {
- purgeLatch.await(5, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- print("Timed out waiting for intent {} purge", key);
- }
- }
- }
- }
-
- if (listener != null) {
- // clean up the listener
- intentService.removeListener(listener);
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentsListCommand.java
deleted file mode 100644
index 55b9ec9c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IntentsListCommand.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright 2014-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.List;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.intent.ConnectivityIntent;
-import org.onosproject.net.intent.HostToHostIntent;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.intent.LinkCollectionIntent;
-import org.onosproject.net.intent.MultiPointToSinglePointIntent;
-import org.onosproject.net.intent.PathIntent;
-import org.onosproject.net.intent.PointToPointIntent;
-import org.onosproject.net.intent.SinglePointToMultiPointIntent;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * 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 {
-
- @Option(name = "-i", aliases = "--installable",
- description = "Output Installable Intents",
- required = false, multiValued = false)
- private boolean showInstallable = false;
-
- @Option(name = "-s", aliases = "--summary",
- description = "Intents summary",
- required = false, multiValued = false)
- private boolean intentsSummary = false;
-
- @Option(name = "-p", aliases = "--pending",
- description = "Show inforamtion about pending intents",
- required = false, multiValued = false)
- private boolean pending = false;
-
- @Override
- protected void execute() {
- IntentService service = get(IntentService.class);
-
- if (intentsSummary) {
- IntentSummaries intentSummaries = new IntentSummaries();
- intentSummaries.collectIntentSummary(service,
- service.getIntents());
- if (outputJson()) {
- print("%s", intentSummaries.json());
- } else {
- intentSummaries.printSummary();
- }
- return;
- } else if (pending) {
- if (outputJson()) {
- print("%s", json(service, service.getPending()));
- } else {
- service.getPending().forEach(intent ->
- print("id=%s, key=%s, type=%s, appId=%s",
- intent.id(), intent.key(),
- intent.getClass().getSimpleName(),
- intent.appId().name())
- );
- }
- return;
- }
-
- if (outputJson()) {
- print("%s", json(service, service.getIntents()));
- } else {
- for (Intent intent : service.getIntents()) {
- IntentState state = service.getIntentState(intent.key());
- if (state != null) {
- print("id=%s, state=%s, key=%s, type=%s, appId=%s",
- intent.id(), state, intent.key(),
- intent.getClass().getSimpleName(),
- intent.appId().name());
- printDetails(service, intent);
- }
- }
- }
- }
-
- /**
- * Internal local class to keep track of all intent summaries.
- */
- private class IntentSummaries {
- private IntentSummary summaryAll;
- private IntentSummary summaryConnectivity;
- private IntentSummary summaryHostToHost;
- private IntentSummary summaryPointToPoint;
- private IntentSummary summaryMultiPointToSinglePoint;
- private IntentSummary summarySinglePointToMultiPoint;
- private IntentSummary summaryPath;
- private IntentSummary summaryLinkCollection;
- private IntentSummary summaryUnknownType;
-
- /**
- * Initializes the internal state.
- */
- private void init() {
- summaryAll = new IntentSummary("All");
- summaryConnectivity = new IntentSummary("Connectivity");
- summaryHostToHost = new IntentSummary("HostToHost");
- summaryPointToPoint = new IntentSummary("PointToPoint");
- summaryMultiPointToSinglePoint =
- new IntentSummary("MultiPointToSinglePoint");
- summarySinglePointToMultiPoint =
- new IntentSummary("SinglePointToMultiPoint");
- summaryPath = new IntentSummary("Path");
- summaryLinkCollection = new IntentSummary("LinkCollection");
- summaryUnknownType = new IntentSummary("UnknownType");
- }
-
- /**
- * Collects summary of all intents.
- *
- * @param service the Intent Service to use
- * @param intents the intents
- */
- private void collectIntentSummary(IntentService service,
- Iterable<Intent> intents) {
- init();
-
- // Collect the summary for each intent type intents
- for (Intent intent : intents) {
- IntentState intentState = service.getIntentState(intent.key());
- if (intentState == null) {
- continue;
- }
-
- // Update the summary for all Intents
- summaryAll.update(intentState);
-
- if (intent instanceof ConnectivityIntent) {
- summaryConnectivity.update(intentState);
- // NOTE: ConnectivityIntent is a base type Intent
- // continue;
- }
- if (intent instanceof HostToHostIntent) {
- summaryHostToHost.update(intentState);
- continue;
- }
- if (intent instanceof PointToPointIntent) {
- summaryPointToPoint.update(intentState);
- continue;
- }
- if (intent instanceof MultiPointToSinglePointIntent) {
- summaryMultiPointToSinglePoint.update(intentState);
- continue;
- }
- if (intent instanceof SinglePointToMultiPointIntent) {
- summarySinglePointToMultiPoint.update(intentState);
- continue;
- }
- if (intent instanceof PathIntent) {
- summaryPath.update(intentState);
- continue;
- }
- if (intent instanceof LinkCollectionIntent) {
- summaryLinkCollection.update(intentState);
- continue;
- }
-
- summaryUnknownType.update(intentState);
- }
- }
-
- /**
- * Gets JSON representation of all Intents summary.
- *
- * @return JSON representation of all Intents summary
- */
- ObjectNode json() {
- ObjectMapper mapper = new ObjectMapper();
- ObjectNode result = mapper.createObjectNode();
- result.set("connectivity", summaryConnectivity.json(mapper));
- result.set("hostToHost", summaryHostToHost.json(mapper));
- result.set("pointToPoint", summaryPointToPoint.json(mapper));
- result.set("multiPointToSinglePoint",
- summaryMultiPointToSinglePoint.json(mapper));
- result.set("singlePointToMultiPoint",
- summarySinglePointToMultiPoint.json(mapper));
- result.set("path", summaryPath.json(mapper));
- result.set("linkCollection", summaryLinkCollection.json(mapper));
- result.set("unknownType", summaryUnknownType.json(mapper));
- result.set("all", summaryAll.json(mapper));
- return result;
- }
-
- /**
- * Prints summary of the intents.
- */
- private void printSummary() {
- summaryConnectivity.printState();
- summaryHostToHost.printState();
- summaryPointToPoint.printState();
- summaryMultiPointToSinglePoint.printState();
- summarySinglePointToMultiPoint.printState();
- summaryPath.printState();
- summaryLinkCollection.printState();
- summaryUnknownType.printState();
- summaryAll.printState();
- }
-
- /**
- * Internal local class to keep track of a single type Intent summary.
- */
- private class IntentSummary {
- private final String intentType;
- private int total = 0;
- private int installReq = 0;
- private int compiling = 0;
- private int installing = 0;
- private int installed = 0;
- private int recompiling = 0;
- private int withdrawReq = 0;
- private int withdrawing = 0;
- private int withdrawn = 0;
- private int failed = 0;
- private int unknownState = 0;
-
- private static final String FORMAT_SUMMARY_LINE1 =
- "%-23s total= %7d installed= %7d";
- private static final String FORMAT_SUMMARY_LINE2 =
- "%-23s withdrawn= %7d failed= %7d";
- private static final String FORMAT_SUMMARY_LINE3 =
- "%-23s installReq= %7d compiling= %7d";
- private static final String FORMAT_SUMMARY_LINE4 =
- "%-23s installing= %7d recompiling= %7d";
- private static final String FORMAT_SUMMARY_LINE5 =
- "%-23s withdrawReq= %7d withdrawing= %7d";
- private static final String FORMAT_SUMMARY_LINE6 =
- "%-23s unknownState= %7d";
-
- /**
- * Constructor.
- *
- * @param intentType the scring describing the Intent type
- */
- IntentSummary(String intentType) {
- this.intentType = intentType;
- }
-
- /**
- * Updates the Intent Summary.
- *
- * @param intentState the state of the Intent
- */
- void update(IntentState intentState) {
- total++;
- switch (intentState) {
- case INSTALL_REQ:
- installReq++;
- break;
- case COMPILING:
- compiling++;
- break;
- case INSTALLING:
- installing++;
- break;
- case INSTALLED:
- installed++;
- break;
- case RECOMPILING:
- recompiling++;
- break;
- case WITHDRAW_REQ:
- withdrawReq++;
- break;
- case WITHDRAWING:
- withdrawing++;
- break;
- case WITHDRAWN:
- withdrawn++;
- break;
- case FAILED:
- failed++;
- break;
- default:
- unknownState++;
- break;
- }
- }
-
- /**
- * Prints the Intent Summary.
- */
- void printState() {
- print(FORMAT_SUMMARY_LINE1, intentType, total, installed);
- print(FORMAT_SUMMARY_LINE2, intentType, withdrawn, failed);
- print(FORMAT_SUMMARY_LINE3, intentType, installReq, compiling);
- print(FORMAT_SUMMARY_LINE4, intentType, installing, recompiling);
- print(FORMAT_SUMMARY_LINE5, intentType, withdrawReq, withdrawing);
- if (unknownState != 0) {
- print(FORMAT_SUMMARY_LINE6, intentType, unknownState);
- }
- }
-
- /**
- * Gets the JSON representation of the Intent Summary.
- *
- * @return the JSON representation of the Intent Summary
- */
- JsonNode json(ObjectMapper mapper) {
- ObjectNode result = mapper.createObjectNode()
- .put("total", total)
- .put("installed", installed)
- .put("failed", failed)
- .put("installReq", installReq)
- .put("compiling", compiling)
- .put("installing", installing)
- .put("recompiling", recompiling)
- .put("withdrawReq", withdrawReq)
- .put("withdrawing", withdrawing)
- .put("withdrawn", withdrawn)
- .put("unknownState", unknownState);
-
- return result;
- }
- }
- }
-
- private void printDetails(IntentService service, Intent intent) {
- if (!intent.resources().isEmpty()) {
- print(" resources=%s", intent.resources());
- }
- if (intent instanceof ConnectivityIntent) {
- ConnectivityIntent ci = (ConnectivityIntent) intent;
- if (!ci.selector().criteria().isEmpty()) {
- print(" selector=%s", ci.selector().criteria());
- }
- if (!ci.treatment().allInstructions().isEmpty()) {
- print(" treatment=%s", ci.treatment().allInstructions());
- }
- if (ci.constraints() != null && !ci.constraints().isEmpty()) {
- print(" constraints=%s", ci.constraints());
- }
- }
-
- if (intent instanceof HostToHostIntent) {
- HostToHostIntent pi = (HostToHostIntent) intent;
- print(" host1=%s, host2=%s", pi.one(), pi.two());
- } else if (intent instanceof PointToPointIntent) {
- PointToPointIntent pi = (PointToPointIntent) intent;
- print(" ingress=%s, egress=%s", pi.ingressPoint(), pi.egressPoint());
- } else if (intent instanceof MultiPointToSinglePointIntent) {
- MultiPointToSinglePointIntent pi = (MultiPointToSinglePointIntent) intent;
- print(" ingress=%s, egress=%s", pi.ingressPoints(), pi.egressPoint());
- } else if (intent instanceof SinglePointToMultiPointIntent) {
- SinglePointToMultiPointIntent pi = (SinglePointToMultiPointIntent) intent;
- print(" ingress=%s, egress=%s", pi.ingressPoint(), pi.egressPoints());
- } else if (intent instanceof PathIntent) {
- PathIntent pi = (PathIntent) intent;
- print(" path=%s, cost=%d", pi.path().links(), pi.path().cost());
- } else if (intent instanceof LinkCollectionIntent) {
- LinkCollectionIntent li = (LinkCollectionIntent) intent;
- print(" links=%s", li.links());
- print(" egress=%s", li.egressPoints());
- }
-
- List<Intent> installable = service.getInstallableIntents(intent.key());
- if (showInstallable && installable != null && !installable.isEmpty()) {
- print(" installable=%s", installable);
- }
- }
-
- // Produces JSON array of the specified intents.
- private JsonNode json(IntentService service, Iterable<Intent> intents) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
-
- intents.forEach(intent -> result.add(jsonForEntity(intent, Intent.class)));
- return result;
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfaceAddCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfaceAddCommand.java
deleted file mode 100644
index ae4e410c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfaceAddCommand.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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 com.google.common.collect.Sets;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.intf.Interface;
-import org.onosproject.incubator.net.intf.InterfaceAdminService;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.host.InterfaceIpAddress;
-
-import java.util.Set;
-
-/**
- * Adds a new interface configuration.
- */
-@Command(scope = "onos", name = "add-interface",
- description = "Adds a new configured interface")
-public class InterfaceAddCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "port",
- description = "Device port that the interface is associated with",
- required = true, multiValued = false)
- private String connectPoint = null;
-
- @Argument(index = 1, name = "name", description = "Interface name",
- required = true, multiValued = false)
- private String name = null;
-
- @Option(name = "-m", aliases = "--mac",
- description = "MAC address of the interface",
- required = false, multiValued = false)
- private String mac = null;
-
- @Option(name = "-i", aliases = "--ip",
- description = "IP address configured on the interface\n" +
- "(e.g. 10.0.1.1/24). Can be specified multiple times.",
- required = false, multiValued = true)
- private String[] ips = null;
-
- @Option(name = "-v", aliases = "--vlan",
- description = "VLAN configured on the interface",
- required = false, multiValued = false)
- private String vlan = null;
-
- @Override
- protected void execute() {
- InterfaceAdminService interfaceService = get(InterfaceAdminService.class);
-
- Set<InterfaceIpAddress> ipAddresses = Sets.newHashSet();
- if (ips != null) {
- for (String strIp : ips) {
- ipAddresses.add(InterfaceIpAddress.valueOf(strIp));
- }
- }
-
- MacAddress macAddr = mac == null ? null : MacAddress.valueOf(mac);
-
- VlanId vlanId = vlan == null ? VlanId.NONE : VlanId.vlanId(Short.parseShort(vlan));
-
- Interface intf = new Interface(name,
- ConnectPoint.deviceConnectPoint(connectPoint),
- ipAddresses, macAddr, vlanId);
-
- interfaceService.add(intf);
-
- print("Interface added");
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfaceRemoveCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfaceRemoveCommand.java
deleted file mode 100644
index 0a7b5a16..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfaceRemoveCommand.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.intf.InterfaceAdminService;
-import org.onosproject.net.ConnectPoint;
-
-/**
- * Removes an interface configuration.
- */
-@Command(scope = "onos", name = "remove-interface",
- description = "Removes a configured interface")
-public class InterfaceRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "connectPoint",
- description = "Connect point of the interface",
- required = true, multiValued = false)
- private String connectPoint = null;
-
- @Argument(index = 1, name = "name",
- description = "Interface name",
- required = true, multiValued = false)
- private String name = null;
-
- @Override
- protected void execute() {
- InterfaceAdminService interfaceService = get(InterfaceAdminService.class);
-
- boolean success = interfaceService.remove(
- ConnectPoint.deviceConnectPoint(connectPoint), name);
-
- if (success) {
- print("Interface removed");
- } else {
- print("Unable to remove interface");
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfacesListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfacesListCommand.java
deleted file mode 100644
index fb3e68c2..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/InterfacesListCommand.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * 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 com.google.common.collect.Lists;
-import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.incubator.net.intf.Interface;
-import org.onosproject.incubator.net.intf.InterfaceService;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Lists all configured interfaces.
- */
-@Command(scope = "onos", name = "interfaces",
- description = "Lists all configured interfaces.")
-public class InterfacesListCommand extends AbstractShellCommand {
-
- private static final String FORMAT = "%s: port=%s/%s";
- private static final String IP_FORMAT = " ips=";
- private static final String MAC_FORMAT = " mac=";
- private static final String VLAN_FORMAT = " vlan=";
-
- private static final String NO_NAME = "(unamed)";
-
- @Override
- protected void execute() {
- InterfaceService interfaceService = get(InterfaceService.class);
-
- List<Interface> interfaces = Lists.newArrayList(interfaceService.getInterfaces());
-
- Collections.sort(interfaces, Comparators.INTERFACES_COMPARATOR);
-
- interfaces.forEach(this::printInterface);
- }
-
- private void printInterface(Interface intf) {
- StringBuilder formatStringBuilder = new StringBuilder(FORMAT);
-
- if (!intf.ipAddresses().isEmpty()) {
- formatStringBuilder.append(IP_FORMAT);
- formatStringBuilder.append(intf.ipAddresses().toString());
- }
-
- if (!intf.mac().equals(MacAddress.NONE)) {
- formatStringBuilder.append(MAC_FORMAT);
- formatStringBuilder.append(intf.mac().toString());
- }
-
- if (!intf.vlan().equals(VlanId.NONE)) {
- formatStringBuilder.append(VLAN_FORMAT);
- formatStringBuilder.append(intf.vlan().toString());
- }
-
- String name = (intf.name().equals(Interface.NO_INTERFACE_NAME)) ?
- NO_NAME : intf.name();
-
- print(formatStringBuilder.toString(), name, intf.connectPoint().deviceId(),
- intf.connectPoint().port());
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IpProtocol.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IpProtocol.java
deleted file mode 100644
index 5e0d865e..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IpProtocol.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2014 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.onlab.packet.IPv4;
-import org.onlab.packet.IPv6;
-
-/**
- * Known protocol values for IP protocol field that can be supplied to the CLI.
- */
-public enum IpProtocol {
- /** ICMP. **/
- ICMP(IPv4.PROTOCOL_ICMP),
- /** TCP. **/
- TCP(IPv4.PROTOCOL_TCP),
- /** UDP. **/
- UDP(IPv4.PROTOCOL_UDP),
- /** ICMP6. **/
- ICMP6(IPv6.PROTOCOL_ICMP6);
-
- private short value;
-
- /**
- * Constructs an IpProtocol with the given value.
- *
- * @param value value to use when this IpProtocol is seen
- */
- private IpProtocol(short value) {
- this.value = value;
- }
-
- /**
- * Gets the value to use for this IpProtocol.
- *
- * @return short value to use for this IpProtocol
- */
- public short value() {
- return this.value;
- }
-
- /**
- * Parse a string input that could contain an IpProtocol value. The value
- * may appear in the string either as a known protocol name (one of the
- * values of this enum), or a numeric protocol value.
- *
- * @param input the input string to parse
- * @return the numeric value of the parsed IP protocol
- * @throws IllegalArgumentException if the input string does not contain a
- * value that can be parsed into an IP protocol
- */
- public static short parseFromString(String input) {
- try {
- return valueOf(input).value();
- } catch (IllegalArgumentException e) {
- // The input is not a known IP protocol name, let's see if it's an IP
- // protocol value (byte). We parse with Short to handle unsigned values
- // correctly.
- try {
- return Short.parseShort(input);
- } catch (NumberFormatException e1) {
- throw new IllegalArgumentException(
- "IpProtocol value must be either a string protocol name"
- + " or an 8-bit protocol value");
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IpProtocolCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IpProtocolCompleter.java
deleted file mode 100644
index ec02b1da..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/IpProtocolCompleter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014 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.List;
-import java.util.SortedSet;
-
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-
-/**
- * IP protocol completer.
- */
-public class IpProtocolCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
-
- for (IpProtocol ip : IpProtocol.values()) {
- strings.add(ip.toString());
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java
deleted file mode 100644
index c88d41c4..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelApplyCommand.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2014-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.Collection;
-import java.util.Iterator;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-
-@Command(scope = "onos", name = "label-apply",
- description = "Apply label resource from device pool by specific device id")
-public class LabelApplyCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "deviceId",
- description = "Device identity",
- required = true, multiValued = false)
- String deviceId = null;
- @Argument(index = 1, name = "applyNum",
- description = "Applying number means how many labels applications want to use.",
- required = true, multiValued = false)
- String applyNum = null;
-
- private static final String FMT = "deviceid=%s, labelresourceid=%s";
-
- @Override
- protected void execute() {
- LabelResourceService lrs = get(LabelResourceService.class);
- Collection<LabelResource> result = lrs.applyFromDevicePool(DeviceId
- .deviceId(deviceId), Long.parseLong(applyNum));
- if (result.size() > 0) {
- for (Iterator<LabelResource> iterator = result.iterator(); iterator
- .hasNext();) {
- DefaultLabelResource defaultLabelResource = (DefaultLabelResource) iterator
- .next();
- print(FMT, defaultLabelResource.deviceId().toString(),
- defaultLabelResource.labelResourceId().toString());
- }
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelPoolCreateCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelPoolCreateCommand.java
deleted file mode 100644
index 78a6d196..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelPoolCreateCommand.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-
-/**
- * create label resource pool by specific device id.
- */
-@Command(scope = "onos", name = "label-pool-create",
- description = "Creates label resource pool by a specific device id")
-public class LabelPoolCreateCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
- String deviceId = null;
- @Argument(index = 1, name = "beginLabel",
- description = "The first label of global label resource pool.", required = true, multiValued = false)
- String beginLabel = null;
- @Argument(index = 2, name = "endLabel",
- description = "The last label of global label resource pool.", required = true, multiValued = false)
- String endLabel = null;
-
- @Override
- protected void execute() {
- LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
- lrs.createDevicePool(DeviceId.deviceId(deviceId), LabelResourceId
- .labelResourceId(Long.parseLong(beginLabel)), LabelResourceId
- .labelResourceId(Long.parseLong(endLabel)));
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelPoolDestroyCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelPoolDestroyCommand.java
deleted file mode 100644
index 6445de63..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelPoolDestroyCommand.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
-
-@Command(scope = "onos", name = "label-pool-destroy",
- description = "Destroys label resource pool by a specific device id")
-public class LabelPoolDestroyCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "deviceId", description = "Device identity", required = true, multiValued = false)
- String deviceId = null;
-
- @Override
- protected void execute() {
- LabelResourceAdminService lrs = get(LabelResourceAdminService.class);
- lrs.destroyDevicePool(DeviceId.deviceId(deviceId));
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelReleaseCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelReleaseCommand.java
deleted file mode 100644
index cc52204c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelReleaseCommand.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResource;
-import org.onosproject.incubator.net.resource.label.LabelResourceId;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
-@Command(scope = "onos", name = "label-release",
-description = "Releases label ids to label resource pool by a specific device id")
-public class LabelReleaseCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "deviceId",
- description = "Device identity",
- required = true, multiValued = false)
- String deviceId = null;
- @Argument(index = 1, name = "releaseLabelIds",
- description = "Represents for the label ids that are released. They are splited by dot symbol",
- required = true, multiValued = false)
- String releaseLabelIds = null;
-
- @Override
- protected void execute() {
- LabelResourceService lrs = get(LabelResourceService.class);
- Multimap<DeviceId, LabelResource> map = ArrayListMultimap
- .create();
- String[] labelIds = releaseLabelIds.split(",");
- DefaultLabelResource resource = null;
- for (int i = 0; i < labelIds.length; i++) {
- resource = new DefaultLabelResource(
- DeviceId.deviceId(deviceId),
- LabelResourceId.labelResourceId(Long
- .parseLong(labelIds[i])));
- map.put(DeviceId.deviceId(deviceId), resource);
- }
- lrs.releaseToDevicePool(map);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelResourceCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelResourceCommand.java
deleted file mode 100644
index fe263c68..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LabelResourceCommand.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.incubator.net.resource.label.LabelResourcePool;
-import org.onosproject.incubator.net.resource.label.LabelResourceService;
-
-@Command(scope = "onos", name = "label-pool",
- description = "Gets label resource pool information by a specific device id")
-public class LabelResourceCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "deviceId",
- description = "Device identity", required = true, multiValued = false)
- String deviceId = null;
- private static final String FMT = "deviceid=%s, beginLabel=%s,"
- + "endLabel=%s, totalNum=%s, usedNum=%s, currentUsedMaxLabelId=%s,"
- + "releaseLabelIds=%s";
-
- @Override
- protected void execute() {
- LabelResourceService lrs = get(LabelResourceService.class);
- LabelResourcePool pool = lrs.getDeviceLabelResourcePool(DeviceId
- .deviceId(deviceId));
- if (pool != null) {
- print(FMT, pool.deviceId().toString(), pool.beginLabel(),
- pool.endLabel(), pool.totalNum(), pool.usedNum(),
- pool.currentUsedMaxLabelId(), pool.releaseLabelId()
- .toString());
- } else {
- print(FMT, deviceId, null, null, null, null, null, null);
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LeaderCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LeaderCommand.java
deleted file mode 100644
index da4ab13a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LeaderCommand.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright 2014-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.Comparator;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.util.Tools;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cluster.Leadership;
-import org.onosproject.cluster.LeadershipService;
-import org.onosproject.cluster.NodeId;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-
-/**
- * Prints the leader for every topic.
- */
-@Command(scope = "onos", name = "leaders",
- description = "Finds the leader for particular topic.")
-public class LeaderCommand extends AbstractShellCommand {
-
- private static final String FMT = "%-30s | %-15s | %-6s | %-10s |";
- private static final String FMT_C = "%-30s | %-15s | %-19s |";
- private boolean allTopics;
- private Pattern pattern;
-
- @Argument(index = 0, name = "topic", description = "A leadership topic. Can be a regex",
- required = false, multiValued = false)
- String topicPattern = null;
-
- @Option(name = "-c", aliases = "--candidates",
- description = "List candidate Nodes for each topic's leadership race",
- required = false, multiValued = false)
- private boolean showCandidates = false;
-
- /**
- * Compares leaders, sorting by toString() output.
- */
- private Comparator<Leadership> leadershipComparator =
- (e1, e2) -> {
- if (e1.leader() == null && e2.leader() == null) {
- return 0;
- }
- if (e1.leader() == null) {
- return 1;
- }
- if (e2.leader() == null) {
- return -1;
- }
- return e1.leader().toString().compareTo(e2.leader().toString());
- };
-
- /**
- * Displays text representing the leaders.
- *
- * @param leaderBoard map of leaders
- */
- private void displayLeaders(Map<String, Leadership> leaderBoard) {
- print("------------------------------------------------------------------------");
- print(FMT, "Topic", "Leader", "Epoch", "Elected");
- print("------------------------------------------------------------------------");
-
- leaderBoard.values()
- .stream()
- .filter(l -> allTopics || pattern.matcher(l.topic()).matches())
- .sorted(leadershipComparator)
- .forEach(l -> print(FMT,
- l.topic(),
- l.leader(),
- l.epoch(),
- Tools.timeAgo(l.electedTime())));
- print("------------------------------------------------------------------------");
- }
-
- private void displayCandidates(Map<String, Leadership> leaderBoard,
- Map<String, List<NodeId>> candidates) {
- print("------------------------------------------------------------------------");
- print(FMT_C, "Topic", "Leader", "Candidates");
- print("------------------------------------------------------------------------");
- candidates
- .entrySet()
- .stream()
- .filter(es -> allTopics || pattern.matcher(es.getKey()).matches())
- .forEach(es -> {
- List<NodeId> list = es.getValue();
- if (list == null || list.isEmpty()) {
- return;
- }
- Leadership l = leaderBoard.get(es.getKey());
- print(FMT_C,
- es.getKey(),
- l == null ? "null" : l.leader(),
- // formatting hacks to get it into a table
- list.get(0).toString());
- list.subList(1, list.size()).forEach(n -> print(FMT_C, " ", " ", n));
- print(FMT_C, " ", " ", " ");
- });
- print("------------------------------------------------------------------------");
- }
-
- /**
- * Returns JSON node representing the leaders.
- *
- * @param leaderBoard map of leaders
- */
- private JsonNode json(Map<String, Leadership> leaderBoard) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- leaderBoard.values()
- .stream()
- .sorted(leadershipComparator)
- .forEach(l ->
- result.add(
- mapper.createObjectNode()
- .put("topic", l.topic())
- .put("leader", l.leader().toString())
- .put("candidates", l.candidates().toString())
- .put("epoch", l.epoch())
- .put("electedTime", Tools.timeAgo(l.electedTime()))));
-
- return result;
- }
-
- /**
- * Returns JSON node representing the leaders.
- *
- * @param leaderBoard map of leaders
- */
- private JsonNode json(Map<String, Leadership> leaderBoard,
- Map<String, List<NodeId>> candidateBoard) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- candidateBoard.entrySet()
- .stream()
- .forEach(es -> {
- Leadership l = leaderBoard.get(es.getKey());
- result.add(
- mapper.createObjectNode()
- .put("topic", es.getKey())
- .put("leader", l == null ? "none" : l.leader().toString())
- .put("candidates", es.getValue().toString()));
- });
- return result;
- }
-
- @Override
- protected void execute() {
- LeadershipService leaderService = get(LeadershipService.class);
- Map<String, Leadership> leaderBoard = leaderService.getLeaderBoard();
- if (topicPattern == null) {
- allTopics = true;
- } else {
- allTopics = false;
- pattern = Pattern.compile(topicPattern);
- }
-
- if (showCandidates) {
- Map<String, List<NodeId>> candidates = leaderService
- .getCandidates();
- if (outputJson()) {
- print("%s", json(leaderBoard, candidates));
- } else {
- displayCandidates(leaderBoard, candidates);
- }
- } else {
- if (outputJson()) {
- print("%s", json(leaderBoard));
- } else {
- displayLeaders(leaderBoard);
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkDstCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkDstCompleter.java
deleted file mode 100644
index 626777e3..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkDstCompleter.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.console.completer.ArgumentCompleter;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.link.LinkService;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Link destination end-point completer.
- */
-public class LinkDstCompleter extends AbstractCompleter {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- LinkService service = AbstractShellCommand.get(LinkService.class);
-
- // Link source the previous argument.
- ArgumentCompleter.ArgumentList list = getArgumentList();
- String srcArg = list.getArguments()[list.getCursorArgumentIndex() - 1];
-
- // Generate the device ID/port number identifiers
- SortedSet<String> strings = delegate.getStrings();
- try {
- ConnectPoint src = ConnectPoint.deviceConnectPoint(srcArg);
- service.getEgressLinks(src)
- .forEach(link -> strings.add(link.dst().elementId().toString() +
- "/" + link.dst().port()));
- } catch (NumberFormatException e) {
- System.err.println("Invalid connect-point");
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
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
deleted file mode 100644
index a1a76925..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkResourceTestCommand.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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 com.google.common.collect.Lists;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.intent.IntentId;
-import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
-import org.onosproject.net.resource.link.LinkResourceAllocations;
-import org.onosproject.net.resource.link.LinkResourceRequest;
-import org.onosproject.net.resource.link.LinkResourceService;
-import org.onosproject.net.topology.PathService;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Commands to test out LinkResourceManager directly.
- */
-@Command(scope = "onos", name = "resource-request",
- description = "request or remove resources")
-public class LinkResourceTestCommand extends AbstractShellCommand {
-
- // default is bandwidth.
- @Option(name = "-m", aliases = "--mpls", description = "MPLS resource",
- required = false, multiValued = false)
- private boolean isMpls = false;
-
- @Option(name = "-o", aliases = "--optical", description = "Optical resource",
- required = false, multiValued = false)
- private boolean isOptical = false;
-
- @Option(name = "-d", aliases = "--delete", description = "Delete resource by intent ID",
- required = false, multiValued = false)
- private boolean remove = false;
-
- @Argument(index = 0, name = "srcString", description = "Link source",
- required = true, multiValued = false)
- String srcString = null;
-
- @Argument(index = 1, name = "dstString", description = "Link destination",
- required = true, multiValued = false)
- String dstString = null;
-
- @Argument(index = 2, name = "id", description = "Identifier",
- required = true, multiValued = false)
- int id;
-
- private LinkResourceService resService;
- private PathService pathService;
-
- private static final int BANDWIDTH = 1_000_000;
-
- @Override
- protected void execute() {
- resService = get(LinkResourceService.class);
- pathService = get(PathService.class);
-
- DeviceId src = DeviceId.deviceId(getDeviceId(srcString));
- DeviceId dst = DeviceId.deviceId(getDeviceId(dstString));
- IntentId intId = IntentId.valueOf(id);
-
- Set<Path> paths = pathService.getPaths(src, dst);
-
- if (paths == null || paths.isEmpty()) {
- print("No path between %s and %s", srcString, dstString);
- return;
- }
-
- if (remove) {
- LinkResourceAllocations lra = resService.getAllocations(intId);
- resService.releaseResources(lra);
- return;
- }
-
- for (Path p : paths) {
- List<Link> links = p.links();
- LinkResourceRequest.Builder request = null;
- if (isMpls) {
- List<Link> nlinks = Lists.newArrayList();
- try {
- nlinks.addAll(links.subList(1, links.size() - 2));
- request = DefaultLinkResourceRequest.builder(intId, nlinks)
- .addMplsRequest();
- } catch (IndexOutOfBoundsException e) {
- log.warn("could not allocate MPLS path", e);
- continue;
- }
- } else if (isOptical) {
- request = DefaultLinkResourceRequest.builder(intId, links)
- .addLambdaRequest();
- } else {
- request = DefaultLinkResourceRequest.builder(intId, links)
- .addBandwidthRequest(BANDWIDTH);
- }
-
- if (request != null) {
- LinkResourceRequest lrr = request.build();
- LinkResourceAllocations lra = resService.requestResources(lrr);
- if (lra != null) {
- break;
- }
- print("Allocated:\n%s", lra);
- } else {
- log.info("nothing to request");
- }
- }
- }
-
- public String getDeviceId(String deviceString) {
- int slash = deviceString.indexOf('/');
- if (slash <= 0) {
- return "";
- }
- return deviceString.substring(0, slash);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkSrcCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkSrcCompleter.java
deleted file mode 100644
index f957f77f..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinkSrcCompleter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.console.completer.StringsCompleter;
-import org.onosproject.cli.AbstractCompleter;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.link.LinkService;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Link source end-point completer.
- */
-public class LinkSrcCompleter extends AbstractCompleter {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- // Fetch our service and feed it's offerings to the string completer
- LinkService service = AbstractShellCommand.get(LinkService.class);
-
- // Generate the device ID/port number identifiers
- SortedSet<String> strings = delegate.getStrings();
- service.getLinks()
- .forEach(link -> strings.add(link.src().elementId().toString() +
- "/" + link.src().port()));
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinksListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinksListCommand.java
deleted file mode 100644
index b9403a39..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/LinksListCommand.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.Link;
-import org.onosproject.net.link.LinkService;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import static org.onosproject.net.DeviceId.deviceId;
-
-/**
- * Lists all infrastructure links.
- */
-@Command(scope = "onos", name = "links",
- description = "Lists all infrastructure links")
-public class LinksListCommand extends AbstractShellCommand {
-
- private static final String FMT = "src=%s/%s, dst=%s/%s, type=%s, state=%s%s";
- private static final String COMPACT = "%s/%s-%s/%s";
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = false, multiValued = false)
- String uri = null;
-
- @Override
- protected void execute() {
- LinkService service = get(LinkService.class);
- Iterable<Link> links = uri != null ?
- service.getDeviceLinks(deviceId(uri)) : service.getLinks();
- if (outputJson()) {
- print("%s", json(this, links));
- } else {
- for (Link link : links) {
- print(linkString(link));
- }
- }
- }
-
- /**
- * Produces a JSON array containing the specified links.
- *
- * @param context context to use for looking up codecs
- * @param links collection of links
- * @return JSON array
- */
- public static JsonNode json(AbstractShellCommand context, Iterable<Link> links) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
-
- links.forEach(link -> result.add(context.jsonForEntity(link, Link.class)));
-
- return result;
- }
-
- /**
- * Produces a JSON object for the specified link.
- *
- * @param context context to use for looking up codecs
- * @param link link to encode
- * @return JSON object
- */
- public static ObjectNode json(AbstractShellCommand context, Link link) {
- return context.jsonForEntity(link, Link.class);
- }
-
- /**
- * Returns a formatted string representing the given link.
- *
- * @param link infrastructure link
- * @return formatted link string
- */
- public static String linkString(Link link) {
- return String.format(FMT, link.src().deviceId(), link.src().port(),
- link.dst().deviceId(), link.dst().port(),
- link.type(), link.state(),
- annotations(link.annotations()));
- }
-
- /**
- * Returns a compact string representing the given link.
- *
- * @param link infrastructure link
- * @return formatted link string
- */
- public static String compactLinkString(Link link) {
- return String.format(COMPACT, link.src().deviceId(), link.src().port(),
- link.dst().deviceId(), link.dst().port());
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/MapsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/MapsListCommand.java
deleted file mode 100644
index 27cc5254..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/MapsListCommand.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * 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.List;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.service.MapInfo;
-import org.onosproject.store.service.StorageAdminService;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Command to list the various maps in the system.
- */
-@Command(scope = "onos", name = "maps",
- description = "Lists information about consistent maps in the system")
-public class MapsListCommand extends AbstractShellCommand {
-
- // TODO: Add support to display different eventually
- // consistent maps as well.
-
- private static final String FMT = "name=%s size=%d";
-
- /**
- * Displays map info as text.
- *
- * @param mapInfo map descriptions
- */
- private void displayMaps(List<MapInfo> mapInfo) {
- for (MapInfo info : mapInfo) {
- print(FMT, info.name(), info.size());
- }
- }
-
- /**
- * Converts list of map info into a JSON object.
- *
- * @param mapInfo map descriptions
- */
- private JsonNode json(List<MapInfo> mapInfo) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode maps = mapper.createArrayNode();
-
- // Create a JSON node for each map
- mapInfo.stream()
- .forEach(info -> {
- ObjectNode map = mapper.createObjectNode();
- map.put("name", info.name())
- .put("size", info.size());
- maps.add(map);
- });
-
- return maps;
- }
-
- @Override
- protected void execute() {
- StorageAdminService storageAdminService = get(StorageAdminService.class);
- List<MapInfo> mapInfo = storageAdminService.getMapInfo();
- if (outputJson()) {
- print("%s", json(mapInfo));
- } else {
- displayMaps(mapInfo);
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Meters.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Meters.java
deleted file mode 100644
index 76f3813c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/Meters.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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 com.google.common.collect.Collections2;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.meter.Meter;
-import org.onosproject.net.meter.MeterService;
-
-import java.util.Collection;
-
-/**
- * Add a meter.
- */
-@Command(scope = "onos", name = "meters",
- description = "Shows meters")
-public class Meters extends AbstractShellCommand {
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = false, multiValued = false)
- String uri = null;
-
-
- @Override
- protected void execute() {
- MeterService service = get(MeterService.class);
-
- Collection<Meter> meters = service.getAllMeters();
- if (uri != null) {
- DeviceId deviceId = DeviceId.deviceId(uri);
- Collection<Meter> devMeters = Collections2.filter(meters,
- m -> m.deviceId().equals(deviceId));
- printMeters(devMeters);
- } else {
- printMeters(meters);
- }
- }
-
- private void printMeters(Collection<Meter> meters) {
- meters.forEach(m -> print(" %s", m));
- }
-}
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
deleted file mode 100644
index 6b7d9336..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketProcessorsListCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.PacketProcessorEntry;
-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, packets=%d, avgNanos=%d";
-
- @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(PacketProcessorEntry entry) {
- print(FMT, priorityFormat(entry.priority()),
- entry.processor().getClass().getName(),
- entry.invocations(), entry.averageNanos());
- }
-
- 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
deleted file mode 100644
index 9bdeadb3..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PacketRequestsListCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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/java/org/onosproject/cli/net/PartitionsListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PartitionsListCommand.java
deleted file mode 100644
index 8b3d1660..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PartitionsListCommand.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * 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.List;
-
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.service.PartitionInfo;
-import org.onosproject.store.service.StorageAdminService;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Command to list the database partitions in the system.
- */
-@Command(scope = "onos", name = "partitions",
- description = "Lists information about partitions in the system")
-public class PartitionsListCommand extends AbstractShellCommand {
-
- private static final String FMT = "%-20s %8s %25s %s";
-
- /**
- * Displays partition info as text.
- *
- * @param partitionInfo partition descriptions
- */
- private void displayPartitions(List<PartitionInfo> partitionInfo) {
- print("----------------------------------------------------------");
- print(FMT, "Name", "Term", "Members", "");
- print("----------------------------------------------------------");
-
- for (PartitionInfo info : partitionInfo) {
- boolean first = true;
- for (String member : info.members()) {
- if (first) {
- print(FMT, info.name(), info.term(), member,
- member.equals(info.leader()) ? "*" : "");
- first = false;
- } else {
- print(FMT, "", "", member,
- member.equals(info.leader()) ? "*" : "");
- }
- }
- if (!first) {
- print("----------------------------------------------------------");
- }
- }
- }
-
- /**
- * Converts partition info into a JSON object.
- *
- * @param partitionInfo partition descriptions
- */
- private JsonNode json(List<PartitionInfo> partitionInfo) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode partitions = mapper.createArrayNode();
-
- // Create a JSON node for each partition
- partitionInfo.stream()
- .forEach(info -> {
- ObjectNode partition = mapper.createObjectNode();
-
- // Add each member to the "members" array for this partition
- ArrayNode members = partition.putArray("members");
- info.members()
- .stream()
- .forEach(members::add);
-
- // Complete the partition attributes and add it to the array
- partition.put("name", info.name())
- .put("term", info.term())
- .put("leader", info.leader());
- partitions.add(partition);
-
- });
-
- return partitions;
- }
-
- @Override
- protected void execute() {
- StorageAdminService storageAdminService = get(StorageAdminService.class);
- List<PartitionInfo> partitionInfo = storageAdminService.getPartitionInfo();
-
- if (outputJson()) {
- print("%s", json(partitionInfo));
- } else {
- displayPartitions(partitionInfo);
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PathListCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PathListCommand.java
deleted file mode 100644
index 141ae266..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/PathListCommand.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2014 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 com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-
-import java.util.Set;
-
-import static org.onosproject.cli.net.LinksListCommand.compactLinkString;
-import static org.onosproject.net.DeviceId.deviceId;
-
-/**
- * Lists all shortest-paths paths between the specified source and
- * destination devices.
- */
-@Command(scope = "onos", name = "paths",
- description = "Lists all shortest-paths paths between the specified source and destination devices")
-public class PathListCommand extends TopologyCommand {
-
- private static final String SEP = "==>";
-
- @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;
-
- @Override
- protected void execute() {
- init();
- Set<Path> paths = service.getPaths(topology, deviceId(src), deviceId(dst));
- if (outputJson()) {
- print("%s", json(this, paths));
- } else {
- for (Path path : paths) {
- print(pathString(path));
- }
- }
- }
-
- /**
- * Produces a JSON array containing the specified paths.
- *
- * @param context context to use for looking up codecs
- * @param paths collection of paths
- * @return JSON array
- */
- public static JsonNode json(AbstractShellCommand context, Iterable<Path> paths) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- for (Path path : paths) {
- result.add(LinksListCommand.json(context, path)
- .put("cost", path.cost())
- .set("links", LinksListCommand.json(context, path.links())));
- }
- return result;
- }
-
- /**
- * Produces a formatted string representing the specified path.
- *
- * @param path network path
- * @return formatted path string
- */
- protected String pathString(Path path) {
- StringBuilder sb = new StringBuilder();
- for (Link link : path.links()) {
- sb.append(compactLinkString(link)).append(SEP);
- }
- sb.delete(sb.lastIndexOf(SEP), sb.length());
- sb.append("; cost=").append(path.cost());
- return sb.toString();
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/RandomIntentCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/RandomIntentCommand.java
deleted file mode 100644
index d917f904..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/RandomIntentCommand.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2014-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.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.Host;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.intent.HostToHostIntent;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-
-import com.google.common.collect.Lists;
-
-/**
- * Installs bulk point-to-point connectivity intents between random ingress/egress devices.
- */
-@Command(scope = "onos", name = "push-random-intents",
- description = "Installs random intents to test throughput")
-public class RandomIntentCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "count",
- description = "Number of intents to push",
- required = true, multiValued = false)
- String countString = null;
-
- private IntentService service;
- private HostService hostService;
- private int count;
-
- @Override
- protected void execute() {
- service = get(IntentService.class);
- hostService = get(HostService.class);
-
- count = Integer.parseInt(countString);
-
- if (count > 0) {
- Collection<Intent> intents = generateIntents();
- submitIntents(intents);
- } else {
- withdrawIntents();
- }
- }
-
- private Collection<Intent> generateIntents() {
- List<Host> hosts = Lists.newArrayList(hostService.getHosts());
- List<Intent> fullMesh = Lists.newArrayList();
- for (int i = 0; i < hosts.size(); i++) {
- for (int j = i + 1; j < hosts.size(); j++) {
- fullMesh.add(HostToHostIntent.builder()
- .appId(appId())
- .one(hosts.get(i).id())
- .two(hosts.get(j).id())
- .build());
-
- }
- }
- Collections.shuffle(fullMesh);
- return fullMesh.subList(0, Math.min(count, fullMesh.size()));
- }
-
- private void submitIntents(Collection<Intent> intents) {
- for (Intent intent : intents) {
- service.submit(intent);
- }
- print("Submitted %d host to host intents.", intents.size());
- }
-
- private void withdrawIntents() {
- for (Intent intent : service.getIntents()) {
- if (appId().equals(intent.appId())) {
- service.withdraw(intent);
- }
- }
- print("Withdrew all randomly generated host to host intents.");
- }
-
- @Override
- protected ApplicationId appId() {
- return get(CoreService.class).registerApplication("org.onosproject.cli-random");
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ResourceAllocationsCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ResourceAllocationsCommand.java
deleted file mode 100644
index 9a18bfce..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ResourceAllocationsCommand.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Link;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-/**
- * Lists allocations by link. Lists all allocations if link is unspecified.
- */
-@Command(scope = "onos", name = "resource-allocations",
- description = "Lists allocations by link. Lists all allocations if link is unspecified.")
-public class ResourceAllocationsCommand extends AbstractShellCommand {
-
- private static final String FMT = "src=%s/%s, dst=%s/%s, type=%s%s";
- private static final String COMPACT = "%s/%s-%s/%s";
-
- @Argument(index = 0, name = "srcString", description = "Link source",
- required = false, multiValued = false)
- String srcString = null;
- @Argument(index = 1, name = "dstString", description = "Link destination",
- required = false, multiValued = false)
- String dstString = null;
-
- @Override
- protected void execute() {
- LinkResourceService resourceService = get(LinkResourceService.class);
- LinkService linkService = get(LinkService.class);
-
- if (srcString == null || dstString == null) {
- print("----- Displaying all resource allocations -----");
- resourceService.getAllocations().forEach(alloc -> print("%s", alloc));
- return;
- }
-
- ConnectPoint src = ConnectPoint.deviceConnectPoint(srcString);
- ConnectPoint dst = ConnectPoint.deviceConnectPoint(dstString);
-
- Link link = linkService.getLink(src, dst);
- if (link != null) {
- resourceService.getAllocations(link).forEach(alloc -> print("%s", alloc));
- } else {
- print("No path found for endpoints: %s, %s", src, dst);
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ResourceAvailableCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ResourceAvailableCommand.java
deleted file mode 100644
index ab0d3958..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/ResourceAvailableCommand.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2014 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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.Link;
-import org.onosproject.net.link.LinkService;
-import org.onosproject.net.resource.link.LinkResourceService;
-import org.onosproject.net.resource.ResourceRequest;
-
-/**
- * Lists allocations by link.
- */
-@Command(scope = "onos", name = "resource-available",
- description = "Lists available resources by link")
-public class ResourceAvailableCommand extends AbstractShellCommand {
-
- private static final String FMT = "src=%s/%s, dst=%s/%s, type=%s%s";
- private static final String COMPACT = "%s/%s-%s/%s";
-
- @Argument(index = 0, name = "srcString", description = "Link source",
- required = false, multiValued = false)
- String srcString = null;
- @Argument(index = 1, name = "dstString", description = "Link destination",
- required = false, multiValued = false)
- String dstString = null;
-
- @Override
- protected void execute() {
- LinkResourceService resourceService = get(LinkResourceService.class);
- LinkService linkService = get(LinkService.class);
-
- Iterable<ResourceRequest> itr = null;
- try {
- ConnectPoint src = ConnectPoint.deviceConnectPoint(srcString);
-
- ConnectPoint dst = ConnectPoint.deviceConnectPoint(dstString);
-
- Link link = linkService.getLink(src, dst);
-
- itr = resourceService.getAvailableResources(link);
-
- int lambdaCount = 0;
- for (ResourceRequest req : itr) {
- switch (req.type()) {
- case LAMBDA:
- lambdaCount++;
- break;
- case BANDWIDTH:
- print("%s", req);
- break;
- default:
- break;
- }
- }
- if (lambdaCount > 0) {
- print("Number of available lambdas: %d", lambdaCount);
- }
-
- } catch (Exception e) {
- print("Invalid link %s", e.getMessage());
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/RoleCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/RoleCompleter.java
deleted file mode 100644
index 0b4fc97d..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/RoleCompleter.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2014 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.console.Completer;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.net.MastershipRole;
-
-import java.util.List;
-import java.util.SortedSet;
-
-/**
- * Device mastership role completer.
- */
-public class RoleCompleter implements Completer {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
- SortedSet<String> strings = delegate.getStrings();
- strings.add(MastershipRole.MASTER.toString().toLowerCase());
- strings.add(MastershipRole.STANDBY.toString().toLowerCase());
- strings.add(MastershipRole.NONE.toString().toLowerCase());
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TableStatisticsCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TableStatisticsCommand.java
deleted file mode 100644
index e0cd72fc..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TableStatisticsCommand.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * 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 static com.google.common.collect.Lists.newArrayList;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.cli.Comparators;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.flow.TableStatisticsEntry;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Lists port statistic of all ports in the system.
- */
-@Command(scope = "onos", name = "tablestats",
- description = "Lists statistics of all tables in the device")
-public class TableStatisticsCommand extends AbstractShellCommand {
-
- @Option(name = "-t", aliases = "--table", description = "Show human readable table format for statistics",
- required = false, multiValued = false)
- private boolean table = false;
-
- @Argument(index = 0, name = "uri", description = "Device ID",
- required = false, multiValued = false)
- String uri = null;
-
- private static final String FORMAT =
- " table=%s, active=%s, lookedup=%s, matched=%s";
-
- @Override
- protected void execute() {
- FlowRuleService flowService = get(FlowRuleService.class);
- DeviceService deviceService = get(DeviceService.class);
-
- SortedMap<Device, List<TableStatisticsEntry>> deviceTableStats =
- getSortedTableStats(deviceService, flowService);
-
- if (outputJson()) {
- print("%s", json(deviceTableStats.keySet(), deviceTableStats));
- } else {
- deviceTableStats.forEach((device, tableStats) -> printTableStats(device, tableStats));
- }
- }
-
- /**
- * Produces a JSON array of table statistics grouped by the each device.
- *
- * @param devices collection of devices
- * @param deviceTableStats collection of table statistics per each device
- * @return JSON array
- */
- private JsonNode json(Iterable<Device> devices,
- Map<Device, List<TableStatisticsEntry>> deviceTableStats) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode result = mapper.createArrayNode();
- for (Device device : devices) {
- result.add(json(mapper, device, deviceTableStats.get(device)));
- }
- return result;
- }
-
- // Produces JSON object with the table statistics of the given device.
- private ObjectNode json(ObjectMapper mapper,
- Device device, List<TableStatisticsEntry> tableStats) {
- ObjectNode result = mapper.createObjectNode();
- ArrayNode array = mapper.createArrayNode();
-
- tableStats.forEach(tableStat -> array.add(jsonForEntity(tableStat, TableStatisticsEntry.class)));
-
- result.put("device", device.id().toString())
- .put("tableCount", tableStats.size())
- .set("tables", array);
- return result;
- }
-
- /**
- * Prints flow table statistics.
- *
- * @param d the device
- * @param tableStats the set of flow table statistics for that device
- */
- protected void printTableStats(Device d,
- List<TableStatisticsEntry> tableStats) {
- boolean empty = tableStats == null || tableStats.isEmpty();
- print("deviceId=%s, tableCount=%d", d.id(), empty ? 0 : tableStats.size());
- if (!empty) {
- for (TableStatisticsEntry t : tableStats) {
- print(FORMAT, t.tableId(), t.activeFlowEntries(),
- t.packetsLookedup(), t.packetsMatched());
- }
- }
- }
-
- /**
- * Returns the list of table statistics sorted using the device ID URIs and table IDs.
- *
- * @param deviceService device service
- * @param flowService flow rule service
- * @return sorted table statistics list
- */
- protected SortedMap<Device, List<TableStatisticsEntry>> getSortedTableStats(DeviceService deviceService,
- FlowRuleService flowService) {
- SortedMap<Device, List<TableStatisticsEntry>> deviceTableStats = new TreeMap<>(Comparators.ELEMENT_COMPARATOR);
- List<TableStatisticsEntry> tableStatsList;
- Iterable<Device> devices = uri == null ? deviceService.getDevices() :
- Collections.singletonList(deviceService.getDevice(DeviceId.deviceId(uri)));
- for (Device d : devices) {
- tableStatsList = newArrayList(flowService.getFlowTableStatistics(d.id()));
- tableStatsList.sort((p1, p2) -> Integer.valueOf(p1.tableId()).compareTo(Integer.valueOf(p2.tableId())));
- deviceTableStats.put(d, tableStatsList);
- }
- return deviceTableStats;
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TopologyCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TopologyCommand.java
deleted file mode 100644
index e1ebd25a..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TopologyCommand.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2014-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.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.topology.Topology;
-import org.onosproject.net.topology.TopologyProvider;
-import org.onosproject.net.topology.TopologyService;
-
-/**
- * Lists summary of the current topology.
- */
-@Command(scope = "onos", name = "topology",
-description = "Lists summary of the current topology")
-public class TopologyCommand extends AbstractShellCommand {
-
- private static final String FMT = "created=%s, uptime=%s, devices=%d, links=%d, clusters=%d";
-
- @Option(name = "-r", aliases = "--recompute",
- description = "Trigger topology re-computation", required = false,
- multiValued = false)
- private boolean recompute = false;
-
- protected TopologyService service;
- protected Topology topology;
-
- /**
- * Initializes the context for all cluster commands.
- */
- protected void init() {
- service = get(TopologyService.class);
- topology = service.currentTopology();
- }
-
- @Override
- protected void execute() {
- init();
- long topologyUptime =
- Math.max(0, (System.currentTimeMillis() - topology.creationTime()));
- if (recompute) {
- get(TopologyProvider.class).triggerRecompute();
-
- } else if (outputJson()) {
- print("%s",
- jsonForEntity(topology, Topology.class));
- } else {
- print(FMT, formatCreationTime(topology.creationTime()),
- formatElapsedTime(topologyUptime),
- topology.deviceCount(), topology.linkCount(),
- topology.clusterCount());
- }
- }
-
- /**
- * Converts millis to a formatted elapsed time string.
- *
- * @param millis Duration in millis to convert to a string
- *
- * @return Formatted string: "D days, H hrs, M mins, S secs".
- */
- private static String formatElapsedTime(long millis) {
- if (millis < 0) {
- throw new IllegalArgumentException("Interval less than zero. "
- + "Possible unsynchronized timestamps");
- }
-
- final long days = TimeUnit.MILLISECONDS.toDays(millis);
- millis -= TimeUnit.DAYS.toMillis(days);
- final long hours = TimeUnit.MILLISECONDS.toHours(millis);
- millis -= TimeUnit.HOURS.toMillis(hours);
- final long minutes = TimeUnit.MILLISECONDS.toMinutes(millis);
- millis -= TimeUnit.MINUTES.toMillis(minutes);
- final long seconds = TimeUnit.MILLISECONDS.toSeconds(millis);
-
- final StringBuilder topologyUptimeString = new StringBuilder(64);
- topologyUptimeString.append(days);
- topologyUptimeString.append(" days, ");
- topologyUptimeString.append(hours);
- topologyUptimeString.append(" hrs, ");
- topologyUptimeString.append(minutes);
- topologyUptimeString.append(" mins, ");
- topologyUptimeString.append(seconds);
- topologyUptimeString.append(" secs");
-
- return (topologyUptimeString.toString());
- }
-
- /**
- * Converts millis to a formatted Date String.
- *
- * @param millis Duration in millis to convert to a string
- *
- * @return Formatted string: yyyy-MM-dd HH:mm:ss.
- */
- private static String formatCreationTime(long millis) {
- final DateFormat dateFormatter =
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeInMillis(millis);
- return (dateFormatter.format(calendar.getTime()));
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TransactionsCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TransactionsCommand.java
deleted file mode 100644
index 6013a389..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TransactionsCommand.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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.Collection;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.util.Tools;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.service.StorageAdminService;
-import org.onosproject.store.service.Transaction;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * CLI to work with database transactions in the system.
- */
-@Command(scope = "onos", name = "transactions",
- description = "Utility for viewing and redriving database transactions")
-public class TransactionsCommand extends AbstractShellCommand {
-
- @Option(name = "-r", aliases = "--redrive",
- description = "Redrive stuck transactions while removing those that are done",
- required = false, multiValued = false)
- private boolean redrive = false;
-
- private static final String FMT = "%-20s %-15s %-10s";
-
- /**
- * Displays transactions as text.
- *
- * @param transactions transactions
- */
- private void displayTransactions(Collection<Transaction> transactions) {
- print("---------------------------------------------");
- print(FMT, "Id", "State", "Updated");
- print("---------------------------------------------");
- transactions.forEach(txn -> print(FMT, txn.id(), txn.state(), Tools.timeAgo(txn.lastUpdated())));
- if (transactions.size() > 0) {
- print("---------------------------------------------");
- }
- }
-
- /**
- * Converts collection of transactions into a JSON object.
- *
- * @param transactions transactions
- */
- private JsonNode json(Collection<Transaction> transactions) {
- ObjectMapper mapper = new ObjectMapper();
- ArrayNode txns = mapper.createArrayNode();
-
- // Create a JSON node for each transaction
- transactions.stream().forEach(txn -> {
- ObjectNode txnNode = mapper.createObjectNode();
- txnNode.put("id", txn.id())
- .put("state", txn.state().toString())
- .put("lastUpdated", txn.lastUpdated());
- txns.add(txnNode);
- });
-
- return txns;
- }
-
- @Override
- protected void execute() {
- StorageAdminService storageAdminService = get(StorageAdminService.class);
-
- if (redrive) {
- storageAdminService.redriveTransactions();
- return;
- }
-
- Collection<Transaction> transactions = storageAdminService.getTransactions();
- if (outputJson()) {
- print("%s", json(transactions));
- } else {
- displayTransactions(transactions);
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelBorrowCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelBorrowCommand.java
deleted file mode 100644
index 3db4e865..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelBorrowCommand.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * Copyright 2014-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.Collection;
-import java.util.HashSet;
-import java.util.Optional;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.OpticalLogicId;
-import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Borrows tunnels. It's used by consumers.
- */
-@Command(scope = "onos", name = "tunnel-borrow", description = "Borrows tunnels. It's used by consumers.")
-public class TunnelBorrowCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "consumerId",
- description = "consumer id means application id.", required = true, multiValued = false)
- String consumerId = null;
-
- @Option(name = "-s", aliases = "--src", description = "Source tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise src means IP address.", required = false, multiValued = false)
- String src = null;
-
- @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise dst means IP address.", required = false, multiValued = false)
- String dst = null;
-
- @Option(name = "-t", aliases = "--type", description = "The type of tunnels,"
- + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false)
- String type = null;
-
- @Option(name = "-i", aliases = "--tunnelId",
- description = "the tunnel identity.", required = false, multiValued = false)
- String tunnelId = null;
-
- @Option(name = "-n", aliases = "--tunnelName",
- description = "The name of tunnels", required = false, multiValued = false)
- String tunnelName = null;
- private static final String FMT = "src=%s, dst=%s,"
- + "type=%s, state=%s, producerName=%s, tunnelName=%s,"
- + "groupId=%s";
-
- @Override
- protected void execute() {
- Collection<Tunnel> tunnelSet = null;
- Tunnel.Type trueType = null;
- TunnelService service = get(TunnelService.class);
- ApplicationId appId = new DefaultApplicationId(1, consumerId);
- ProviderId producerName = new ProviderId("default",
- "org.onosproject.provider.tunnel.default");
- if (!isNull(src) && !isNull(dst) && !isNull(type)) {
- TunnelEndPoint srcPoint = null;
- TunnelEndPoint dstPoint = null;
- if ("MPLS".equals(type)) {
- trueType = Tunnel.Type.MPLS;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("VXLAN".equals(type)) {
- trueType = Tunnel.Type.VXLAN;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("GRE".equals(type)) {
- trueType = Tunnel.Type.GRE;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("VLAN".equals(type)) {
- trueType = Tunnel.Type.VLAN;
- String[] srcArray = src.split("-");
- String[] dstArray = dst.split("-");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- null,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- null,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("ODUK".equals(type)) {
- trueType = Tunnel.Type.ODUK;
- String[] srcArray = src.split("-");
- String[] dstArray = dst.split("-");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("OCH".equals(type)) {
- trueType = Tunnel.Type.OCH;
- String[] srcArray = src.split("-");
- String[] dstArray = dst.split("-");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.TIMESLOT,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.TIMESLOT,
- OpticalLogicId
- .logicId(0),
- true);
- } else {
- print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
- return;
- }
- tunnelSet = service.borrowTunnel(appId, srcPoint, dstPoint, trueType);
- }
- if (!isNull(tunnelId)) {
- TunnelId id = TunnelId.valueOf(tunnelId);
- Tunnel tunnel = service.borrowTunnel(appId, id);
- tunnelSet = new HashSet<Tunnel>();
- tunnelSet.add(tunnel);
- }
- if (!isNull(tunnelName)) {
- TunnelName name = TunnelName.tunnelName(tunnelName);
- tunnelSet = service.borrowTunnel(appId, name);
- }
- for (Tunnel tunnel : tunnelSet) {
- print(FMT, tunnel.src(), tunnel.dst(), tunnel.type(),
- tunnel.state(), tunnel.providerId(), tunnel.tunnelName(),
- tunnel.groupId());
- }
- }
-
- private boolean isNull(String s) {
- return s == null || "".equals(s);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelCreateCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelCreateCommand.java
deleted file mode 100644
index 955df887..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelCreateCommand.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * 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.Optional;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.DefaultGroupId;
-import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.OpticalLogicId;
-import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelDescription;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelProvider;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.SparseAnnotations;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Supports for creating a tunnel by using IP address and optical as tunnel end
- * point.
- */
-@Command(scope = "onos", name = "tunnel-create",
-description = "Supports for creating a tunnel by using IP address and optical as tunnel end point now.")
-public class TunnelCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "src", description = "Source tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If creates a ODUK or OCH or VLAN type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise src means IP address.", required = true, multiValued = false)
- String src = null;
-
- @Argument(index = 1, name = "dst", description = "Destination tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If creates a ODUK or OCH or VLAN type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise dst means IP address.", required = true, multiValued = false)
- String dst = null;
- @Argument(index = 2, name = "type", description = "The type of tunnels,"
- + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = true, multiValued = false)
- String type = null;
- @Option(name = "-g", aliases = "--groupId",
- description = "Group flow table id which a tunnel match up", required = false, multiValued = false)
- String groupId = "0";
-
- @Option(name = "-n", aliases = "--tunnelName",
- description = "The name of tunnels", required = false, multiValued = false)
- String tunnelName = "onos";
-
- @Option(name = "-b", aliases = "--bandwidth",
- description = "The bandwidth attribute of tunnel", required = false, multiValued = false)
- String bandwidth = "1024";
-
- private static final String FMT = "The tunnel identity is %s";
-
- @Override
- protected void execute() {
- TunnelProvider service = get(TunnelProvider.class);
- ProviderId producerName = new ProviderId("default",
- "org.onosproject.provider.tunnel.default");
- TunnelEndPoint srcPoint = null;
- TunnelEndPoint dstPoint = null;
- Tunnel.Type trueType = null;
- if ("MPLS".equals(type)) {
- trueType = Tunnel.Type.MPLS;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
- } else if ("VLAN".equals(type)) {
- trueType = Tunnel.Type.VLAN;
- String[] srcArray = src.split("/");
- String[] dstArray = dst.split("/");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- null,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- null,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("VXLAN".equals(type)) {
- trueType = Tunnel.Type.VXLAN;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
- } else if ("GRE".equals(type)) {
- trueType = Tunnel.Type.GRE;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dst));
- } else if ("ODUK".equals(type)) {
- trueType = Tunnel.Type.ODUK;
- String[] srcArray = src.split("/");
- String[] dstArray = dst.split("/");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("OCH".equals(type)) {
- trueType = Tunnel.Type.OCH;
- String[] srcArray = src.split("/");
- String[] dstArray = dst.split("/");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.TIMESLOT,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.TIMESLOT,
- OpticalLogicId
- .logicId(0),
- true);
- } else {
- print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
- return;
- }
-
- SparseAnnotations annotations = DefaultAnnotations
- .builder()
- .set("bandwidth", bandwidth == null || "".equals(bandwidth) ? "0" : bandwidth)
- .build();
- TunnelDescription tunnel = new DefaultTunnelDescription(
- null,
- srcPoint,
- dstPoint,
- trueType,
- new DefaultGroupId(Integer.parseInt(groupId)),
- producerName,
- TunnelName
- .tunnelName(tunnelName),
- null,
- annotations);
- TunnelId tunnelId = service.tunnelAdded(tunnel);
- if (tunnelId == null) {
- error("Create tunnel failed.");
- return;
- }
- print(FMT, tunnelId.id());
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelQueryCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelQueryCommand.java
deleted file mode 100644
index c60337c5..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelQueryCommand.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright 2014-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.Collection;
-import java.util.HashSet;
-import java.util.Optional;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.OpticalLogicId;
-import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Supports for querying tunnels. It's used by consumers.
- */
-@Command(scope = "onos", name = "tunnels", description = "Supports for querying tunnels."
- + " It's used by consumers.")
-public class TunnelQueryCommand extends AbstractShellCommand {
- @Option(name = "-s", aliases = "--src", description = "Source tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise src means IP address.", required = false, multiValued = false)
- String src = null;
- @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise dst means IP address.", required = false, multiValued = false)
- String dst = null;
-
- @Option(name = "-t", aliases = "--type", description = "The type of tunnels,"
- + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false)
- String type = null;
-
- @Option(name = "-i", aliases = "--tunnelId",
- description = "the tunnel identity.", required = false, multiValued = false)
- String tunnelId = null;
-
- private static final String FMT = "tunnelId=%s, src=%s, dst=%s,"
- + "type=%s, state=%s, producerName=%s, tunnelName=%s,"
- + "groupId=%s, path=%s%s";
-
- @Override
- protected void execute() {
- Tunnel.Type trueType = null;
- TunnelService service = get(TunnelService.class);
- ProviderId producerName = new ProviderId("default",
- "org.onosproject.provider.tunnel.default");
- Collection<Tunnel> tunnelSet = null;
- if (isNull(src) && isNull(dst) && isNull(type) && isNull(tunnelId)) {
- tunnelSet = service.queryAllTunnels();
- }
-
- if (!isNull(src) && !isNull(dst) && !isNull(type)) {
- TunnelEndPoint srcPoint = null;
- TunnelEndPoint dstPoint = null;
- if ("MPLS".equals(type) || "VXLAN".equals(type)
- || "GRE".equals(type)) {
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("VLAN".equals(type)) {
- String[] srcArray = src.split("/");
- String[] dstArray = dst.split("/");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- null,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- null,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("ODUK".equals(type)) {
- String[] srcArray = src.split("/");
- String[] dstArray = dst.split("/");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("OCH".equals(type)) {
- String[] srcArray = src.split("/");
- String[] dstArray = dst.split("/");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.TIMESLOT,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.TIMESLOT,
- OpticalLogicId
- .logicId(0),
- true);
- } else {
- print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
- return;
- }
- tunnelSet = service.queryTunnel(srcPoint, dstPoint);
- }
- if (!isNull(type)) {
- if ("MPLS".equals(type)) {
- trueType = Tunnel.Type.MPLS;
- } else if ("VLAN".equals(type)) {
- trueType = Tunnel.Type.VLAN;
- } else if ("VXLAN".equals(type)) {
- trueType = Tunnel.Type.VXLAN;
- } else if ("GRE".equals(type)) {
- trueType = Tunnel.Type.GRE;
- } else if ("ODUK".equals(type)) {
- trueType = Tunnel.Type.ODUK;
- } else if ("OCH".equals(type)) {
- trueType = Tunnel.Type.OCH;
- } else {
- print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
- return;
- }
- tunnelSet = service.queryTunnel(trueType);
- }
- if (!isNull(tunnelId)) {
- TunnelId id = TunnelId.valueOf(tunnelId);
- Tunnel tunnel = service.queryTunnel(id);
- tunnelSet = new HashSet<Tunnel>();
- tunnelSet.add(tunnel);
- }
- if (tunnelSet != null) {
- for (Tunnel tunnel : tunnelSet) {
- print(FMT, tunnel.tunnelId().id(), tunnel.src().toString(), tunnel.dst().toString(),
- tunnel.type(), tunnel.state(), tunnel.providerId(),
- tunnel.tunnelName(), tunnel.groupId(),
- showPath(tunnel.path()),
- annotations(tunnel.annotations()));
- }
- }
- }
-
- private String showPath(Path path) {
- if (path == null) {
- return "null";
- }
- StringBuilder builder = new StringBuilder("(");
- for (Link link : path.links()) {
- builder.append("(DeviceId:" + link.src().deviceId() + " Port:"
- + link.src().port().toString());
- builder.append(" DeviceId:" + link.dst().deviceId() + " Port:"
- + link.dst().port().toString() + ")");
- }
- builder.append(annotations(path.annotations()) + ")");
- return builder.toString();
- }
-
- private boolean isNull(String s) {
- return s == null || "".equals(s);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelQuerySubscriptionCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelQuerySubscriptionCommand.java
deleted file mode 100644
index 92db9268..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelQuerySubscriptionCommand.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2014-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.Collection;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.incubator.net.tunnel.TunnelSubscription;
-
-/**
- * Query all tunnel subscriptions of consumer by consumer id.
- * It's used by consumers.
- */
-@Command(scope = "onos", name = "tunnel-subscriptions",
- description = "Query all request orders of consumer by consumer id. It's used by consumers.")
-public class TunnelQuerySubscriptionCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "consumerId",
- description = "consumer id means provider id",
- required = true, multiValued = false)
- String consumerId = null;
- private static final String FMT = "appId=%s, src=%s, dst=%s,"
- + "type=%s, tunnelId=%s";
-
- @Override
- protected void execute() {
- TunnelService service = get(TunnelService.class);
- ApplicationId applicationId = new DefaultApplicationId(1, consumerId);
- Collection<TunnelSubscription> tunnelSet = service.queryTunnelSubscription(applicationId);
- for (TunnelSubscription order : tunnelSet) {
- print(FMT, order.consumerId(), order.src(), order.dst(),
- order.type(), order.tunnelId());
- }
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelRemoveCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelRemoveCommand.java
deleted file mode 100644
index 7d42c2d0..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelRemoveCommand.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright 2014-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.Collection;
-import java.util.Optional;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.OpticalLogicId;
-import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelDescription;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelProvider;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Supports for removing tunnels. It's used by producers.
- */
-@Command(scope = "onos", name = "tunnel-remove", description = "Supports for removing tunnels. It's used by producers.")
-public class TunnelRemoveCommand extends AbstractShellCommand {
- @Option(name = "-s", aliases = "--src", description = "Source tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise src means IP address.", required = false, multiValued = false)
- String src = null;
- @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise dst means IP address.", required = false, multiValued = false)
- String dst = null;
-
- @Option(name = "-t", aliases = "--type", description = "The type of tunnels,"
- + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false)
- String type = null;
-
- @Option(name = "-i", aliases = "--tunnelId",
- description = "the tunnel identity.", required = false, multiValued = false)
- String tunnelId = null;
-
- @Override
- protected void execute() {
- TunnelDescription tunnel = null;
- TunnelProvider service = get(TunnelProvider.class);
- ProviderId producerName = new ProviderId("default",
- "org.onosproject.provider.tunnel.default");
- if (!isNull(src) && !isNull(dst) && !isNull(type)) {
- TunnelEndPoint srcPoint = null;
- TunnelEndPoint dstPoint = null;
- Tunnel.Type trueType = null;
- if ("MPLS".equals(type)) {
- trueType = Tunnel.Type.MPLS;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("VLAN".equals(type)) {
- trueType = Tunnel.Type.VLAN;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("VXLAN".equals(type)) {
- trueType = Tunnel.Type.VXLAN;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("GRE".equals(type)) {
- trueType = Tunnel.Type.GRE;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("ODUK".equals(type)) {
- trueType = Tunnel.Type.ODUK;
- String[] srcArray = src.split("/");
- String[] dstArray = dst.split("/");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("OCH".equals(type)) {
- trueType = Tunnel.Type.OCH;
- String[] srcArray = src.split("/");
- String[] dstArray = dst.split("/");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- } else {
- print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
- return;
- }
-
- tunnel = new DefaultTunnelDescription(null, srcPoint, dstPoint,
- trueType, null, producerName,
- null, null);
- service.tunnelRemoved(tunnel);
- return;
- }
- if (!isNull(tunnelId)) {
- TunnelId id = TunnelId.valueOf(tunnelId);
- tunnel = new DefaultTunnelDescription(id, null, null, null, null,
- producerName, null, null);
- service.tunnelRemoved(tunnel);
- return;
- }
-
- if (!isNull(type)) {
- Tunnel.Type trueType = null;
- Collection<Tunnel> tunnelSet = null;
- TunnelService tunnelService = get(TunnelService.class);
- if ("MPLS".equals(type)) {
- trueType = Tunnel.Type.MPLS;
- } else if ("VLAN".equals(type)) {
- trueType = Tunnel.Type.VLAN;
- } else if ("VXLAN".equals(type)) {
- trueType = Tunnel.Type.VXLAN;
- } else if ("GRE".equals(type)) {
- trueType = Tunnel.Type.GRE;
- } else if ("ODUK".equals(type)) {
- trueType = Tunnel.Type.ODUK;
- } else if ("OCH".equals(type)) {
- trueType = Tunnel.Type.OCH;
- } else {
- print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
- return;
- }
- tunnelSet = tunnelService.queryTunnel(trueType);
- if (tunnelSet != null) {
- for (Tunnel tunnelTemp : tunnelSet) {
- tunnel = new DefaultTunnelDescription(tunnelTemp.tunnelId(), null, null, null, null,
- producerName, null, null);
- service.tunnelRemoved(tunnel);
- }
- }
- }
- }
-
- private boolean isNull(String s) {
- return s == null || "".equals(s);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelReturnCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelReturnCommand.java
deleted file mode 100644
index 2b7d7bbd..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelReturnCommand.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright 2014-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.Optional;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.DefaultApplicationId;
-import org.onosproject.incubator.net.tunnel.DefaultOpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.OpticalLogicId;
-import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelName;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.provider.ProviderId;
-
-/**
- * Returns tunnels. It's used by consumers.
- */
-@Command(scope = "onos", name = "tunnel-return",
-description = "Returns tunnels. It's used by consumers.")
-public class TunnelReturnCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "consumerId",
- description = "consumer id means application id.", required = true, multiValued = false)
- String consumerId = null;
-
- @Option(name = "-s", aliases = "--src", description = "Source tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise src means IP address.", required = false, multiValued = false)
- String src = null;
-
- @Option(name = "-d", aliases = "--dst", description = "Destination tunnel point."
- + " Only supports for IpTunnelEndPoint and OpticalTunnelEndPoint as end point now."
- + " If deletess a ODUK or OCH type tunnel, the formatter of this argument is DeviceId-PortNumber."
- + " Otherwise dst means IP address.", required = false, multiValued = false)
- String dst = null;
-
- @Option(name = "-t", aliases = "--type", description = "The type of tunnels,"
- + " It includes MPLS, VLAN, VXLAN, GRE, ODUK, OCH", required = false, multiValued = false)
- String type = null;
-
- @Option(name = "-i", aliases = "--tunnelId",
- description = "the tunnel identity.", required = false, multiValued = false)
- String tunnelId = null;
-
- @Option(name = "-n", aliases = "--tunnelName",
- description = "The name of tunnels", required = false, multiValued = false)
- String tunnelName = null;
-
- @Override
- protected void execute() {
- Tunnel.Type trueType = null;
- TunnelService service = get(TunnelService.class);
- ApplicationId appId = new DefaultApplicationId(1, consumerId);
- ProviderId producerName = new ProviderId("default",
- "org.onosproject.provider.tunnel.default");
- if (!isNull(src) && !isNull(dst) && !isNull(type)) {
- TunnelEndPoint srcPoint = null;
- TunnelEndPoint dstPoint = null;
- if ("MPLS".equals(type)) {
- trueType = Tunnel.Type.MPLS;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("VXLAN".equals(type)) {
- trueType = Tunnel.Type.VXLAN;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("GRE".equals(type)) {
- trueType = Tunnel.Type.GRE;
- srcPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(src));
- dstPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress
- .valueOf(dst));
- } else if ("VLAN".equals(type)) {
- trueType = Tunnel.Type.VLAN;
- String[] srcArray = src.split("-");
- String[] dstArray = dst.split("-");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- null,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- null,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("ODUK".equals(type)) {
- trueType = Tunnel.Type.ODUK;
- String[] srcArray = src.split("-");
- String[] dstArray = dst.split("-");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.LAMBDA,
- OpticalLogicId
- .logicId(0),
- true);
- } else if ("OCH".equals(type)) {
- trueType = Tunnel.Type.OCH;
- String[] srcArray = src.split("-");
- String[] dstArray = dst.split("-");
- srcPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(srcArray[0])),
- Optional.of(PortNumber
- .portNumber(srcArray[1])),
- null,
- OpticalTunnelEndPoint.Type.TIMESLOT,
- OpticalLogicId
- .logicId(0),
- true);
- dstPoint = new DefaultOpticalTunnelEndPoint(
- producerName,
- Optional.of(DeviceId
- .deviceId(dstArray[0])),
- Optional.of(PortNumber
- .portNumber(dstArray[1])),
- null,
- OpticalTunnelEndPoint.Type.TIMESLOT,
- OpticalLogicId
- .logicId(0),
- true);
- } else {
- print("Illegal tunnel type. Please input MPLS, VLAN, VXLAN, GRE, ODUK or OCH.");
- return;
- }
- service.returnTunnel(appId, srcPoint, dstPoint, trueType);
- }
- if (!isNull(tunnelId)) {
- TunnelId id = TunnelId.valueOf(tunnelId);
- service.returnTunnel(appId, id);
- }
- if (!isNull(tunnelName)) {
- TunnelName name = TunnelName.tunnelName(tunnelName);
- service.returnTunnel(appId, name);
- }
- }
- private boolean isNull(String s) {
- return s == null || "".equals(s);
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelUpdateCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelUpdateCommand.java
deleted file mode 100644
index d7065571..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/TunnelUpdateCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.incubator.net.tunnel.DefaultTunnelDescription;
-import org.onosproject.incubator.net.tunnel.TunnelDescription;
-import org.onosproject.incubator.net.tunnel.TunnelId;
-import org.onosproject.incubator.net.tunnel.TunnelProvider;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.SparseAnnotations;
-
-/**
- * Supports for updating a tunnel by tunnel identity.
- * It's used by producers.
- */
-@Command(scope = "onos", name = "tunnel-update",
-description = "Supports for updating a tunnel by tunnel identity."
- + " It's used by producers.")
-public class TunnelUpdateCommand extends AbstractShellCommand {
- @Argument(index = 0, name = "tunnelId", description = "the tunnel identity.",
- required = true, multiValued = false)
- String tunnelId = null;
-
- @Option(name = "-b", aliases = "--bandwidth",
- description = "The bandwidth attribute of tunnel", required = false, multiValued = false)
- String bandwidth = null;
-
- @Override
- protected void execute() {
- TunnelProvider service = get(TunnelProvider.class);
- TunnelId id = TunnelId.valueOf(tunnelId);
- SparseAnnotations annotations = DefaultAnnotations
- .builder()
- .set("bandwidth", bandwidth)
- .build();
- TunnelDescription tunnel = new DefaultTunnelDescription(id, null,
- null,
- null, null,
- null,
- null, null, annotations);
- service.tunnelUpdated(tunnel);
- }
-
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java
deleted file mode 100644
index c842acff..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/WipeOutCommand.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2014-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;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.net.Device;
-import org.onosproject.net.Host;
-import org.onosproject.net.Link;
-import org.onosproject.net.device.DeviceAdminService;
-import org.onosproject.net.host.HostAdminService;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.intent.IntentService;
-import org.onosproject.net.intent.IntentState;
-import org.onosproject.net.link.LinkAdminService;
-
-/**
- * Wipes-out the entire network information base, i.e. devices, links, hosts, intents.
- */
-@Command(scope = "onos", name = "wipe-out",
- description = "Wipes-out the entire network information base, i.e. devices, links, hosts")
-public class WipeOutCommand extends ClustersListCommand {
-
- private static final String PLEASE = "please";
-
- @Argument(index = 0, name = "please", description = "Confirmation phrase",
- required = false, multiValued = false)
- String please = null;
-
- @Override
- protected void execute() {
- if (please == null || !please.equals(PLEASE)) {
- print("I'm afraid I can't do that!\nSay: %s", PLEASE);
- return;
- }
-
- wipeOutIntents();
- wipeOutHosts();
- wipeOutDevices();
- wipeOutLinks();
- }
-
- private void wipeOutIntents() {
- print("Wiping intents");
- IntentService intentService = get(IntentService.class);
- for (Intent intent : intentService.getIntents()) {
- if (intentService.getIntentState(intent.key()) != IntentState.WITHDRAWN) {
- intentService.withdraw(intent);
- }
- intentService.purge(intent);
- }
- }
-
- private void wipeOutHosts() {
- print("Wiping hosts");
- HostAdminService hostAdminService = get(HostAdminService.class);
- while (hostAdminService.getHostCount() > 0) {
- try {
- for (Host host : hostAdminService.getHosts()) {
- hostAdminService.removeHost(host.id());
- }
- } catch (Exception e) {
- log.warn("Unable to wipe-out hosts", e);
- }
- }
- }
-
- private void wipeOutDevices() {
- print("Wiping devices");
- DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
- while (deviceAdminService.getDeviceCount() > 0) {
- try {
- for (Device device : deviceAdminService.getDevices()) {
- deviceAdminService.removeDevice(device.id());
- }
- } catch (Exception e) {
- log.warn("Unable to wipe-out devices", e);
- }
- }
- }
-
- private void wipeOutLinks() {
- print("Wiping links");
- LinkAdminService linkAdminService = get(LinkAdminService.class);
- while (linkAdminService.getLinkCount() > 0) {
- try {
- for (Link link : linkAdminService.getLinks()) {
- linkAdminService.removeLinks(link.src());
- linkAdminService.removeLinks(link.dst());
- }
- } catch (Exception e) {
- log.warn("Unable to wipe-out links", e);
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/package-info.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/package-info.java
deleted file mode 100644
index fb4ba016..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/net/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-/**
- * Administrative console command-line extensions for interacting with the
- * network model &amp; services.
- */
-package org.onosproject.cli.net;
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/package-info.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/package-info.java
deleted file mode 100644
index 4d9d3690..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-/**
- * Administrative console command-line extensions.
- */
-package org.onosproject.cli;
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/ReviewApplicationNameCompleter.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/ReviewApplicationNameCompleter.java
deleted file mode 100644
index 73744f3c..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/ReviewApplicationNameCompleter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.security;
-
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.onosproject.app.ApplicationService;
-import org.onosproject.app.ApplicationState;
-import org.onosproject.cli.AbstractCompleter;
-import org.onosproject.core.Application;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.SortedSet;
-
-import static org.onosproject.app.ApplicationState.INSTALLED;
-import static org.onosproject.cli.AbstractShellCommand.get;
-
-/**
- * Application name completer for security review command.
- */
-public class ReviewApplicationNameCompleter extends AbstractCompleter {
- @Override
- public int complete(String buffer, int cursor, List<String> candidates) {
- // Delegate string completer
- StringsCompleter delegate = new StringsCompleter();
-
- ApplicationService service = get(ApplicationService.class);
- Iterator<Application> it = service.getApplications().iterator();
- SortedSet<String> strings = delegate.getStrings();
- while (it.hasNext()) {
- Application app = it.next();
- ApplicationState state = service.getState(app.id());
-// if (previousApps.contains(app.id().name())) {
-// continue;
-// }
- if (state == INSTALLED) {
- strings.add(app.id().name());
- }
- }
-
- // Now let the completer do the work for figuring out what to offer.
- return delegate.complete(buffer, cursor, candidates);
- }
-} \ No newline at end of file
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/ReviewCommand.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/ReviewCommand.java
deleted file mode 100644
index 9d17eb23..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/ReviewCommand.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * 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.security;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.app.ApplicationAdminService;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.core.Application;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.security.SecurityAdminService;
-import org.onosproject.security.SecurityUtil;
-
-import java.security.Permission;
-import java.util.List;
-import java.util.Map;
-
-
-/**
- * Application security policy review commands.
- */
-@Command(scope = "onos", name = "review",
- description = "Application security policy review interface")
-public class ReviewCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "name", description = "Application name",
- required = true, multiValued = false)
- String name = null;
-
- @Argument(index = 1, name = "accept", description = "Option to accept policy",
- required = false, multiValued = false)
- String accept = null;
-
- @Override
- protected void execute() {
- ApplicationAdminService applicationAdminService = get(ApplicationAdminService.class);
- ApplicationId appId = applicationAdminService.getId(name);
- if (appId == null) {
- print("No such application: %s", name);
- return;
- }
- Application app = applicationAdminService.getApplication(appId);
- SecurityAdminService smService = SecurityUtil.getSecurityService();
- if (smService == null) {
- print("Security Mode is disabled");
- return;
- }
- if (accept == null) {
- smService.review(appId);
- printPolicy(smService, app);
- } else if (accept.trim().equals("accept")) {
- smService.acceptPolicy(appId);
- printPolicy(smService, app);
- } else {
- print("Unknown command");
- }
- }
-
- private void printPolicy(SecurityAdminService smService, Application app) {
- print("\n*******************************");
- print(" SM-ONOS APP REVIEW ");
- print("*******************************");
-
- print("Application name: %s ", app.id().name());
- print("Application role: " + app.role());
- print("\nDeveloper specified permissions: ");
- printMap(smService.getPrintableSpecifiedPermissions(app.id()));
- print("\nPermissions granted: ");
- printMap(smService.getPrintableGrantedPermissions(app.id()));
- print("\nAdditional permissions requested on runtime (POLICY VIOLATIONS): ");
- printMap(smService.getPrintableRequestedPermissions(app.id()));
- print("");
-
- }
- private void printMap(Map<Integer, List<Permission>> assortedMap) {
- for (Integer type : assortedMap.keySet()) {
- switch (type) {
- case 0:
- for (Permission perm: assortedMap.get(0)) {
- print("\t[APP PERMISSION] " + perm.getName());
- }
- break;
- case 1:
- for (Permission perm: assortedMap.get(1)) {
- print("\t[NB-ADMIN SERVICE] " + perm.getName() + "(" + perm.getActions() + ")");
- }
- break;
- case 2:
- for (Permission perm: assortedMap.get(2)) {
- print("\t[NB SERVICE] " + perm.getName() + "(" + perm.getActions() + ")");
- }
- break;
- case 3:
- for (Permission perm: assortedMap.get(3)) {
- print("\t[Other SERVICE] " + perm.getName() + "(" + perm.getActions() + ")");
- }
- break;
- case 4:
- for (Permission perm: assortedMap.get(4)) {
- print("\t[Other] " + perm.getClass().getSimpleName() +
- " " + perm.getName() + " (" + perm.getActions() + ")");
- }
- default:
- break;
- }
- }
- }
-}
diff --git a/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/package-info.java b/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/package-info.java
deleted file mode 100644
index e634edab..00000000
--- a/framework/src/onos/cli/src/main/java/org/onosproject/cli/security/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * CLI commands for managing security permissions.
- */
-package org.onosproject.cli.security; \ No newline at end of file