You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2015/02/25 19:55:08 UTC
[33/50] [abbrv] stratos git commit: CLI command added to
DescribeApplicationRuntime. Fixed issues in DeleteApplicationCommand.
CLI command added to DescribeApplicationRuntime.
Fixed issues in DeleteApplicationCommand.
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/4f9eaeef
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/4f9eaeef
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/4f9eaeef
Branch: refs/heads/master-deployment-policy-fix-merge
Commit: 4f9eaeef2e5f3c067c926b32e11b8a637382bc34
Parents: 6b95185
Author: Dinithi <di...@wso2.com>
Authored: Fri Feb 20 17:16:55 2015 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Wed Feb 25 22:55:20 2015 +0530
----------------------------------------------------------------------
.../stratos/cli/RestCommandLineService.java | 28 +++++++-
.../apache/stratos/cli/StratosApplication.java | 6 ++
.../cli/commands/DeleteApplicationCommand.java | 2 +-
.../cli/commands/DeployApplicationCommand.java | 4 +-
.../DescribeApplicationRuntimeCommand.java | 67 ++++++++++++++++++++
5 files changed, 103 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f9eaeef/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
index 53336b2..0a4266e 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestCommandLineService.java
@@ -120,6 +120,7 @@ public class RestCommandLineService {
private static final String ENDPOINT_GET_KUBERNETES_MASTER = API_CONTEXT + "/kubernetesClusters/{kubernetesClusterId}/master";
private static final String ENDPOINT_GET_KUBERNETES_HOST_CLUSTER = API_CONTEXT + "/kubernetesClusters/{kubernetesClusterId}";
private static final String ENDPOINT_GET_NETWORK_PARTITION = API_CONTEXT + "/networkPartitions/{networkPartitionId}";
+ private static final String ENDPOINT_GET_APPLICATION_RUNTIME = API_CONTEXT + "/applications/{applicationId}/runtime";
private static final String ENDPOINT_UPDATE_KUBERNETES_MASTER = API_CONTEXT + "/kubernetesClusters/{kubernetesClusterId}/master";
private static final String ENDPOINT_UPDATE_KUBERNETES_HOST = API_CONTEXT + "/kubernetesClusters/{kubernetesClusterId}/minion/{minionId}";
@@ -1354,7 +1355,7 @@ public class RestCommandLineService {
* @throws CommandException
*/// This method helps to remove applications
public void deleteApplication (String applicationId) {
- restClient.deleteEntity(ENDPOINT_REMOVE_APPLICATION.replace("{applicationId}", applicationId), applicationId,
+ restClient.deleteEntity(ENDPOINT_REMOVE_APPLICATION.replace("{appId}", applicationId), applicationId,
"application");
}
@@ -1393,6 +1394,31 @@ public class RestCommandLineService {
}
/**
+ * Describe application runtime
+ * @throws CommandException
+ */
+ public void describeApplicationRuntime (String applicationID) {
+ try {
+ Type listType = new TypeToken<ApplicationBean>() {
+ }.getType();
+ ApplicationBean application = (ApplicationBean) restClient
+ .getEntity(ENDPOINT_GET_APPLICATION_RUNTIME, ApplicationBean.class, "{applicationId}", applicationID,
+ "application");
+
+ if (application == null) {
+ System.out.println("Application not found: " + applicationID);
+ return;
+ }
+
+ System.out.println("Application: " + applicationID);
+ System.out.println(getGson().toJson(application));
+ } catch (Exception e) {
+ String message = "Could not describe application runtime: " + applicationID;
+ printError(message, e);
+ }
+ }
+
+ /**
* Add application signup
* @throws CommandException
*/
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f9eaeef/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
index 8dd8166..9c35aa9 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java
@@ -255,6 +255,12 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
command = new DescribeKubernetesClusterCommand();
commands.put(command.getName(), command);
+ command = new DeleteApplicationCommand();
+ commands.put(command.getName(), command);
+
+ command = new DescribeApplicationRuntimeCommand();
+ commands.put(command.getName(), command);
+
if (logger.isDebugEnabled()) {
logger.debug("Created {} commands for the application. {}", commands.size(), commands.keySet());
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f9eaeef/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java
index 0557b0c..9286ed1 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteApplicationCommand.java
@@ -42,7 +42,7 @@ public class DeleteApplicationCommand implements Command<StratosCommandContext>
@Override
public String getArgumentSyntax() {
- return "[Application Id]";
+ return "[application-id]";
}
@Override
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f9eaeef/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java
index 4dacb00..135ff81 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java
@@ -49,12 +49,12 @@ public class DeployApplicationCommand implements Command<StratosCommandContext>
@Override
public String getName() {
- return "remove-application";
+ return "deploy-application";
}
@Override
public String getDescription() {
- return "remove application";
+ return "deploy application";
}
@Override
http://git-wip-us.apache.org/repos/asf/stratos/blob/4f9eaeef/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationRuntimeCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationRuntimeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationRuntimeCommand.java
new file mode 100644
index 0000000..4405518
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeApplicationRuntimeCommand.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.stratos.cli.commands;
+
+import org.apache.commons.cli.Options;
+import org.apache.stratos.cli.Command;
+import org.apache.stratos.cli.RestCommandLineService;
+import org.apache.stratos.cli.StratosCommandContext;
+import org.apache.stratos.cli.exception.CommandException;
+import org.apache.stratos.cli.utils.CliConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DescribeApplicationRuntimeCommand implements Command<StratosCommandContext> {
+
+ private static final Logger logger = LoggerFactory.getLogger(DescribeApplicationRuntimeCommand.class);
+
+ public DescribeApplicationRuntimeCommand() {
+ }
+
+ public String getName() {
+ return "describe-application-runtime";
+ }
+
+ public String getDescription() {
+ return "Describe application runtime";
+ }
+
+ public String getArgumentSyntax() {
+ return "[application-id]";
+ }
+
+ public int execute(StratosCommandContext context, String[] args) throws CommandException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Executing command: ", getName());
+ }
+ if ((args == null) || (args.length == 0)) {
+ context.getStratosApplication().printUsage(getName());
+ return CliConstants.COMMAND_FAILED;
+ } else {
+ String applicationId = args[0];
+ RestCommandLineService.getInstance().describeApplicationRuntime(applicationId);
+ return CliConstants.COMMAND_SUCCESSFULL;
+ }
+ }
+
+ public Options getOptions() {
+ return null;
+ }
+}