diff --git a/apps/metrics/intent/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java b/apps/metrics/intent/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java index 237fd170ee..21878ca43c 100644 --- a/apps/metrics/intent/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java +++ b/apps/metrics/intent/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java @@ -88,8 +88,7 @@ public class IntentMetrics implements IntentMetricsService, @Activate protected void activate() { - appId = - coreService.registerApplication("org.onosproject.metrics.intent"); + appId = coreService.registerApplication("org.onosproject.metrics"); clear(); registerMetrics(); diff --git a/apps/metrics/topology/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java b/apps/metrics/topology/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java index a2f0d5c5c9..ec02c3b9ad 100644 --- a/apps/metrics/topology/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java +++ b/apps/metrics/topology/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java @@ -108,8 +108,7 @@ public class TopologyMetrics implements TopologyMetricsService { @Activate protected void activate() { - appId = - coreService.registerApplication("org.onosproject.metrics.topology"); + appId = coreService.registerApplication("org.onosproject.metrics"); clear(); registerMetrics(); diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationActivateCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationActivateCommand.java deleted file mode 100644 index eadaa7d11e..0000000000 --- a/cli/src/main/java/org/onosproject/cli/app/ApplicationActivateCommand.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 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; - -/** - * Activates an installed application. - */ -@Deprecated -@Command(scope = "onos", name = "app-activate", - description = "Activates an installed application") -public class ApplicationActivateCommand extends AbstractShellCommand { - - @Argument(index = 0, name = "name", description = "Application name", - required = true, multiValued = false) - String name = null; - - @Override - protected void execute() { - ApplicationAdminService service = get(ApplicationAdminService.class); - ApplicationId appId = service.getId(name); - if (appId != null) { - service.activate(appId); - } else { - print("No such application: %s", name); - } - } - -} diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java index 4a0a9e0db4..68a195724e 100644 --- a/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java +++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationCommand.java @@ -38,9 +38,9 @@ public class ApplicationCommand extends AbstractShellCommand { required = true, multiValued = false) String command = null; - @Argument(index = 1, name = "name", description = "Application name", - required = true, multiValued = false) - String name = null; + @Argument(index = 1, name = "names", description = "Application name(s)", + required = true, multiValued = true) + String[] names = null; @Override protected void execute() { @@ -49,20 +49,22 @@ public class ApplicationCommand extends AbstractShellCommand { print("Not supported via CLI yet."); } else { - ApplicationId appId = service.getId(name); - if (appId == null) { - print("No such application: %s", name); - return; - } + for (String name : names) { + ApplicationId appId = service.getId(name); + if (appId == null) { + print("No such application: %s", name); + return; + } - 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); + 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); + } } } } diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationDeactivateCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationDeactivateCommand.java deleted file mode 100644 index 3e0195db7c..0000000000 --- a/cli/src/main/java/org/onosproject/cli/app/ApplicationDeactivateCommand.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 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; - -/** - * Deactivates an installed application. - */ -@Deprecated -@Command(scope = "onos", name = "app-deactivate", - description = "Deactivates an installed application") -public class ApplicationDeactivateCommand extends AbstractShellCommand { - - @Argument(index = 0, name = "name", description = "Application name", - required = true, multiValued = false) - String name = null; - - @Override - protected void execute() { - ApplicationAdminService service = get(ApplicationAdminService.class); - ApplicationId appId = service.getId(name); - if (appId != null) { - service.deactivate(appId); - } else { - print("No such application: %s", name); - } - } - -} diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationUninstallCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationUninstallCommand.java deleted file mode 100644 index 2e05c0cc74..0000000000 --- a/cli/src/main/java/org/onosproject/cli/app/ApplicationUninstallCommand.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 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; - -/** - * Uninstalls an application. - */ -@Deprecated -@Command(scope = "onos", name = "app-uninstall", - description = "Uninstalls an application") -public class ApplicationUninstallCommand extends AbstractShellCommand { - - @Argument(index = 0, name = "name", description = "Application name", - required = true, multiValued = false) - String name = null; - - @Override - protected void execute() { - ApplicationAdminService service = get(ApplicationAdminService.class); - ApplicationId appId = service.getId(name); - if (appId != null) { - service.uninstall(appId); - } else { - print("No such application: %s", name); - } - } - -} diff --git a/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java b/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java index 13d5cd8259..d9debdb000 100644 --- a/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java +++ b/cli/src/main/java/org/onosproject/cli/app/ApplicationsListCommand.java @@ -19,6 +19,7 @@ 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.apache.karaf.shell.commands.Option; import org.onosproject.app.ApplicationService; import org.onosproject.cli.AbstractShellCommand; import org.onosproject.cli.Comparators; @@ -41,6 +42,11 @@ public class ApplicationsListCommand extends AbstractShellCommand { "%s id=%d, name=%s, version=%s, origin=%s, description=%s, " + "features=%s, featuresRepo=%s, permissions=%s"; + @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); @@ -51,11 +57,14 @@ public class ApplicationsListCommand extends AbstractShellCommand { print("%s", json(service, apps)); } else { for (Application app : apps) { - print(FMT, service.getState(app.id()) == ACTIVE ? "*" : " ", - app.id().id(), app.id().name(), app.version(), app.origin(), - app.description(), app.features(), - app.featuresRepo().isPresent() ? app.featuresRepo().get().toString() : "", - app.permissions()); + boolean isActive = service.getState(app.id()) == ACTIVE; + if (activeOnly && isActive || !activeOnly) { + 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.permissions()); + } } } } @@ -64,7 +73,10 @@ public class ApplicationsListCommand extends AbstractShellCommand { ObjectMapper mapper = new ObjectMapper(); ArrayNode result = mapper.createArrayNode(); for (Application app : apps) { - result.add(json(service, mapper, app)); + boolean isActive = service.getState(app.id()) == ACTIVE; + if (activeOnly && isActive || !activeOnly) { + result.add(json(service, mapper, app)); + } } return result; } diff --git a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml index 265dcd0a18..e065d315e0 100644 --- a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml +++ b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml @@ -29,7 +29,6 @@ - diff --git a/tools/test/bin/onos-app b/tools/test/bin/onos-app index 31b87d325c..0515e838d5 100755 --- a/tools/test/bin/onos-app +++ b/tools/test/bin/onos-app @@ -15,10 +15,12 @@ case $cmd in list) $curl -X GET $URL;; install) $curl -X POST $HDR $URL --data-binary @$app;; install!) $curl -X POST $HDR $URL?activate=true --data-binary @$app;; + reinstall) $curl -X DELETE $URL/$app && $curl -X POST $HDR $URL --data-binary @$app;; + reinstall!) $curl -X DELETE $URL/$app && $curl -X POST $HDR $URL?activate=true --data-binary @$app;; uninstall) $curl -X DELETE $URL/$app;; activate) $curl -X POST $URL/$app/active;; deactivate) $curl -X DELETE $URL/$app/active;; - *) echo "usage: onos-app {install|install!} " >&2 + *) echo "usage: onos-app {install|install!|reinstall|reinstall!} " >&2 echo " onos-app {activate|deactivate|uninstall} " >&2 exit 1;; esac