summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/cli/src/main/java/org/onosproject/cli/app
diff options
context:
space:
mode:
authorCNlucius <lukai1@huawei.com>2016-09-13 11:40:12 +0800
committerCNlucius <lukai1@huawei.com>2016-09-13 11:41:53 +0800
commitb731e2f1dd0972409b136aebc7b463dd72c9cfad (patch)
tree5107d7d80c19ad8076c2c97c2b5ef8d1cf3ab903 /framework/src/onos/cli/src/main/java/org/onosproject/cli/app
parentee93993458266114c29271a481ef9ce7ce621b2a (diff)
ONOSFW-171
O/S-SFC-ONOS scenario documentation Change-Id: I51ae1cf736ea24ab6680f8edca1b2bf5dd598365 Signed-off-by: CNlucius <lukai1@huawei.com>
Diffstat (limited to 'framework/src/onos/cli/src/main/java/org/onosproject/cli/app')
-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
8 files changed, 0 insertions, 501 deletions
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