You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by im...@apache.org on 2014/12/17 11:39:45 UTC

[1/3] stratos git commit: Updating deploy application cli command

Repository: stratos
Updated Branches:
  refs/heads/4.1.0-test aceb115f3 -> aa5032702


Updating deploy application cli command


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/cb576861
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/cb576861
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/cb576861

Branch: refs/heads/4.1.0-test
Commit: cb576861e61816f34a24a241ea16c0d1eea18ac7
Parents: aceb115
Author: Imesh Gunaratne <im...@apache.org>
Authored: Wed Dec 17 15:47:18 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Wed Dec 17 15:47:18 2014 +0530

----------------------------------------------------------------------
 .../java/org/apache/stratos/cli/RestCommandLineService.java   | 7 ++++---
 .../apache/stratos/cli/commands/DeployApplicationCommand.java | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/cb576861/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 ea7452d..61f5e2b 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
@@ -75,7 +75,7 @@ public class RestCommandLineService {
     private static final String ENDPOINT_DEPLOY_KUBERNETES_CLUSTER = API_CONTEXT + "/kubernetesCluster";
     private static final String ENDPOINT_DEPLOY_KUBERNETES_HOST = API_CONTEXT + "/kubernetesCluster/{kubernetesClusterId}/minion";
     private static final String ENDPOINT_DEPLOY_SERVICE_GROUP = API_CONTEXT + "/groups";
-    private static final String ENDPOINT_DEPLOY_APPLICATION = API_CONTEXT + "/applications";
+    private static final String ENDPOINT_DEPLOY_APPLICATION = API_CONTEXT + "/applications/{applicationId}/deploy";
 
     private static final String ENDPOINT_UNDEPLOY_KUBERNETES_CLUSTER= API_CONTEXT + "/kubernetesCluster/{id}";
     private static final String ENDPOINT_UNDEPLOY_KUBERNETES_HOST = API_CONTEXT + "/kubernetesCluster/{kubernetesClusterId}/hosts/{id}";
@@ -930,8 +930,9 @@ public class RestCommandLineService {
     }
 
     // This method helps to deploy applications
-    public void deployApplication (String entityBody) {
-        restClient.deployEntity(ENDPOINT_DEPLOY_APPLICATION, entityBody, "application");
+    public void deployApplication (String applicationId, String entityBody) {
+        restClient.deployEntity(ENDPOINT_DEPLOY_APPLICATION.replace("{applicationId}", applicationId), entityBody,
+                "application");
     }
 
     // This method helps to undeploy applications

http://git-wip-us.apache.org/repos/asf/stratos/blob/cb576861/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 25e9567..699f803 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
@@ -59,7 +59,7 @@ public class DeployApplicationCommand implements Command<StratosCommandContext>
 
     @Override
     public String getArgumentSyntax() {
-        return null;
+        return "[application-id]";
     }
 
     @Override
@@ -77,6 +77,7 @@ public class DeployApplicationCommand implements Command<StratosCommandContext>
             context.getStratosApplication().printUsage(getName());
             return CliConstants.COMMAND_FAILED;
         }
+        String applicationId = args[0];
 
         try {
             CommandLineParser parser = new GnuParser();
@@ -88,7 +89,7 @@ public class DeployApplicationCommand implements Command<StratosCommandContext>
                     return CliConstants.COMMAND_FAILED;
                 }
                 String resourceFileContent = CliUtils.readResource(resourcePath);
-                RestCommandLineService.getInstance().deployApplication(resourceFileContent);
+                RestCommandLineService.getInstance().deployApplication(applicationId, resourceFileContent);
                 return CliConstants.COMMAND_SUCCESSFULL;
             } else {
                 System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");


[3/3] stratos git commit: Renaming deploy commands to add

Posted by im...@apache.org.
Renaming deploy commands to add


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/aa503270
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/aa503270
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/aa503270

Branch: refs/heads/4.1.0-test
Commit: aa50327024b20b6e0713817a5f324d6c80613ef0
Parents: 7295c88
Author: Imesh Gunaratne <im...@apache.org>
Authored: Wed Dec 17 16:09:33 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Wed Dec 17 16:09:33 2014 +0530

----------------------------------------------------------------------
 .../stratos/cli/RestCommandLineService.java     |  12 +-
 .../apache/stratos/cli/StratosApplication.java  |  14 +-
 .../commands/AddAutoscalingPolicyCommand.java   | 138 ++++++++++++++++++
 .../cli/commands/AddCartridgeCommand.java       | 140 +++++++++++++++++++
 .../cli/commands/AddCartridgeGroupCommand.java  | 111 +++++++++++++++
 .../cli/commands/AddKubernetesGroupCommand.java | 112 +++++++++++++++
 .../DeployAutoscalingPolicyCommand.java         | 138 ------------------
 .../cli/commands/DeployCartridgeCommand.java    | 140 -------------------
 .../commands/DeployKubernetesGroupCommand.java  | 112 ---------------
 .../commands/DeployKubernetesHostCommand.java   | 128 -----------------
 .../cli/commands/DeployServiceGroupCommand.java | 111 ---------------
 .../stratos/cli/commands/ListAllTenants.java    |  65 ---------
 .../stratos/cli/commands/ListAllUsers.java      |  65 ---------
 .../stratos/cli/commands/ListTenants.java       |  65 +++++++++
 .../apache/stratos/cli/commands/ListUsers.java  |  65 +++++++++
 .../commands/UpdateKubernetesHostCommand.java   |   2 +-
 .../commands/UpdateKubernetesMasterCommand.java |   2 +-
 .../cli/commands/addKubernetesHostCommand.java  | 128 +++++++++++++++++
 .../apache/stratos/cli/utils/CliConstants.java  |   4 +-
 19 files changed, 776 insertions(+), 776 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/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 61f5e2b..36b0128 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
@@ -559,7 +559,7 @@ public class RestCommandLineService {
     }
 
     // This method helps to list all tenants
-    public void listAllTenants() throws CommandException {
+    public void listTenants() throws CommandException {
         try {
             Type listType = new TypeToken<ArrayList<TenantInfoBean>>() {
             }.getType();
@@ -628,7 +628,7 @@ public class RestCommandLineService {
     }
 
     // This method helps to deploy cartridge definitions
-    public void deployCartridgeDefinition(String cartridgeDefinition) throws CommandException {
+    public void addCartridge(String cartridgeDefinition) throws CommandException {
         restClient.deployEntity(ENDPOINT_DEPLOY_CARTRIDGE, cartridgeDefinition, "cartridge");
     }
 
@@ -638,7 +638,7 @@ public class RestCommandLineService {
     }
 
     // This method helps to deploy autoscalling polices
-    public void deployAutoscalingPolicy(String autoScalingPolicy) throws CommandException {
+    public void addAutoscalingPolicy(String autoScalingPolicy) throws CommandException {
         restClient.deployEntity(ENDPOINT_DEPLOY_AUTOSCALING_POLICY, autoScalingPolicy, "autoscaling policy");
     }
 
@@ -764,7 +764,7 @@ public class RestCommandLineService {
         }
     }
 
-    public void deployKubernetesCluster(String entityBody) {
+    public void addKubernetesCluster(String entityBody) {
         restClient.deployEntity(ENDPOINT_DEPLOY_KUBERNETES_CLUSTER, entityBody, "kubernetes cluster");
     }
 
@@ -802,7 +802,7 @@ public class RestCommandLineService {
         restClient.undeployEntity(ENDPOINT_UNDEPLOY_KUBERNETES_CLUSTER, "kubernetes cluster", clusterId);
     }
 
-    public void deployKubernetesHost(String entityBody, String clusterId) throws CommandException {
+    public void addKubernetesHost(String entityBody, String clusterId) throws CommandException {
         DefaultHttpClient httpClient = new DefaultHttpClient();
         try {
             HttpResponse response = restClient.doPut(httpClient, restClient.getBaseURL()
@@ -901,7 +901,7 @@ public class RestCommandLineService {
     }
 
     // This method helps to deploy service groups
-    public void deployServiceGroup (String entityBody) {
+    public void addCartridgeGroup(String entityBody) {
         restClient.deployEntity(ENDPOINT_DEPLOY_SERVICE_GROUP, entityBody, "service group");
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/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 0298742..5af9fc5 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
@@ -102,10 +102,10 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
         command = new DeleteUserCommand();
         commands.put(command.getName(), command);
 
-        command = new ListAllUsers();
+        command = new ListUsers();
         commands.put(command.getName(), command);
 
-        command = new ListAllTenants();
+        command = new ListTenants();
         commands.put(command.getName(), command);
 
         command = new DeactivateTenantCommand();
@@ -114,10 +114,10 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
         command = new ActivateTenantCommand();
         commands.put(command.getName(), command);
 
-        command = new DeployCartridgeCommand();
+        command = new AddCartridgeCommand();
         commands.put(command.getName(), command);
 
-        command = new DeployAutoscalingPolicyCommand();
+        command = new AddAutoscalingPolicyCommand();
         commands.put(command.getName(), command);
 
         command = new ListApplicationsCommand();
@@ -141,7 +141,7 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
 		command = new SyncCommand();
 		commands.put(command.getName(), command);
 
-        command = new DeployKubernetesGroupCommand();
+        command = new AddKubernetesGroupCommand();
         commands.put(command.getName(), command);
 
         command = new ListKubernetesGroupsCommand();
@@ -150,7 +150,7 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
         command = new ListKubernetesHostsCommand();
         commands.put(command.getName(), command);
 
-        command = new DeployKubernetesHostCommand();
+        command = new AddKubernetesHostCommand();
         commands.put(command.getName(), command);
 
         command = new UnDeployKubernetesGroupCommand();
@@ -165,7 +165,7 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
         command = new UpdateKubernetesHostCommand();
         commands.put(command.getName(), command);
 
-        command = new DeployServiceGroupCommand();
+        command = new AddCartridgeGroupCommand();
         commands.put(command.getName(), command);
 
         command = new DescribeServiceGroupCommand();

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddAutoscalingPolicyCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddAutoscalingPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddAutoscalingPolicyCommand.java
new file mode 100644
index 0000000..019d047
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddAutoscalingPolicyCommand.java
@@ -0,0 +1,138 @@
+/**
+ *  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.*;
+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;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class AddAutoscalingPolicyCommand implements Command<StratosCommandContext> {
+
+    private static final Logger logger = LoggerFactory.getLogger(AddAutoscalingPolicyCommand.class);
+
+    private final Options options;
+
+    public AddAutoscalingPolicyCommand(){
+        options = constructOptions();
+    }
+
+    private Options constructOptions() {
+        final Options options = new Options();
+
+        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
+                "Autoscaling policy resource path");
+        resourcePath.setArgName("resource path");
+        options.addOption(resourcePath);
+
+        return options;
+    }
+
+    public String getName() {
+        return "add-autoscaling-policy";
+    }
+
+    public String getDescription() {
+        return "Add autoscaling policy deployment";
+    }
+
+    public String getArgumentSyntax() {
+        return null;
+    }
+
+    public int execute(StratosCommandContext context, String[] args) throws CommandException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Executing {} command...", getName());
+        }
+
+        if (args != null && args.length > 0) {
+            String resourcePath = null;
+            String autoscalingPolicyDeployment = null;
+
+            final CommandLineParser parser = new GnuParser();
+            CommandLine commandLine;
+
+            try {
+                commandLine = parser.parse(options, args);
+
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Autoscaling policy deployment");
+                }
+
+                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
+                    if (logger.isTraceEnabled()) {
+                        logger.trace("Resource path option is passed");
+                    }
+                    resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
+                    autoscalingPolicyDeployment = readResource(resourcePath);
+                }
+
+                if (resourcePath == null) {
+                    System.out.println("usage: " + getName() + " [-p <resource path>]");
+                    return CliConstants.COMMAND_FAILED;
+                }
+
+                RestCommandLineService.getInstance().addAutoscalingPolicy(autoscalingPolicyDeployment);
+                return CliConstants.COMMAND_SUCCESSFULL;
+
+            } catch (ParseException e) {
+                if (logger.isErrorEnabled()) {
+                    logger.error("Error parsing arguments", e);
+                }
+                System.out.println(e.getMessage());
+                return CliConstants.COMMAND_FAILED;
+            } catch (IOException e) {
+                //e.printStackTrace();
+                System.out.println("Invalid resource path");
+                return CliConstants.COMMAND_FAILED;
+            }
+        } else {
+            context.getStratosApplication().printUsage(getName());
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+
+    private String readResource(String fileName) throws IOException {
+        BufferedReader br = new BufferedReader(new FileReader(fileName));
+        try {
+            StringBuilder sb = new StringBuilder();
+            String line = br.readLine();
+
+            while (line != null) {
+                sb.append(line);
+                sb.append("\n");
+                line = br.readLine();
+            }
+            return sb.toString();
+        } finally {
+            br.close();
+        }
+    }
+
+    public Options getOptions() {
+        return options;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddCartridgeCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddCartridgeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddCartridgeCommand.java
new file mode 100644
index 0000000..1367fef
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddCartridgeCommand.java
@@ -0,0 +1,140 @@
+/**
+ *  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.*;
+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;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class AddCartridgeCommand implements Command<StratosCommandContext> {
+
+    private static final Logger logger = LoggerFactory.getLogger(AddCartridgeCommand.class);
+
+    private final Options options;
+
+    public AddCartridgeCommand(){
+        options = constructOptions();
+    }
+
+    private Options constructOptions() {
+        final Options options = new Options();
+
+        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
+                "Cartridge resource path");
+        resourcePath.setArgName("resource path");
+        options.addOption(resourcePath);
+
+        return options;
+    }
+
+    public String getName() {
+        return "add-cartridge";
+    }
+
+    public String getDescription() {
+        return "Add cartridge deployment";
+    }
+
+    public String getArgumentSyntax() {
+        return null;
+    }
+
+    public int execute(StratosCommandContext context, String[] args) throws CommandException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Executing {} command...", getName());
+        }
+
+        if (args != null && args.length > 0) {
+            String resourcePath = null;
+            String cartridgeJson = null;
+
+            final CommandLineParser parser = new GnuParser();
+            CommandLine commandLine;
+
+            try {
+                commandLine = parser.parse(options, args);
+
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Cartridge deployment");
+                }
+
+                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
+                    if (logger.isTraceEnabled()) {
+                        logger.trace("Resource path option is passed");
+                    }
+                    resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
+                    cartridgeJson = readResource(resourcePath);
+                }
+
+                if (resourcePath == null) {
+                    System.out.println("usage: " + getName() + " [-p <resource path>]");
+                    return CliConstants.COMMAND_FAILED;
+                }
+
+                RestCommandLineService.getInstance().addCartridge(cartridgeJson);
+                return CliConstants.COMMAND_SUCCESSFULL;
+
+            } catch (ParseException e) {
+                if (logger.isErrorEnabled()) {
+                    logger.error("Error parsing arguments", e);
+                }
+                System.out.println(e.getMessage());
+                return CliConstants.COMMAND_FAILED;
+            } catch (IOException e) {
+                //e.printStackTrace();
+                System.out.println("Invalid resource path");
+                return CliConstants.COMMAND_FAILED;
+            }
+
+
+        } else {
+            context.getStratosApplication().printUsage(getName());
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+
+    private String readResource(String fileName) throws IOException {
+        BufferedReader br = new BufferedReader(new FileReader(fileName));
+        try {
+            StringBuilder sb = new StringBuilder();
+            String line = br.readLine();
+
+            while (line != null) {
+                sb.append(line);
+                sb.append("\n");
+                line = br.readLine();
+            }
+            return sb.toString();
+        } finally {
+            br.close();
+        }
+    }
+
+    public Options getOptions() {
+        return options;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddCartridgeGroupCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddCartridgeGroupCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddCartridgeGroupCommand.java
new file mode 100644
index 0000000..46c3bf3
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddCartridgeGroupCommand.java
@@ -0,0 +1,111 @@
+/**
+ *  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.*;
+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.apache.stratos.cli.utils.CliUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+
+/**
+ * Deploy service group command.
+ */
+public class AddCartridgeGroupCommand implements Command<StratosCommandContext> {
+
+    private static final Logger logger = LoggerFactory.getLogger(AddCartridgeGroupCommand.class);
+
+    private Options options;
+
+    public AddCartridgeGroupCommand() {
+        options = new Options();
+        Option option = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
+                "Cartridge group resource path");
+        option.setArgName("resource path");
+        options.addOption(option);
+    }
+
+    @Override
+    public String getName() {
+        return "add-cartridge-group";
+    }
+
+    @Override
+    public String getDescription() {
+        return "Add cartridge group";
+    }
+
+    @Override
+    public String getArgumentSyntax() {
+        return null;
+    }
+
+    @Override
+    public Options getOptions() {
+        return options;
+    }
+
+    @Override
+    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;
+        }
+
+        try {
+            CommandLineParser parser = new GnuParser();
+            CommandLine commandLine = parser.parse(options, args);
+            if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
+                String resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
+                if (resourcePath == null) {
+                    System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");
+                    return CliConstants.COMMAND_FAILED;
+                }
+                String resourceFileContent = CliUtils.readResource(resourcePath);
+                RestCommandLineService.getInstance().addCartridgeGroup(resourceFileContent);
+                return CliConstants.COMMAND_SUCCESSFULL;
+            } else {
+                System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");
+                return CliConstants.COMMAND_FAILED;
+            }
+        } catch (ParseException e) {
+            logger.error("Error parsing arguments", e);
+            System.out.println(e.getMessage());
+            return CliConstants.COMMAND_FAILED;
+        } catch (IOException e) {
+            System.out.println("Invalid resource path");
+            return CliConstants.COMMAND_FAILED;
+        } catch (Exception e) {
+            String message = "Unknown error occurred: " + e.getMessage();
+            System.out.println(message);
+            logger.error(message, e);
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddKubernetesGroupCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddKubernetesGroupCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddKubernetesGroupCommand.java
new file mode 100644
index 0000000..41054ec
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddKubernetesGroupCommand.java
@@ -0,0 +1,112 @@
+/**
+ *  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.*;
+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.apache.stratos.cli.utils.CliUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+/**
+ * Deploy kubernetes group command.
+ */
+public class AddKubernetesGroupCommand implements Command<StratosCommandContext> {
+
+    private static final Logger logger = LoggerFactory.getLogger(AddKubernetesGroupCommand.class);
+
+    private Options options;
+
+    public AddKubernetesGroupCommand() {
+        options = new Options();
+        Option option = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
+                "Kubernetes group resource path");
+        option.setArgName("resource path");
+        options.addOption(option);
+    }
+
+    @Override
+    public String getName() {
+        return "add-kubernetes-group";
+    }
+
+    @Override
+    public String getDescription() {
+        return "Add kubernetes group";
+    }
+
+    @Override
+    public String getArgumentSyntax() {
+        return null;
+    }
+
+    @Override
+    public Options getOptions() {
+        return options;
+    }
+
+    @Override
+    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;
+        }
+
+        try {
+            CommandLineParser parser = new GnuParser();
+            CommandLine commandLine = parser.parse(options, args);
+            if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
+                String resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
+                if (resourcePath == null) {
+                    System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");
+                    return CliConstants.COMMAND_FAILED;
+                }
+                String resourceFileContent = CliUtils.readResource(resourcePath);
+                RestCommandLineService.getInstance().addKubernetesCluster(resourceFileContent);
+                return CliConstants.COMMAND_SUCCESSFULL;
+            } else {
+                System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");
+                return CliConstants.COMMAND_FAILED;
+            }
+        } catch (ParseException e) {
+            logger.error("Error parsing arguments", e);
+            System.out.println(e.getMessage());
+            return CliConstants.COMMAND_FAILED;
+        } catch (IOException e) {
+            System.out.println("Invalid resource path");
+            return CliConstants.COMMAND_FAILED;
+        } catch (Exception e) {
+            String message = "Unknown error occurred: " + e.getMessage();
+            System.out.println(message);
+            logger.error(message, e);
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployAutoscalingPolicyCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployAutoscalingPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployAutoscalingPolicyCommand.java
deleted file mode 100644
index f6aa2ba..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployAutoscalingPolicyCommand.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/**
- *  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.*;
-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;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class DeployAutoscalingPolicyCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(DeployAutoscalingPolicyCommand.class);
-
-    private final Options options;
-
-    public DeployAutoscalingPolicyCommand(){
-        options = constructOptions();
-    }
-
-    private Options constructOptions() {
-        final Options options = new Options();
-
-        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Autoscaling policy deployment resource path");
-        resourcePath.setArgName("resource path");
-        options.addOption(resourcePath);
-
-        return options;
-    }
-
-    public String getName() {
-        return CliConstants.AUTOSCALING_POLICY_DEPLOYMENT;
-    }
-
-    public String getDescription() {
-        return "Add new autoscaling policy deployment";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-
-        if (args != null && args.length > 0) {
-            String resourcePath = null;
-            String autoscalingPolicyDeployment = null;
-
-            final CommandLineParser parser = new GnuParser();
-            CommandLine commandLine;
-
-            try {
-                commandLine = parser.parse(options, args);
-
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Autoscaling policy deployment");
-                }
-
-                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Resource path option is passed");
-                    }
-                    resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                    autoscalingPolicyDeployment = readResource(resourcePath);
-                }
-
-                if (resourcePath == null) {
-                    System.out.println("usage: " + getName() + " [-p <resource path>]");
-                    return CliConstants.COMMAND_FAILED;
-                }
-
-                RestCommandLineService.getInstance().deployAutoscalingPolicy(autoscalingPolicyDeployment);
-                return CliConstants.COMMAND_SUCCESSFULL;
-
-            } catch (ParseException e) {
-                if (logger.isErrorEnabled()) {
-                    logger.error("Error parsing arguments", e);
-                }
-                System.out.println(e.getMessage());
-                return CliConstants.COMMAND_FAILED;
-            } catch (IOException e) {
-                //e.printStackTrace();
-                System.out.println("Invalid resource path");
-                return CliConstants.COMMAND_FAILED;
-            }
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-
-    private String readResource(String fileName) throws IOException {
-        BufferedReader br = new BufferedReader(new FileReader(fileName));
-        try {
-            StringBuilder sb = new StringBuilder();
-            String line = br.readLine();
-
-            while (line != null) {
-                sb.append(line);
-                sb.append("\n");
-                line = br.readLine();
-            }
-            return sb.toString();
-        } finally {
-            br.close();
-        }
-    }
-
-    public Options getOptions() {
-        return options;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployCartridgeCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployCartridgeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployCartridgeCommand.java
deleted file mode 100644
index 6982fc1..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployCartridgeCommand.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**
- *  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.*;
-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;
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-
-public class DeployCartridgeCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(DeployCartridgeCommand.class);
-
-    private final Options options;
-
-    public DeployCartridgeCommand(){
-        options = constructOptions();
-    }
-
-    private Options constructOptions() {
-        final Options options = new Options();
-
-        Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Cartridge deployment resource path");
-        resourcePath.setArgName("resource path");
-        options.addOption(resourcePath);
-
-        return options;
-    }
-
-    public String getName() {
-        return CliConstants.CARTRIDGE_DEPLOYMENT;
-    }
-
-    public String getDescription() {
-        return "Add new cartridge deployment";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-
-        if (args != null && args.length > 0) {
-            String resourcePath = null;
-            String cartridgeDeploymentJSON = null;
-
-            final CommandLineParser parser = new GnuParser();
-            CommandLine commandLine;
-
-            try {
-                commandLine = parser.parse(options, args);
-
-                if (logger.isDebugEnabled()) {
-                    logger.debug("Cartridge deployment");
-                }
-
-                if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
-                    if (logger.isTraceEnabled()) {
-                        logger.trace("Resource path option is passed");
-                    }
-                    resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                    cartridgeDeploymentJSON = readResource(resourcePath);
-                }
-
-                if (resourcePath == null) {
-                    System.out.println("usage: " + getName() + " [-p <resource path>]");
-                    return CliConstants.COMMAND_FAILED;
-                }
-
-                RestCommandLineService.getInstance().deployCartridgeDefinition(cartridgeDeploymentJSON);
-                return CliConstants.COMMAND_SUCCESSFULL;
-
-            } catch (ParseException e) {
-                if (logger.isErrorEnabled()) {
-                    logger.error("Error parsing arguments", e);
-                }
-                System.out.println(e.getMessage());
-                return CliConstants.COMMAND_FAILED;
-            } catch (IOException e) {
-                //e.printStackTrace();
-                System.out.println("Invalid resource path");
-                return CliConstants.COMMAND_FAILED;
-            }
-
-
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-
-    private String readResource(String fileName) throws IOException {
-        BufferedReader br = new BufferedReader(new FileReader(fileName));
-        try {
-            StringBuilder sb = new StringBuilder();
-            String line = br.readLine();
-
-            while (line != null) {
-                sb.append(line);
-                sb.append("\n");
-                line = br.readLine();
-            }
-            return sb.toString();
-        } finally {
-            br.close();
-        }
-    }
-
-    public Options getOptions() {
-        return options;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesGroupCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesGroupCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesGroupCommand.java
deleted file mode 100644
index 320fe68..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesGroupCommand.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- *  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.*;
-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.apache.stratos.cli.utils.CliUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-/**
- * Deploy kubernetes group command.
- */
-public class DeployKubernetesGroupCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(DeployKubernetesGroupCommand.class);
-
-    private Options options;
-
-    public DeployKubernetesGroupCommand() {
-        options = new Options();
-        Option option = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Kubernetes group resource path");
-        option.setArgName("resource path");
-        options.addOption(option);
-    }
-
-    @Override
-    public String getName() {
-        return "deploy-kubernetes-group";
-    }
-
-    @Override
-    public String getDescription() {
-        return "Deploy kubernetes group";
-    }
-
-    @Override
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    @Override
-    public Options getOptions() {
-        return options;
-    }
-
-    @Override
-    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;
-        }
-
-        try {
-            CommandLineParser parser = new GnuParser();
-            CommandLine commandLine = parser.parse(options, args);
-            if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
-                String resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                if (resourcePath == null) {
-                    System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");
-                    return CliConstants.COMMAND_FAILED;
-                }
-                String resourceFileContent = CliUtils.readResource(resourcePath);
-                RestCommandLineService.getInstance().deployKubernetesCluster(resourceFileContent);
-                return CliConstants.COMMAND_SUCCESSFULL;
-            } else {
-                System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");
-                return CliConstants.COMMAND_FAILED;
-            }
-        } catch (ParseException e) {
-            logger.error("Error parsing arguments", e);
-            System.out.println(e.getMessage());
-            return CliConstants.COMMAND_FAILED;
-        } catch (IOException e) {
-            System.out.println("Invalid resource path");
-            return CliConstants.COMMAND_FAILED;
-        } catch (Exception e) {
-            String message = "Unknown error occurred: " + e.getMessage();
-            System.out.println(message);
-            logger.error(message, e);
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesHostCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesHostCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesHostCommand.java
deleted file mode 100644
index 235929d..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesHostCommand.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/**
- *  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.*;
-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.apache.stratos.cli.utils.CliUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-
-/**
- * Deploy kubernetes host command.
- */
-public class DeployKubernetesHostCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(DeployKubernetesHostCommand.class);
-
-    private Options options;
-
-    public DeployKubernetesHostCommand() {
-        options = new Options();
-        Option resourcePathOption = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Kubernetes host resource path");
-        resourcePathOption.setArgName("resource path");
-        Option clusterIdOption = new Option(CliConstants.CLUSTER_ID_OPTION, CliConstants.CLUSTER_ID_LONG_OPTION, true,
-                "Kubernetes cluster id");
-        clusterIdOption.setArgName("cluster id");
-        options.addOption(clusterIdOption);
-        options.addOption(resourcePathOption);
-    }
-
-    @Override
-    public String getName() {
-        return "deploy-kubernetes-host";
-    }
-
-    @Override
-    public String getDescription() {
-        return "Deploy kubernetes host";
-    }
-
-    @Override
-    public String getArgumentSyntax() {
-    	return null;
-    }
-
-    @Override
-    public Options getOptions() {
-        return options;
-    }
-
-    @Override
-    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;
-        }
-       			
-        try {
-            CommandLineParser parser = new GnuParser();
-            CommandLine commandLine = parser.parse(options, args);
-            
-            if((commandLine.hasOption(CliConstants.RESOURCE_PATH)) && (commandLine.hasOption(CliConstants.CLUSTER_ID_OPTION))) {
-	               
-                // get cluster id arg value
-            	String clusterId = commandLine.getOptionValue(CliConstants.CLUSTER_ID_OPTION);
-                if (clusterId == null) {
-                    context.getStratosApplication().printUsage(getName());
-                    return CliConstants.COMMAND_FAILED;
-                }
-                
-                // get resource path arg value
-            	String resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                if (resourcePath == null) {
-                    context.getStratosApplication().printUsage(getName());
-                    return CliConstants.COMMAND_FAILED;
-                }
-                String resourceFileContent = CliUtils.readResource(resourcePath);
-                
-                RestCommandLineService.getInstance().deployKubernetesHost(resourceFileContent, clusterId);
-                return CliConstants.COMMAND_SUCCESSFULL;
-            } else {
-                context.getStratosApplication().printUsage(getName());
-                return CliConstants.COMMAND_FAILED;
-            }
-           
-        } catch (ParseException e) {
-            logger.error("Error parsing arguments", e);
-            System.out.println(e.getMessage());
-            return CliConstants.COMMAND_FAILED;
-        } catch (IOException e) {
-            System.out.println("Invalid resource path");
-            return CliConstants.COMMAND_FAILED;
-        } catch (Exception e) {
-            String message = "Unknown error occurred: " + e.getMessage();
-            System.out.println(message);
-            logger.error(message, e);
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceGroupCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceGroupCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceGroupCommand.java
deleted file mode 100644
index c59da2e..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceGroupCommand.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- *  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.*;
-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.apache.stratos.cli.utils.CliUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
-/**
- * Deploy service group command.
- */
-public class DeployServiceGroupCommand implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(DeployServiceGroupCommand.class);
-
-    private Options options;
-
-    public DeployServiceGroupCommand() {
-        options = new Options();
-        Option option = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
-                "Service group resource path");
-        option.setArgName("resource path");
-        options.addOption(option);
-    }
-
-    @Override
-    public String getName() {
-        return "deploy-service-group";
-    }
-
-    @Override
-    public String getDescription() {
-        return "Deploy service group";
-    }
-
-    @Override
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    @Override
-    public Options getOptions() {
-        return options;
-    }
-
-    @Override
-    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;
-        }
-
-        try {
-            CommandLineParser parser = new GnuParser();
-            CommandLine commandLine = parser.parse(options, args);
-            if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
-                String resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
-                if (resourcePath == null) {
-                    System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");
-                    return CliConstants.COMMAND_FAILED;
-                }
-                String resourceFileContent = CliUtils.readResource(resourcePath);
-                RestCommandLineService.getInstance().deployServiceGroup(resourceFileContent);
-                return CliConstants.COMMAND_SUCCESSFULL;
-            } else {
-                System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]");
-                return CliConstants.COMMAND_FAILED;
-            }
-        } catch (ParseException e) {
-            logger.error("Error parsing arguments", e);
-            System.out.println(e.getMessage());
-            return CliConstants.COMMAND_FAILED;
-        } catch (IOException e) {
-            System.out.println("Invalid resource path");
-            return CliConstants.COMMAND_FAILED;
-        } catch (Exception e) {
-            String message = "Unknown error occurred: " + e.getMessage();
-            System.out.println(message);
-            logger.error(message, e);
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java
deleted file mode 100644
index 1540c7c..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *  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 ListAllTenants implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(ListAllTenants.class);
-
-    public ListAllTenants(){
-    }
-
-    public String getName() {
-        return CliConstants.LIST_TENANTS;
-    }
-
-    public String getDescription() {
-        return "List available tenants";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-        if (args == null || args.length == 0) {
-            RestCommandLineService.getInstance().listAllTenants();
-            return CliConstants.COMMAND_SUCCESSFULL;
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-
-    public Options getOptions() {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllUsers.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllUsers.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllUsers.java
deleted file mode 100644
index 6638cc7..0000000
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllUsers.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- *  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 ListAllUsers implements Command<StratosCommandContext> {
-
-    private static final Logger logger = LoggerFactory.getLogger(ListAllUsers.class);
-
-    public ListAllUsers(){
-    }
-
-    public String getName() {
-        return CliConstants.LIST_USERS;
-    }
-
-    public String getDescription() {
-        return "List available users";
-    }
-
-    public String getArgumentSyntax() {
-        return null;
-    }
-
-    public int execute(StratosCommandContext context, String[] args) throws CommandException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Executing {} command...", getName());
-        }
-        if (args == null || args.length == 0) {
-            RestCommandLineService.getInstance().listAllUsers();
-            return CliConstants.COMMAND_SUCCESSFULL;
-        } else {
-            context.getStratosApplication().printUsage(getName());
-            return CliConstants.COMMAND_FAILED;
-        }
-    }
-
-    public Options getOptions() {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListTenants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListTenants.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListTenants.java
new file mode 100644
index 0000000..da19061
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListTenants.java
@@ -0,0 +1,65 @@
+/**
+ *  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 ListTenants implements Command<StratosCommandContext> {
+
+    private static final Logger logger = LoggerFactory.getLogger(ListTenants.class);
+
+    public ListTenants(){
+    }
+
+    public String getName() {
+        return CliConstants.LIST_TENANTS;
+    }
+
+    public String getDescription() {
+        return "List available tenants";
+    }
+
+    public String getArgumentSyntax() {
+        return null;
+    }
+
+    public int execute(StratosCommandContext context, String[] args) throws CommandException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Executing {} command...", getName());
+        }
+        if (args == null || args.length == 0) {
+            RestCommandLineService.getInstance().listTenants();
+            return CliConstants.COMMAND_SUCCESSFULL;
+        } else {
+            context.getStratosApplication().printUsage(getName());
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+
+    public Options getOptions() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListUsers.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListUsers.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListUsers.java
new file mode 100644
index 0000000..e7ac8d4
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListUsers.java
@@ -0,0 +1,65 @@
+/**
+ *  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 ListUsers implements Command<StratosCommandContext> {
+
+    private static final Logger logger = LoggerFactory.getLogger(ListUsers.class);
+
+    public ListUsers(){
+    }
+
+    public String getName() {
+        return CliConstants.LIST_USERS;
+    }
+
+    public String getDescription() {
+        return "List available users";
+    }
+
+    public String getArgumentSyntax() {
+        return null;
+    }
+
+    public int execute(StratosCommandContext context, String[] args) throws CommandException {
+        if (logger.isDebugEnabled()) {
+            logger.debug("Executing {} command...", getName());
+        }
+        if (args == null || args.length == 0) {
+            RestCommandLineService.getInstance().listAllUsers();
+            return CliConstants.COMMAND_SUCCESSFULL;
+        } else {
+            context.getStratosApplication().printUsage(getName());
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+
+    public Options getOptions() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesHostCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesHostCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesHostCommand.java
index 078fa5c..0688d65 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesHostCommand.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesHostCommand.java
@@ -35,7 +35,7 @@ import java.io.IOException;
  */
 public class UpdateKubernetesHostCommand implements Command<StratosCommandContext> {
 
-    private static final Logger logger = LoggerFactory.getLogger(DeployKubernetesGroupCommand.class);
+    private static final Logger logger = LoggerFactory.getLogger(AddKubernetesGroupCommand.class);
 
     private Options options;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesMasterCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesMasterCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesMasterCommand.java
index 3186be4..4c52f37 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesMasterCommand.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UpdateKubernetesMasterCommand.java
@@ -35,7 +35,7 @@ import java.io.IOException;
  */
 public class UpdateKubernetesMasterCommand implements Command<StratosCommandContext> {
 
-    private static final Logger logger = LoggerFactory.getLogger(DeployKubernetesGroupCommand.class);
+    private static final Logger logger = LoggerFactory.getLogger(AddKubernetesGroupCommand.class);
 
     private Options options;
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/addKubernetesHostCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/addKubernetesHostCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/addKubernetesHostCommand.java
new file mode 100644
index 0000000..60ca1f8
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/addKubernetesHostCommand.java
@@ -0,0 +1,128 @@
+/**
+ *  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.*;
+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.apache.stratos.cli.utils.CliUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+
+/**
+ * Deploy kubernetes host command.
+ */
+public class AddKubernetesHostCommand implements Command<StratosCommandContext> {
+
+    private static final Logger logger = LoggerFactory.getLogger(AddKubernetesHostCommand.class);
+
+    private Options options;
+
+    public AddKubernetesHostCommand() {
+        options = new Options();
+        Option resourcePathOption = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
+                "Kubernetes host resource path");
+        resourcePathOption.setArgName("resource path");
+        Option clusterIdOption = new Option(CliConstants.CLUSTER_ID_OPTION, CliConstants.CLUSTER_ID_LONG_OPTION, true,
+                "Kubernetes cluster id");
+        clusterIdOption.setArgName("cluster id");
+        options.addOption(clusterIdOption);
+        options.addOption(resourcePathOption);
+    }
+
+    @Override
+    public String getName() {
+        return "add-kubernetes-host";
+    }
+
+    @Override
+    public String getDescription() {
+        return "Add kubernetes host";
+    }
+
+    @Override
+    public String getArgumentSyntax() {
+    	return null;
+    }
+
+    @Override
+    public Options getOptions() {
+        return options;
+    }
+
+    @Override
+    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;
+        }
+       			
+        try {
+            CommandLineParser parser = new GnuParser();
+            CommandLine commandLine = parser.parse(options, args);
+            
+            if((commandLine.hasOption(CliConstants.RESOURCE_PATH)) && (commandLine.hasOption(CliConstants.CLUSTER_ID_OPTION))) {
+	               
+                // get cluster id arg value
+            	String clusterId = commandLine.getOptionValue(CliConstants.CLUSTER_ID_OPTION);
+                if (clusterId == null) {
+                    context.getStratosApplication().printUsage(getName());
+                    return CliConstants.COMMAND_FAILED;
+                }
+                
+                // get resource path arg value
+            	String resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
+                if (resourcePath == null) {
+                    context.getStratosApplication().printUsage(getName());
+                    return CliConstants.COMMAND_FAILED;
+                }
+                String resourceFileContent = CliUtils.readResource(resourcePath);
+                
+                RestCommandLineService.getInstance().addKubernetesHost(resourceFileContent, clusterId);
+                return CliConstants.COMMAND_SUCCESSFULL;
+            } else {
+                context.getStratosApplication().printUsage(getName());
+                return CliConstants.COMMAND_FAILED;
+            }
+           
+        } catch (ParseException e) {
+            logger.error("Error parsing arguments", e);
+            System.out.println(e.getMessage());
+            return CliConstants.COMMAND_FAILED;
+        } catch (IOException e) {
+            System.out.println("Invalid resource path");
+            return CliConstants.COMMAND_FAILED;
+        } catch (Exception e) {
+            String message = "Unknown error occurred: " + e.getMessage();
+            System.out.println(message);
+            logger.error(message, e);
+            return CliConstants.COMMAND_FAILED;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/aa503270/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
index 19482c3..b81b601 100644
--- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java
@@ -128,12 +128,12 @@ public class CliConstants {
     /**
      * Autoscaling policy deployment
      */
-    public static final String AUTOSCALING_POLICY_DEPLOYMENT = "deploy-autoscaling-policy";
+    public static final String AUTOSCALING_POLICY_DEPLOYMENT = "add-autoscaling-policy";
 
     /**
      * Deploy, deployment service
      */
-    public static final String DEPLOY_SERVICE_DEPLOYMENT = "deploy-service";
+    public static final String DEPLOY_SERVICE_DEPLOYMENT = "add-service";
 
     /**
      * Deployment policy deployment


[2/3] stratos git commit: Changing TenantInfoBean.createdDate property type to long

Posted by im...@apache.org.
Changing TenantInfoBean.createdDate property type to long


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/7295c88c
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/7295c88c
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/7295c88c

Branch: refs/heads/4.1.0-test
Commit: 7295c88cdebddd610ec3e840adb54c938213a2d8
Parents: cb57686
Author: Imesh Gunaratne <im...@apache.org>
Authored: Wed Dec 17 16:03:17 2014 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Wed Dec 17 16:03:17 2014 +0530

----------------------------------------------------------------------
 .../stratos/common/beans/TenantInfoBean.java    |  8 ++---
 .../rest/endpoint/api/StratosApiV41.java        |  2 +-
 .../util/converter/ObjectConverter.java         | 33 +++++++++++---------
 3 files changed, 23 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/7295c88c/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/TenantInfoBean.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/TenantInfoBean.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/TenantInfoBean.java
index 5b814f8..62923c0 100755
--- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/TenantInfoBean.java
+++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/beans/TenantInfoBean.java
@@ -37,7 +37,7 @@ public class TenantInfoBean {
     private String email;
     private boolean active;
     private String successKey;
-    private Calendar createdDate;
+    private long createdDate;
     private String originatedService;
     private String usagePlan;
 
@@ -56,7 +56,7 @@ public class TenantInfoBean {
         this.email = tenantInfoBean.email;
         this.active = tenantInfoBean.active;
         this.successKey = tenantInfoBean.successKey;
-        this.createdDate = (Calendar)tenantInfoBean.createdDate.clone();
+        this.createdDate = tenantInfoBean.createdDate;
         this.originatedService = tenantInfoBean.originatedService;
         this.usagePlan = tenantInfoBean.usagePlan;
     }
@@ -134,11 +134,11 @@ public class TenantInfoBean {
         this.successKey = successKey;
     }
 
-    public Calendar getCreatedDate() {
+    public long getCreatedDate() {
         return createdDate;
     }
 
-    public void setCreatedDate(Calendar createdDate) {
+    public void setCreatedDate(long createdDate) {
         this.createdDate = createdDate;
     }
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/7295c88c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
index 2e1c7f3..7b3fa48 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java
@@ -702,7 +702,7 @@ public class StratosApiV41 extends AbstractApi {
             tenantId = persistor.persistTenant(tenant, false, tenantInfoBean.getSuccessKey(),
                     tenantInfoBean.getOriginatedService(), false);
         } catch (Exception e) {
-            String msg = "Error in persisting tenant " + tenantDomain;
+            String msg = "Could not add tenant: " + e.getMessage();
             log.error(msg, e);
             throw new RestAPIException(msg);
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/7295c88c/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
index 86bade3..2441715 100644
--- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
+++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/util/converter/ObjectConverter.java
@@ -58,10 +58,7 @@ import org.apache.stratos.messaging.domain.instance.GroupInstance;
 import org.apache.stratos.messaging.domain.topology.Cluster;
 import org.wso2.carbon.stratos.common.beans.TenantInfoBean;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.List;
+import java.util.*;
 
 public class ObjectConverter {
 
@@ -1499,17 +1496,18 @@ public class ObjectConverter {
             return null;
         }
 
-        org.apache.stratos.common.beans.TenantInfoBean stratosTenantInfoBean =
+        org.apache.stratos.common.beans.TenantInfoBean tenantInfoBean =
                 new org.apache.stratos.common.beans.TenantInfoBean();
-        stratosTenantInfoBean.setTenantId(carbonTenantInfoBean.getTenantId());
-        stratosTenantInfoBean.setTenantDomain(carbonTenantInfoBean.getTenantDomain());
-        stratosTenantInfoBean.setActive(carbonTenantInfoBean.isActive());
-        stratosTenantInfoBean.setAdmin(carbonTenantInfoBean.getAdmin());
-        stratosTenantInfoBean.setEmail(carbonTenantInfoBean.getEmail());
-        stratosTenantInfoBean.setFirstname(carbonTenantInfoBean.getFirstname());
-        stratosTenantInfoBean.setLastname(carbonTenantInfoBean.getLastname());
-        stratosTenantInfoBean.setCreatedDate(carbonTenantInfoBean.getCreatedDate());
-        return stratosTenantInfoBean;
+        tenantInfoBean.setTenantId(carbonTenantInfoBean.getTenantId());
+        tenantInfoBean.setTenantDomain(carbonTenantInfoBean.getTenantDomain());
+        tenantInfoBean.setActive(carbonTenantInfoBean.isActive());
+        tenantInfoBean.setAdmin(carbonTenantInfoBean.getAdmin());
+        tenantInfoBean.setEmail(carbonTenantInfoBean.getEmail());
+        tenantInfoBean.setAdminPassword(carbonTenantInfoBean.getAdminPassword());
+        tenantInfoBean.setFirstname(carbonTenantInfoBean.getFirstname());
+        tenantInfoBean.setLastname(carbonTenantInfoBean.getLastname());
+        tenantInfoBean.setCreatedDate(carbonTenantInfoBean.getCreatedDate().getTimeInMillis());
+        return tenantInfoBean;
     }
 
     public static TenantInfoBean convertTenantInfoBeanToCarbonTenantInfoBean(
@@ -1525,9 +1523,14 @@ public class ObjectConverter {
         carbonTenantInfoBean.setActive(tenantInfoBean.isActive());
         carbonTenantInfoBean.setAdmin(tenantInfoBean.getAdmin());
         carbonTenantInfoBean.setEmail(tenantInfoBean.getEmail());
+        carbonTenantInfoBean.setAdminPassword(tenantInfoBean.getAdminPassword());
         carbonTenantInfoBean.setFirstname(tenantInfoBean.getFirstname());
         carbonTenantInfoBean.setLastname(tenantInfoBean.getLastname());
-        carbonTenantInfoBean.setCreatedDate(tenantInfoBean.getCreatedDate());
+        if(tenantInfoBean.getCreatedDate() > 0) {
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTimeInMillis(tenantInfoBean.getCreatedDate());
+            carbonTenantInfoBean.setCreatedDate(calendar);
+        }
         return carbonTenantInfoBean;
     }
 }