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 2015/01/31 04:29:01 UTC
[2/2] stratos git commit: Adding network partitions for CLI
Adding network partitions for CLI
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/52120c9a
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/52120c9a
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/52120c9a
Branch: refs/heads/master
Commit: 52120c9a99280184d62dc3b21e1ee4c1ce641b94
Parents: f2940d0
Author: Dinithi <di...@wso2.com>
Authored: Thu Jan 29 18:34:05 2015 +0530
Committer: Imesh Gunaratne <im...@apache.org>
Committed: Sat Jan 31 08:58:54 2015 +0530
----------------------------------------------------------------------
.../stratos/cli/RestCommandLineService.java | 205 +++--
.../apache/stratos/cli/StratosApplication.java | 873 ++++++++++---------
.../commands/AddNetworkPartitionCommand.java | 174 ++++
.../commands/ListNetworkPartitionCommand.java | 66 ++
.../commands/RemoveNetworkPartitionCommand.java | 72 ++
.../apache/stratos/cli/utils/CliConstants.java | 247 +++---
6 files changed, 1013 insertions(+), 624 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/52120c9a/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 9f602e4..9b966e5 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
@@ -39,14 +39,15 @@ import org.apache.stratos.common.beans.UserInfoBean;
import org.apache.stratos.common.beans.application.ApplicationBean;
import org.apache.stratos.common.beans.application.GroupBean;
import org.apache.stratos.common.beans.application.domain.mapping.DomainMappingBean;
+import org.apache.stratos.common.beans.application.signup.ApplicationSignUpBean;
import org.apache.stratos.common.beans.cartridge.CartridgeBean;
import org.apache.stratos.common.beans.cartridge.IaasProviderBean;
import org.apache.stratos.common.beans.kubernetes.KubernetesClusterBean;
import org.apache.stratos.common.beans.kubernetes.KubernetesHostBean;
+import org.apache.stratos.common.beans.partition.NetworkPartitionBean;
import org.apache.stratos.common.beans.policy.autoscale.AutoscalePolicyBean;
import org.apache.stratos.common.beans.policy.deployment.DeploymentPolicyBean;
import org.apache.stratos.common.beans.topology.ClusterBean;
-import org.apache.stratos.common.beans.application.signup.ApplicationSignUpBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -71,6 +72,7 @@ public class RestCommandLineService {
private static final String ENDPOINT_ADD_TENANT = API_CONTEXT + "/tenants";
private static final String ENDPOINT_ADD_USER = API_CONTEXT + "/users";
private static final String ENDPOINT_ADD_APPLICATION = API_CONTEXT + "/applications";
+ private static final String ENDPOINT_ADD_NETWORK_PARTITION = API_CONTEXT + "/networkPartitions";
private static final String ENDPOINT_DEPLOY_CARTRIDGE = API_CONTEXT + "/cartridges";
private static final String ENDPOINT_DEPLOY_AUTOSCALING_POLICY = API_CONTEXT + "/autoscalingPolicies";
@@ -79,28 +81,30 @@ public class RestCommandLineService {
private static final String ENDPOINT_DEPLOY_KUBERNETES_HOST = API_CONTEXT + "/kubernetesCluster/{kubernetesClusterId}/minion";
private static final String ENDPOINT_DEPLOY_SERVICE_GROUP = API_CONTEXT + "/cartridgeGroups";
private static final String ENDPOINT_DEPLOY_APPLICATION = API_CONTEXT + "/applications/{applicationId}/deploy";
-
+ private static final String ENDPOINT_DEPLOY_NETWORK_PARTITION = API_CONTEXT + "/networkPartitions";
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}";
private static final String ENDPOINT_UNDEPLOY_SERVICE_GROUP = API_CONTEXT + "/cartridgeGroups/{id}";
private static final String ENDPOINT_UNDEPLOY_APPLICATION = API_CONTEXT + "/applications/{id}";
private static final String ENDPOINT_UNDEPLOY_CARTRIDGE = API_CONTEXT + "/cartridges/{id}";
-
+
private static final String ENDPOINT_REMOVE_APPLICATION = API_CONTEXT + "/applications/{appId}";
+ private static final String ENDPOINT_REMOVE_NETWORK_PARTITION = API_CONTEXT + "/networkPartitions/{id}";
- private static final String ENDPOINT_REMOVE_AUTOSCALINGPOLICY = API_CONTEXT + "/autoscalingPolicies/{policyId}";
+ private static final String ENDPOINT_REMOVE_AUTOSCALINGPOLICY = API_CONTEXT + "/autoscalingPolicies/{policyId}";
private static final String ENDPOINT_LIST_AUTOSCALING_POLICIES = API_CONTEXT + "/autoscalingPolicies";
private static final String ENDPOINT_LIST_DEPLOYMENT_POLICIES = API_CONTEXT + "/deploymentPolicies";
private static final String ENDPOINT_LIST_CARTRIDGES = API_CONTEXT + "/cartridges";
- private static final String ENDPOINT_LIST_CARTRIDGE_GROUPS = API_CONTEXT + "/cartridgeGroups";
+ private static final String ENDPOINT_LIST_CARTRIDGE_GROUPS = API_CONTEXT + "/cartridgeGroups";
private static final String ENDPOINT_LIST_TENANTS = API_CONTEXT + "/tenants";
private static final String ENDPOINT_LIST_USERS = API_CONTEXT + "/users";
private static final String ENDPOINT_LIST_KUBERNETES_CLUSTERS = API_CONTEXT + "/kubernetesCluster";
private static final String ENDPOINT_LIST_KUBERNETES_HOSTS = API_CONTEXT + "/kubernetesCluster/{kubernetesClusterId}/hosts";
private static final String ENDPOINT_LIST_SERVICE_GROUP = API_CONTEXT + "/cartridgeGroups/{groupDefinitionName}";
private static final String ENDPOINT_LIST_APPLICATION = API_CONTEXT + "/applications";
+ private static final String ENDPOINT_LIST_NETWORK_PARTITIONS = API_CONTEXT + "/networkPartitions";
private static final String ENDPOINT_DOMAIN_MAPPINGS = API_CONTEXT + "/applications/{applicationId}/domainMappings";
@@ -293,44 +297,44 @@ public class RestCommandLineService {
}
}
- /**
- * List cartridge groups
- *
- * @throws CommandException
- */
- public void listCartridgeGroups() throws CommandException {
- try {
- Type listType = new TypeToken<ArrayList<GroupBean>>() {
- }.getType();
- List<GroupBean> cartridgeGroupList = (List<GroupBean>) restClient.listEntity(ENDPOINT_LIST_CARTRIDGE_GROUPS,
- listType, "Cartridge Groups");
-
- if ((cartridgeGroupList == null) || (cartridgeGroupList.size() == 0)) {
- System.out.println("No cartridges found");
- return;
- }
-
- RowMapper<GroupBean> cartridgeGroupMapper = new RowMapper<GroupBean>() {
- public String[] getData(GroupBean cartridgeGroup) {
- String[] data = new String[4];
- data[0] = cartridgeGroup.getName();
- data[1] = String.valueOf(cartridgeGroup.getCartridges().size());
- data[2] = String.valueOf(cartridgeGroup.getGroups().size());
- data[3] = String.valueOf(cartridgeGroup.isGroupScalingEnabled());
- return data;
- }
- };
-
- GroupBean[] cartridgeGroups = new GroupBean[cartridgeGroupList.size()];
- cartridgeGroups = cartridgeGroupList.toArray(cartridgeGroups);
-
- System.out.println("Cartridge Groups found:");
- CliUtils.printTable(cartridgeGroups, cartridgeGroupMapper, "Name", "No. of Cartridges", "No of Groups", "Dependency scaling");
- } catch (Exception e) {
- String message = "Error in listing cartridge groups";
- printError(message, e);
- }
- }
+ /**
+ * List cartridge groups
+ *
+ * @throws CommandException
+ */
+ public void listCartridgeGroups() throws CommandException {
+ try {
+ Type listType = new TypeToken<ArrayList<GroupBean>>() {
+ }.getType();
+ List<GroupBean> cartridgeGroupList = (List<GroupBean>) restClient.listEntity(ENDPOINT_LIST_CARTRIDGE_GROUPS,
+ listType, "Cartridge Groups");
+
+ if ((cartridgeGroupList == null) || (cartridgeGroupList.size() == 0)) {
+ System.out.println("No cartridges found");
+ return;
+ }
+
+ RowMapper<GroupBean> cartridgeGroupMapper = new RowMapper<GroupBean>() {
+ public String[] getData(GroupBean cartridgeGroup) {
+ String[] data = new String[4];
+ data[0] = cartridgeGroup.getName();
+ data[1] = String.valueOf(cartridgeGroup.getCartridges().size());
+ data[2] = String.valueOf(cartridgeGroup.getGroups().size());
+ data[3] = String.valueOf(cartridgeGroup.isGroupScalingEnabled());
+ return data;
+ }
+ };
+
+ GroupBean[] cartridgeGroups = new GroupBean[cartridgeGroupList.size()];
+ cartridgeGroups = cartridgeGroupList.toArray(cartridgeGroups);
+
+ System.out.println("Cartridge Groups found:");
+ CliUtils.printTable(cartridgeGroups, cartridgeGroupMapper, "Name", "No. of Cartridges", "No of Groups", "Dependency scaling");
+ } catch (Exception e) {
+ String message = "Error in listing cartridge groups";
+ printError(message, e);
+ }
+ }
/**
* Describe a cartridge
* @param cartridgeType
@@ -668,10 +672,10 @@ public class RestCommandLineService {
restClient.deployEntity(ENDPOINT_DEPLOY_CARTRIDGE, cartridgeDefinition, "cartridge");
}
- // This method helps to update cartridge definitions
- public void updateCartridge(String cartridgeDefinition) throws CommandException {
- restClient.updateEntity(ENDPOINT_DEPLOY_CARTRIDGE, cartridgeDefinition, "cartridge");
- }
+ // This method helps to update cartridge definitions
+ public void updateCartridge(String cartridgeDefinition) throws CommandException {
+ restClient.updateEntity(ENDPOINT_DEPLOY_CARTRIDGE, cartridgeDefinition, "cartridge");
+ }
// This method helps to undeploy cartridge definitions
public void undeployCartrigdeDefinition(String id) throws CommandException {
@@ -683,7 +687,7 @@ public class RestCommandLineService {
restClient.deployEntity(ENDPOINT_DEPLOY_AUTOSCALING_POLICY, autoScalingPolicy, "autoscaling policy");
}
- // This method helps to update an autoscaling policy
+ // This method helps to update an autoscaling policy
public void updateAutoscalingPolicy(String autoScalingPolicy) throws CommandException {
restClient.updateEntity(ENDPOINT_UPDATE_AUTOSCALING_POLICY, autoScalingPolicy, "autoscaling policy");
}
@@ -762,17 +766,17 @@ public class RestCommandLineService {
DeploymentPolicyBean policy = (DeploymentPolicyBean) restClient.getEntity(ENDPOINT_GET_DEPLOYMENT_POLICY,
DeploymentPolicyBean.class, "{applicationId}", applicationId, "deployment policy");
- if (policy == null) {
- System.out.println("Deployment policy not found: " + applicationId);
- return;
- }
-
- System.out.println("Deployment policy: " + applicationId);
- System.out.println(getGson().toJson(policy));
- } catch (Exception e) {
- String message = "Error in describing deployment policy: " + applicationId;
- printError(message, e);
- }
+ if (policy == null) {
+ System.out.println("Deployment policy not found: " + applicationId);
+ return;
+ }
+
+ System.out.println("Deployment policy: " + applicationId);
+ System.out.println(getGson().toJson(policy));
+ } catch (Exception e) {
+ String message = "Error in describing deployment policy: " + applicationId;
+ printError(message, e);
+ }
}
public void describeAutoScalingPolicy(String id) throws CommandException {
@@ -937,12 +941,12 @@ public class RestCommandLineService {
}
public void updateKubernetesMaster(String entityBody, String clusterId) {
- System.out.println(ENDPOINT_UPDATE_KUBERNETES_MASTER.replace("{kubernetesClusterId}", clusterId));
+ System.out.println(ENDPOINT_UPDATE_KUBERNETES_MASTER.replace("{kubernetesClusterId}", clusterId));
restClient.updateEntity(ENDPOINT_UPDATE_KUBERNETES_MASTER.replace("{kubernetesClusterId}", clusterId), entityBody, "kubernetes master");
}
public void updateKubernetesHost(String entityBody, String clusterId, String hostId) {
- System.out.println((ENDPOINT_UPDATE_KUBERNETES_HOST.replace("{kubernetesClusterId}", clusterId)).replace("{minionId}", hostId));
+ System.out.println((ENDPOINT_UPDATE_KUBERNETES_HOST.replace("{kubernetesClusterId}", clusterId)).replace("{minionId}", hostId));
restClient.updateEntity((ENDPOINT_UPDATE_KUBERNETES_HOST.replace("{kubernetesClusterId}", clusterId)).replace("{minionId}", hostId), entityBody, "kubernetes host");
}
@@ -1004,7 +1008,7 @@ public class RestCommandLineService {
public void addApplication (String entityBody) {
restClient.deployEntity(ENDPOINT_ADD_APPLICATION, entityBody, "application");
}
-
+
// This method helps to deploy applications
public void deployApplication (String applicationId, String entityBody) {
restClient.deployEntity(ENDPOINT_DEPLOY_APPLICATION.replace("{applicationId}", applicationId), entityBody,
@@ -1013,7 +1017,7 @@ public class RestCommandLineService {
// This method helps to undeploy applications
public void undeployApplication(String applicationId) throws CommandException {
- DefaultHttpClient httpClient = new DefaultHttpClient();
+ DefaultHttpClient httpClient = new DefaultHttpClient();
try {
HttpResponse response = restClient.doPost(httpClient, restClient.getBaseURL()
+ ENDPOINT_UNDEPLOY_APPLICATION + "/" + applicationId, "");
@@ -1039,17 +1043,17 @@ public class RestCommandLineService {
httpClient.getConnectionManager().shutdown();
}
}
-
+
// This method helps to remove applications
public void deleteApplication (String applicationId) {
restClient.deleteEntity(ENDPOINT_REMOVE_APPLICATION.replace("{applicationId}", applicationId), applicationId,
"application");
}
- public void deleteAutoSclaingPolicy(String policyId) {
- restClient.deleteEntity(ENDPOINT_REMOVE_AUTOSCALINGPOLICY.replace("{policyId}", policyId), policyId,
- "Auto-scaling policy");
- }
+ public void deleteAutoSclaingPolicy(String policyId) {
+ restClient.deleteEntity(ENDPOINT_REMOVE_AUTOSCALINGPOLICY.replace("{policyId}", policyId), policyId,
+ "Auto-scaling policy");
+ }
// This method helps to describe an application
public void describeApplication (String applicationID) {
@@ -1077,12 +1081,12 @@ public class RestCommandLineService {
public void addApplicationSignup (String entityBody, String applicationId) {
restClient.deployEntity(ENDPOINT_APPLICATION_SIGNUP.replace("{applicationId}", applicationId), entityBody, "application");
}
-
+
// This method helps to describe application signup
public void describeApplicationSignup (String applicationId) {
try {
- ApplicationSignUpBean bean = (ApplicationSignUpBean) restClient.listEntity(ENDPOINT_APPLICATION_SIGNUP.replace("{applicationId}", applicationId),
- ApplicationSignUpBean.class, "applicationSignup");
+ ApplicationSignUpBean bean = (ApplicationSignUpBean) restClient.listEntity(ENDPOINT_APPLICATION_SIGNUP.replace("{applicationId}", applicationId),
+ ApplicationSignUpBean.class, "applicationSignup");
if (bean == null) {
System.out.println("Applicationsign up not found for application: " + applicationId);
@@ -1096,13 +1100,13 @@ public class RestCommandLineService {
printError(message, e);
}
}
-
+
// This method helps to remove application signup
public void deleteApplicationSignup (String applicationId) {
restClient.deleteEntity(ENDPOINT_APPLICATION_SIGNUP.replace("{applicationId}", applicationId), applicationId,
"application signup");
}
-
+
// This is for handle exception
private void handleException(String key, Exception e, Object... args) throws CommandException {
if (log.isDebugEnabled()) {
@@ -1118,7 +1122,7 @@ public class RestCommandLineService {
System.out.println(message);
throw new CommandException(message, e);
}
-
+
/**
* Print error on console and log
* @param message
@@ -1130,4 +1134,57 @@ public class RestCommandLineService {
// Log error
log.error(message, e);
}
+
+ // This method helps to add network partition definitions
+ public void addNetworkPartition(String networkPartitionDefinition) throws CommandException {
+ restClient.deployEntity(ENDPOINT_DEPLOY_NETWORK_PARTITION, networkPartitionDefinition, "network partition");
+ }
+
+ // This method helps to remove network partitions
+ public void removeNetworkPartition (String id) {
+ restClient.deleteEntity(ENDPOINT_REMOVE_NETWORK_PARTITION.replace("{networkPartitionId}", id), id,
+ "network-partition");
+ }
+
+ /**
+ * List network partitions
+ * @throws CommandException
+ */
+ public void listNetworkPartitions() throws CommandException {
+ try {
+ Type listType = new TypeToken<ArrayList<NetworkPartitionBean>>() {
+ }.getType();
+ List<NetworkPartitionBean> networkPartitionsList = (List<NetworkPartitionBean>) restClient.listEntity(ENDPOINT_LIST_NETWORK_PARTITIONS,
+ listType, "network-partitions");
+
+ if ((networkPartitionsList == null) || (networkPartitionsList.size() == 0)) {
+ System.out.println("No network partitions found");
+ return;
+ }
+
+ RowMapper<NetworkPartitionBean> networkPartitionMapper = new RowMapper<NetworkPartitionBean>() {
+ public String[] getData(NetworkPartitionBean partition) {
+ String[] data = new String[3];
+ data[0] = partition.getId();
+ data[1] = (partition.getKubernetesClusterId() != null) ? partition.getKubernetesClusterId() : "";
+ data[2] = String.valueOf(partition.getPartitions().size());;
+ return data;
+ }
+ };
+
+ NetworkPartitionBean[] partitions = new NetworkPartitionBean[networkPartitionsList.size()];
+ partitions = networkPartitionsList.toArray(partitions);
+
+ System.out.println("Network partitions found:");
+ CliUtils.printTable(partitions, networkPartitionMapper, "PartitionId", "Kubernetes Cluster Id", "Partitions");
+ } catch (Exception e) {
+ String message = "Error in listing network partitions" + e;
+ printError(message, e);
+ }
+ }
+
+ // This method helps to update network partition definitions
+ public void updateNetworkPartition(String partitionDefinition) throws CommandException {
+ restClient.updateEntity(ENDPOINT_DEPLOY_NETWORK_PARTITION, partitionDefinition, "network-partition");
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/52120c9a/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 5f56669..91b0ee3 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
@@ -43,55 +43,55 @@ import static org.apache.stratos.cli.utils.CliConstants.STRATOS_HISTORY_DIR;
public class StratosApplication extends CommandLineApplication<StratosCommandContext> {
- private static final Logger logger = LoggerFactory.getLogger(StratosApplication.class);
+ private static final Logger logger = LoggerFactory.getLogger(StratosApplication.class);
- private final Map<String, Command<StratosCommandContext>> commands;
- private final StratosCommandContext context;
+ private final Map<String, Command<StratosCommandContext>> commands;
+ private final StratosCommandContext context;
- private final Options options;
+ private final Options options;
- public StratosApplication(String[] args) {
+ public StratosApplication(String[] args) {
super(args);
- commands = new TreeMap<String, Command<StratosCommandContext>>();
- context = new StratosCommandContext(this);
-
- options = constructOptions();
-
- createCommands();
- }
-
- /**
- * Construct Options.
- *
- * @return Options expected from command-line.
- */
- private Options constructOptions() {
- final Options options = new Options();
- Option usernameOption = new Option(CliConstants.USERNAME_OPTION, CliConstants.USERNAME_LONG_OPTION, true,
- "Username");
- usernameOption.setArgName("username");
- options.addOption(usernameOption);
-
- Option passwordOption = new Option(CliConstants.PASSWORD_OPTION, CliConstants.PASSWORD_LONG_OPTION, true,
- "Password");
- passwordOption.setArgName("password");
- passwordOption.setOptionalArg(true);
- options.addOption(passwordOption);
- options.addOption(CliConstants.HELP_OPTION, CliConstants.HELP_LONG_OPTION, false, "Display this help");
- options.addOption(CliConstants.TRACE_OPTION, false, "Enable trace logging");
- options.addOption(CliConstants.DEBUG_OPTION, false, "Enable debug logging");
- return options;
- }
-
- private void createCommands() {
- Command<StratosCommandContext> command = new HelpCommand();
- commands.put(command.getName(), command);
-
- command = new ExitCommand();
- commands.put(command.getName(), command);
-
- command = new ListCartridgesCommand();
- commands.put(command.getName(), command);
+ commands = new TreeMap<String, Command<StratosCommandContext>>();
+ context = new StratosCommandContext(this);
+
+ options = constructOptions();
+
+ createCommands();
+ }
+
+ /**
+ * Construct Options.
+ *
+ * @return Options expected from command-line.
+ */
+ private Options constructOptions() {
+ final Options options = new Options();
+ Option usernameOption = new Option(CliConstants.USERNAME_OPTION, CliConstants.USERNAME_LONG_OPTION, true,
+ "Username");
+ usernameOption.setArgName("username");
+ options.addOption(usernameOption);
+
+ Option passwordOption = new Option(CliConstants.PASSWORD_OPTION, CliConstants.PASSWORD_LONG_OPTION, true,
+ "Password");
+ passwordOption.setArgName("password");
+ passwordOption.setOptionalArg(true);
+ options.addOption(passwordOption);
+ options.addOption(CliConstants.HELP_OPTION, CliConstants.HELP_LONG_OPTION, false, "Display this help");
+ options.addOption(CliConstants.TRACE_OPTION, false, "Enable trace logging");
+ options.addOption(CliConstants.DEBUG_OPTION, false, "Enable debug logging");
+ return options;
+ }
+
+ private void createCommands() {
+ Command<StratosCommandContext> command = new HelpCommand();
+ commands.put(command.getName(), command);
+
+ command = new ExitCommand();
+ commands.put(command.getName(), command);
+
+ command = new ListCartridgesCommand();
+ commands.put(command.getName(), command);
command = new AddTenantCommand();
commands.put(command.getName(), command);
@@ -117,14 +117,14 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
command = new AddCartridgeCommand();
commands.put(command.getName(), command);
- command = new UpdateCartridgeCommand();
- commands.put(command.getName(), command);
+ command = new UpdateCartridgeCommand();
+ commands.put(command.getName(), command);
command = new AddAutoscalingPolicyCommand();
commands.put(command.getName(), command);
- command = new CreateApplicationCommand();
- commands.put(command.getName(), command);
+ command = new CreateApplicationCommand();
+ commands.put(command.getName(), command);
command = new ListApplicationsCommand();
commands.put(command.getName(), command);
@@ -143,9 +143,9 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
command = new DescribeAutoScalingPolicyCommand();
commands.put(command.getName(), command);
-
- command = new SynchronizeArtifactsCommand();
- commands.put(command.getName(), command);
+
+ command = new SynchronizeArtifactsCommand();
+ commands.put(command.getName(), command);
command = new AddKubernetesClusterCommand();
commands.put(command.getName(), command);
@@ -177,8 +177,8 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
command = new DescribeCartridgeGroupCommand();
commands.put(command.getName(), command);
- command = new ListCartridgeGroupsCommand();
- commands.put(command.getName(), command);
+ command = new ListCartridgeGroupsCommand();
+ commands.put(command.getName(), command);
command = new RemoveCartridgeGroupCommand();
commands.put(command.getName(), command);
@@ -192,202 +192,211 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
command = new DescribeApplicationCommand();
commands.put(command.getName(), command);
- command = new AddDomainMappingsCommand();
- commands.put(command.getName(), command);
+ command = new AddDomainMappingsCommand();
+ commands.put(command.getName(), command);
+
+ command = new ListDomainMappingsCommand();
+ commands.put(command.getName(), command);
+
+ command = new RemoveDomainMappingsCommand();
+ commands.put(command.getName(), command);
+
+ command=new DeleteAutoScalingPolicyCommand();
+ commands.put(command.getName(), command);
- command = new ListDomainMappingsCommand();
- commands.put(command.getName(), command);
+ command=new AddNetworkPartitionCommand();
+ commands.put(command.getName(), command);
- command = new RemoveDomainMappingsCommand();
- commands.put(command.getName(), command);
+ command=new RemoveNetworkPartitionCommand();
+ commands.put(command.getName(), command);
- command=new DeleteAutoScalingPolicyCommand();
- commands.put(command.getName(), command);
+ command = new ListNetworkPartitionCommand();
+ commands.put(command.getName(), command);
if (logger.isDebugEnabled()) {
- logger.debug("Created {} commands for the application. {}", commands.size(), commands.keySet());
- }
- }
-
- private void createAutocomplete() {
- reader.addCompleter(new CommandCompleter(commands));
- }
-
- @Override
- protected String getPrompt() {
- return CliConstants.STRATOS_SHELL_PROMPT;
- }
-
- @Override
- protected File getHistoryFile(String username) {
- File stratosFile = new File(System.getProperty("user.home"), STRATOS_DIR);
- File historyFile = new File(stratosFile, STRATOS_HISTORY_DIR + "_" + username);
- return historyFile;
- }
-
- @Override
- public int run(String[] args) {
- boolean loaded = loadRequiredProperties();
- if (!loaded) {
- return CliConstants.ERROR_CODE;
- }
-
- // To get the command action from arguments
- String[] remainingArgs = null;
-
- // Command action
- String action = null;
-
- String usernameInput = null;
- String passwordInput = null;
-
- if (args != null && args.length > 0) {
- // Arguments are passed.
- if (logger.isDebugEnabled()) {
- logger.debug("Arguments:");
- for (String arg : args) {
- logger.debug(arg);
- }
- }
-
- final CommandLineParser parser = new GnuParser();
- CommandLine commandLine;
- try {
- // Must add all options. Otherwise actions cannot be performed directly by command line.
- Options allCommandOptions = new Options();
- for (Command<StratosCommandContext> command : commands.values()) {
- Options commandOptions = command.getOptions();
- if (commandOptions != null) {
- Collection<?> allOptions = commandOptions.getOptions();
- for (Object o : allOptions) {
- allCommandOptions.addOption((Option) o);
- }
- }
- }
- // Add options in this application
- Collection<?> allOptions = options.getOptions();
- for (Object o : allOptions) {
- allCommandOptions.addOption((Option) o);
- }
-
- commandLine = parser.parse(options, args, true);
- remainingArgs = commandLine.getArgs();
- if (remainingArgs != null && remainingArgs.length > 0) {
- // Get command action
- action = remainingArgs[0];
- }
-
- // Set logger levels from this point onwards
- setLoggerLevel(commandLine.hasOption(CliConstants.TRACE_OPTION),
- commandLine.hasOption(CliConstants.DEBUG_OPTION));
-
- if (commandLine.hasOption(CliConstants.USERNAME_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Username option is passed");
- }
- usernameInput = commandLine.getOptionValue(CliConstants.USERNAME_OPTION);
- }
- if (commandLine.hasOption(CliConstants.PASSWORD_OPTION)) {
- if (logger.isTraceEnabled()) {
- logger.trace("Password option is passed");
- }
- passwordInput = commandLine.getOptionValue(CliConstants.PASSWORD_OPTION);
- }
- if (commandLine.hasOption(CliConstants.HELP_ACTION)) {
- printHelp();
- return CliConstants.COMMAND_SUCCESSFULL;
- }
- } catch (ParseException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error parsing arguments when trying to login", e);
- }
- System.out.println(e.getMessage());
- return CliConstants.COMMAND_FAILED;
- }
-
- }
-
- if (StringUtils.isNotBlank(action)) {
- // User is executing an action
- if (logger.isDebugEnabled()) {
- logger.debug("Action: {}", action);
- }
- Command<StratosCommandContext> command = commands.get(action);
- if (command == null) {
- printHelp();
- return CliConstants.COMMAND_FAILED;
- }
-
- boolean loginRequired = !CliConstants.HELP_ACTION.equals(action);
-
- if (loginRequired && logger.isDebugEnabled()) {
- logger.debug("Trying to login...");
- }
-
- if (loginRequired && !login(usernameInput, passwordInput, false)) {
- if (logger.isDebugEnabled()) {
- logger.debug("Exiting from CLI. Login required but login might have failed: {}", action);
- }
- // Exit
- return CliConstants.ERROR_CODE;
- }
-
- try {
- String[] actionArgs = Arrays.copyOfRange(remainingArgs, 1, remainingArgs.length);
- if (logger.isDebugEnabled()) {
- logger.debug("Executing Action: {} {}", action, Arrays.asList(actionArgs));
- }
- int returnCode = command.execute(context, actionArgs);
- if (logger.isDebugEnabled()) {
- logger.debug("Exiting with error code {} after executing action {}", returnCode, action);
- }
- System.exit(returnCode);
- } catch (CommandException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error executing command: " + action, e);
- }
- return CliConstants.ERROR_CODE;
- }
- } else {
- if (login(usernameInput, passwordInput, true)) {
- System.out.println("Successfully authenticated");
- } else {
- // Exit
- return CliConstants.ERROR_CODE;
- }
-
- promptLoop();
- }
- return CliConstants.COMMAND_SUCCESSFULL;
- }
-
- private boolean login(String usernameInput, String passwordInput, boolean validateLogin) {
- // TODO Previous CLI version uses a keystore. Here we are not using it.
- // Check whether user has passed username and password
- if (StringUtils.isBlank(usernameInput) && StringUtils.isBlank(passwordInput)) {
- // User has not passed any arguments.
- // Try authenticating from the values found
- usernameInput = context.getString(CliConstants.STRATOS_USERNAME_ENV_PROPERTY);
- passwordInput = context.getString(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY);
-
- if (logger.isDebugEnabled()) {
- if (StringUtils.isNotBlank(usernameInput) && StringUtils.isNotBlank(passwordInput)) {
- logger.debug("Found authentication details for {} from context", usernameInput);
- }
- }
-
- }
- // Get user input if not passed as args
- if (StringUtils.isBlank(usernameInput)) {
- usernameInput = getInput("Username");
- }
- if (StringUtils.isBlank(passwordInput)) {
- passwordInput = getInput("Password", '*');
- }
-
- boolean success = false;
- String stratosURL = null;
- stratosURL = context.getString(CliConstants.STRATOS_URL_ENV_PROPERTY);
+ logger.debug("Created {} commands for the application. {}", commands.size(), commands.keySet());
+ }
+ }
+
+ private void createAutocomplete() {
+ reader.addCompleter(new CommandCompleter(commands));
+ }
+
+ @Override
+ protected String getPrompt() {
+ return CliConstants.STRATOS_SHELL_PROMPT;
+ }
+
+ @Override
+ protected File getHistoryFile(String username) {
+ File stratosFile = new File(System.getProperty("user.home"), STRATOS_DIR);
+ File historyFile = new File(stratosFile, STRATOS_HISTORY_DIR + "_" + username);
+ return historyFile;
+ }
+
+ @Override
+ public int run(String[] args) {
+ boolean loaded = loadRequiredProperties();
+ if (!loaded) {
+ return CliConstants.ERROR_CODE;
+ }
+
+ // To get the command action from arguments
+ String[] remainingArgs = null;
+
+ // Command action
+ String action = null;
+
+ String usernameInput = null;
+ String passwordInput = null;
+
+ if (args != null && args.length > 0) {
+ // Arguments are passed.
+ if (logger.isDebugEnabled()) {
+ logger.debug("Arguments:");
+ for (String arg : args) {
+ logger.debug(arg);
+ }
+ }
+
+ final CommandLineParser parser = new GnuParser();
+ CommandLine commandLine;
+ try {
+ // Must add all options. Otherwise actions cannot be performed directly by command line.
+ Options allCommandOptions = new Options();
+ for (Command<StratosCommandContext> command : commands.values()) {
+ Options commandOptions = command.getOptions();
+ if (commandOptions != null) {
+ Collection<?> allOptions = commandOptions.getOptions();
+ for (Object o : allOptions) {
+ allCommandOptions.addOption((Option) o);
+ }
+ }
+ }
+ // Add options in this application
+ Collection<?> allOptions = options.getOptions();
+ for (Object o : allOptions) {
+ allCommandOptions.addOption((Option) o);
+ }
+
+ commandLine = parser.parse(options, args, true);
+ remainingArgs = commandLine.getArgs();
+ if (remainingArgs != null && remainingArgs.length > 0) {
+ // Get command action
+ action = remainingArgs[0];
+ }
+
+ // Set logger levels from this point onwards
+ setLoggerLevel(commandLine.hasOption(CliConstants.TRACE_OPTION),
+ commandLine.hasOption(CliConstants.DEBUG_OPTION));
+
+ if (commandLine.hasOption(CliConstants.USERNAME_OPTION)) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Username option is passed");
+ }
+ usernameInput = commandLine.getOptionValue(CliConstants.USERNAME_OPTION);
+ }
+ if (commandLine.hasOption(CliConstants.PASSWORD_OPTION)) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Password option is passed");
+ }
+ passwordInput = commandLine.getOptionValue(CliConstants.PASSWORD_OPTION);
+ }
+ if (commandLine.hasOption(CliConstants.HELP_ACTION)) {
+ printHelp();
+ return CliConstants.COMMAND_SUCCESSFULL;
+ }
+ } catch (ParseException e) {
+ if (logger.isErrorEnabled()) {
+ logger.error("Error parsing arguments when trying to login", e);
+ }
+ System.out.println(e.getMessage());
+ return CliConstants.COMMAND_FAILED;
+ }
+
+ }
+
+ if (StringUtils.isNotBlank(action)) {
+ // User is executing an action
+ if (logger.isDebugEnabled()) {
+ logger.debug("Action: {}", action);
+ }
+ Command<StratosCommandContext> command = commands.get(action);
+ if (command == null) {
+ printHelp();
+ return CliConstants.COMMAND_FAILED;
+ }
+
+ boolean loginRequired = !CliConstants.HELP_ACTION.equals(action);
+
+ if (loginRequired && logger.isDebugEnabled()) {
+ logger.debug("Trying to login...");
+ }
+
+ if (loginRequired && !login(usernameInput, passwordInput, false)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Exiting from CLI. Login required but login might have failed: {}", action);
+ }
+ // Exit
+ return CliConstants.ERROR_CODE;
+ }
+
+ try {
+ String[] actionArgs = Arrays.copyOfRange(remainingArgs, 1, remainingArgs.length);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Executing Action: {} {}", action, Arrays.asList(actionArgs));
+ }
+ int returnCode = command.execute(context, actionArgs);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Exiting with error code {} after executing action {}", returnCode, action);
+ }
+ System.exit(returnCode);
+ } catch (CommandException e) {
+ if (logger.isErrorEnabled()) {
+ logger.error("Error executing command: " + action, e);
+ }
+ return CliConstants.ERROR_CODE;
+ }
+ } else {
+ if (login(usernameInput, passwordInput, true)) {
+ System.out.println("Successfully authenticated");
+ } else {
+ // Exit
+ return CliConstants.ERROR_CODE;
+ }
+
+ promptLoop();
+ }
+ return CliConstants.COMMAND_SUCCESSFULL;
+ }
+
+ private boolean login(String usernameInput, String passwordInput, boolean validateLogin) {
+ // TODO Previous CLI version uses a keystore. Here we are not using it.
+ // Check whether user has passed username and password
+ if (StringUtils.isBlank(usernameInput) && StringUtils.isBlank(passwordInput)) {
+ // User has not passed any arguments.
+ // Try authenticating from the values found
+ usernameInput = context.getString(CliConstants.STRATOS_USERNAME_ENV_PROPERTY);
+ passwordInput = context.getString(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY);
+
+ if (logger.isDebugEnabled()) {
+ if (StringUtils.isNotBlank(usernameInput) && StringUtils.isNotBlank(passwordInput)) {
+ logger.debug("Found authentication details for {} from context", usernameInput);
+ }
+ }
+
+ }
+ // Get user input if not passed as args
+ if (StringUtils.isBlank(usernameInput)) {
+ usernameInput = getInput("Username");
+ }
+ if (StringUtils.isBlank(passwordInput)) {
+ passwordInput = getInput("Password", '*');
+ }
+
+ boolean success = false;
+ String stratosURL = null;
+ stratosURL = context.getString(CliConstants.STRATOS_URL_ENV_PROPERTY);
// This is to create the history file.
// This section execute only when user didn't enter the username as command line arguments
@@ -398,193 +407,193 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon
createAutocomplete();
- try {
+ try {
success = RestCommandLineService.getInstance().login(stratosURL, usernameInput, passwordInput, validateLogin);
- } catch (Exception e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error when trying to login", e);
- }
- }
- if (success) {
- if (logger.isDebugEnabled()) {
- logger.debug("Successfully authenticated");
- }
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("Authentication failed.");
- }
- }
- return success;
- }
-
- @Override
- protected int executeCommand(String line) {
- String[] tokens = new StrTokenizer(line).getTokenArray();
- String action = tokens[0];
- String[] actionArgs = Arrays.copyOfRange(tokens, 1, tokens.length);
- if (logger.isDebugEnabled()) {
- logger.debug("Executing command action: {}, Tokens: {}", action, tokens.length);
- }
- Command<StratosCommandContext> command = commands.get(action);
- if (command == null) {
- System.out.println(action + ": command not found.");
- return CliConstants.COMMAND_FAILED;
- }
- try {
- return command.execute(context, actionArgs);
- } catch (CommandException e) {
- if (logger.isErrorEnabled()) {
- logger.error("Error executing command: " + action, e);
- }
- return CliConstants.ERROR_CODE;
- }
- }
-
- /**
- * @return {@code true} if required properties are loaded
- */
- private boolean loadRequiredProperties() {
- if (logger.isDebugEnabled()) {
- logger.debug("Loading properties...");
- }
- // Load properties
- String stratosURL = null;
- String username = null;
- String password = null;
-
- stratosURL = System.getenv(CliConstants.STRATOS_URL_ENV_PROPERTY);
- username = System.getenv(CliConstants.STRATOS_USERNAME_ENV_PROPERTY);
- password = System.getenv(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY);
-
- if (StringUtils.isBlank(stratosURL)) {
- if (logger.isDebugEnabled()) {
- logger.debug("Required configuration not found.");
- }
- // Stratos Controller details are not set.
- System.out.format("Could not find required \"%s\" variable in your environment.%n",
- CliConstants.STRATOS_URL_ENV_PROPERTY);
- return false;
- }
-
- if (logger.isDebugEnabled()) {
- logger.debug("Required configuration found. Validating {}", stratosURL);
- }
-
- int slashCount = StringUtils.countMatches(stratosURL, "/");
- int colonCount = StringUtils.countMatches(stratosURL, ":");
-
- UrlValidator urlValidator = new UrlValidator(new String[] { "https" },UrlValidator.ALLOW_LOCAL_URLS);
-
- // port must be provided, so colonCount must be 2
- // context path must not be provided, so slashCount must not be >3
-
- if (!urlValidator.isValid(stratosURL) || colonCount != 2 || slashCount >3) {
- if (logger.isDebugEnabled()) {
- logger.debug("Stratos Controller URL {} is not valid", stratosURL);
- }
- System.out.format(
- "The \"%s\" variable in your environment is not a valid URL. You have provided \"%s\".%n"
- + "Please provide the Stratos Controller URL as follows%nhttps://<host>:<port>%n",
- CliConstants.STRATOS_URL_ENV_PROPERTY, stratosURL);
- return false;
- }
- if (logger.isDebugEnabled()) {
- logger.debug("Stratos Controller URL {} is valid.", stratosURL);
- logger.debug("Adding the values to context.");
- }
- context.put(CliConstants.STRATOS_URL_ENV_PROPERTY, stratosURL);
- context.put(CliConstants.STRATOS_USERNAME_ENV_PROPERTY, username);
- context.put(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY, password);
- return true;
- }
-
- private void setLoggerLevel(boolean trace, boolean debug) {
- // We are using Log4j. So, get the logger and set log levels.
- org.apache.log4j.Logger logger = LogManager.getLogger(StratosApplication.class.getPackage().getName());
- if (logger != null && trace) {
- logger.setLevel(Level.TRACE);
- LogManager.getRootLogger().setLevel(Level.TRACE);
- } else if (logger != null && debug) {
- logger.setLevel(Level.DEBUG);
- LogManager.getRootLogger().setLevel(Level.DEBUG);
- }
- }
-
- public void printHelp(final String action) {
- Command<StratosCommandContext> command = commands.get(action);
- if (command == null) {
- System.out.println(action + ": command not found. Help not available.");
- return;
- }
- System.out.println(command.getDescription());
- Options options = command.getOptions();
- if (options != null) {
- if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
- printHelp(command.getName() + " " + command.getArgumentSyntax(), options);
- } else {
- printHelp(command.getName(), options);
- }
- } else {
- // No options. Just print the usage.
- printUsage(command);
- }
- }
-
- public void printHelp() {
- printHelp(CliConstants.STRATOS_APPLICATION_NAME, options);
- System.out.println("\n\nAvailable Commands: ");
- for (String action : commands.keySet()) {
- Command<StratosCommandContext> command = commands.get(action);
- if (command != null) {
- System.out.format("%-35s %s%n", command.getName(), command.getDescription());
- }
- }
-
- System.out.println("\nFor help on a specific command type:\nhelp [command]");
- }
-
- /**
- * Print "help" with usage
- */
- private void printHelp(final String commandLineSyntax, final Options options) {
- final HelpFormatter helpFormatter = new HelpFormatter();
- helpFormatter.printHelp(commandLineSyntax, options, true);
- }
-
- public void printUsage(final String action) {
- Command<StratosCommandContext> command = commands.get(action);
- if (command == null) {
- return;
- }
- printUsage(command);
- }
-
- private void printUsage(Command<StratosCommandContext> command) {
- Options options = command.getOptions();
- if (options != null) {
- if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
- printUsage(command.getName() + " " + command.getArgumentSyntax(), options);
- } else {
- printUsage(command.getName(), options);
- }
- } else {
- System.out.print("usage: ");
- if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
- System.out.println(command.getName() + " " + command.getArgumentSyntax());
- } else {
- System.out.println(command.getName());
- }
- }
- }
-
- /**
- * Print "usage"
- */
- private void printUsage(final String commandLineSyntax, final Options options) {
- final PrintWriter writer = new PrintWriter(System.out);
- final HelpFormatter usageFormatter = new HelpFormatter();
- usageFormatter.printUsage(writer, 80, commandLineSyntax, options);
- writer.flush();
- }
+ } catch (Exception e) {
+ if (logger.isErrorEnabled()) {
+ logger.error("Error when trying to login", e);
+ }
+ }
+ if (success) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Successfully authenticated");
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Authentication failed.");
+ }
+ }
+ return success;
+ }
+
+ @Override
+ protected int executeCommand(String line) {
+ String[] tokens = new StrTokenizer(line).getTokenArray();
+ String action = tokens[0];
+ String[] actionArgs = Arrays.copyOfRange(tokens, 1, tokens.length);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Executing command action: {}, Tokens: {}", action, tokens.length);
+ }
+ Command<StratosCommandContext> command = commands.get(action);
+ if (command == null) {
+ System.out.println(action + ": command not found.");
+ return CliConstants.COMMAND_FAILED;
+ }
+ try {
+ return command.execute(context, actionArgs);
+ } catch (CommandException e) {
+ if (logger.isErrorEnabled()) {
+ logger.error("Error executing command: " + action, e);
+ }
+ return CliConstants.ERROR_CODE;
+ }
+ }
+
+ /**
+ * @return {@code true} if required properties are loaded
+ */
+ private boolean loadRequiredProperties() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Loading properties...");
+ }
+ // Load properties
+ String stratosURL = null;
+ String username = null;
+ String password = null;
+
+ stratosURL = System.getenv(CliConstants.STRATOS_URL_ENV_PROPERTY);
+ username = System.getenv(CliConstants.STRATOS_USERNAME_ENV_PROPERTY);
+ password = System.getenv(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY);
+
+ if (StringUtils.isBlank(stratosURL)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Required configuration not found.");
+ }
+ // Stratos Controller details are not set.
+ System.out.format("Could not find required \"%s\" variable in your environment.%n",
+ CliConstants.STRATOS_URL_ENV_PROPERTY);
+ return false;
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Required configuration found. Validating {}", stratosURL);
+ }
+
+ int slashCount = StringUtils.countMatches(stratosURL, "/");
+ int colonCount = StringUtils.countMatches(stratosURL, ":");
+
+ UrlValidator urlValidator = new UrlValidator(new String[] { "https" },UrlValidator.ALLOW_LOCAL_URLS);
+
+ // port must be provided, so colonCount must be 2
+ // context path must not be provided, so slashCount must not be >3
+
+ if (!urlValidator.isValid(stratosURL) || colonCount != 2 || slashCount >3) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Stratos Controller URL {} is not valid", stratosURL);
+ }
+ System.out.format(
+ "The \"%s\" variable in your environment is not a valid URL. You have provided \"%s\".%n"
+ + "Please provide the Stratos Controller URL as follows%nhttps://<host>:<port>%n",
+ CliConstants.STRATOS_URL_ENV_PROPERTY, stratosURL);
+ return false;
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Stratos Controller URL {} is valid.", stratosURL);
+ logger.debug("Adding the values to context.");
+ }
+ context.put(CliConstants.STRATOS_URL_ENV_PROPERTY, stratosURL);
+ context.put(CliConstants.STRATOS_USERNAME_ENV_PROPERTY, username);
+ context.put(CliConstants.STRATOS_PASSWORD_ENV_PROPERTY, password);
+ return true;
+ }
+
+ private void setLoggerLevel(boolean trace, boolean debug) {
+ // We are using Log4j. So, get the logger and set log levels.
+ org.apache.log4j.Logger logger = LogManager.getLogger(StratosApplication.class.getPackage().getName());
+ if (logger != null && trace) {
+ logger.setLevel(Level.TRACE);
+ LogManager.getRootLogger().setLevel(Level.TRACE);
+ } else if (logger != null && debug) {
+ logger.setLevel(Level.DEBUG);
+ LogManager.getRootLogger().setLevel(Level.DEBUG);
+ }
+ }
+
+ public void printHelp(final String action) {
+ Command<StratosCommandContext> command = commands.get(action);
+ if (command == null) {
+ System.out.println(action + ": command not found. Help not available.");
+ return;
+ }
+ System.out.println(command.getDescription());
+ Options options = command.getOptions();
+ if (options != null) {
+ if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
+ printHelp(command.getName() + " " + command.getArgumentSyntax(), options);
+ } else {
+ printHelp(command.getName(), options);
+ }
+ } else {
+ // No options. Just print the usage.
+ printUsage(command);
+ }
+ }
+
+ public void printHelp() {
+ printHelp(CliConstants.STRATOS_APPLICATION_NAME, options);
+ System.out.println("\n\nAvailable Commands: ");
+ for (String action : commands.keySet()) {
+ Command<StratosCommandContext> command = commands.get(action);
+ if (command != null) {
+ System.out.format("%-35s %s%n", command.getName(), command.getDescription());
+ }
+ }
+
+ System.out.println("\nFor help on a specific command type:\nhelp [command]");
+ }
+
+ /**
+ * Print "help" with usage
+ */
+ private void printHelp(final String commandLineSyntax, final Options options) {
+ final HelpFormatter helpFormatter = new HelpFormatter();
+ helpFormatter.printHelp(commandLineSyntax, options, true);
+ }
+
+ public void printUsage(final String action) {
+ Command<StratosCommandContext> command = commands.get(action);
+ if (command == null) {
+ return;
+ }
+ printUsage(command);
+ }
+
+ private void printUsage(Command<StratosCommandContext> command) {
+ Options options = command.getOptions();
+ if (options != null) {
+ if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
+ printUsage(command.getName() + " " + command.getArgumentSyntax(), options);
+ } else {
+ printUsage(command.getName(), options);
+ }
+ } else {
+ System.out.print("usage: ");
+ if (StringUtils.isNotBlank(command.getArgumentSyntax())) {
+ System.out.println(command.getName() + " " + command.getArgumentSyntax());
+ } else {
+ System.out.println(command.getName());
+ }
+ }
+ }
+
+ /**
+ * Print "usage"
+ */
+ private void printUsage(final String commandLineSyntax, final Options options) {
+ final PrintWriter writer = new PrintWriter(System.out);
+ final HelpFormatter usageFormatter = new HelpFormatter();
+ usageFormatter.printUsage(writer, 80, commandLineSyntax, options);
+ writer.flush();
+ }
}
http://git-wip-us.apache.org/repos/asf/stratos/blob/52120c9a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddNetworkPartitionCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddNetworkPartitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddNetworkPartitionCommand.java
new file mode 100644
index 0000000..c0185a1
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddNetworkPartitionCommand.java
@@ -0,0 +1,174 @@
+/**
+ * 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 AddNetworkPartitionCommand implements Command<StratosCommandContext> {
+
+ private static final Logger logger = LoggerFactory.getLogger(AddNetworkPartitionCommand.class);
+
+ private final Options options;
+
+ public AddNetworkPartitionCommand(){
+ options = constructOptions();
+ }
+
+ private Options constructOptions() {
+ final Options options = new Options();
+
+ Option resourcePath = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true,
+ "Network partition resource path");
+ resourcePath.setArgName("resource path");
+ options.addOption(resourcePath);
+
+ return options;
+ }
+ /**
+ * @return The name of the command
+ */
+ @Override
+ public String getName() {
+ return "add-network-partition";
+ }
+
+ /**
+ * Information about the command
+ *
+ * @return The description of the command
+ */
+ @Override
+ public String getDescription() {
+ return "add network partition deployment";
+ }
+
+ /**
+ * This should return the syntax required for the command.
+ * <p/>
+ * Used to display help.
+ *
+ * @return The syntax for this command
+ */
+ @Override
+ public String getArgumentSyntax() {
+ return null;
+ }
+
+ /**
+ * The options accepted by the command
+ *
+ * @return The Options for the commands
+ */
+ @Override
+ public Options getOptions() {
+ return options;
+ }
+
+ /**
+ * Executing the commands. Returns a code
+ *
+ * @param context The context assoicated with the Command Line Application
+ * @param args The arguments for the command
+ * @return The status code
+ * @throws org.apache.stratos.cli.exception.CommandException if any errors occur when executing the command
+ */
+ @Override
+ public int execute(StratosCommandContext context, String[] args) throws CommandException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Executing {} command...", getName());
+ logger.info("Get name" + getName());
+ }
+
+ if (args != null && args.length > 0) {
+ String resourcePath = null;
+ String partitionJson = null;
+
+ final CommandLineParser parser = new GnuParser();
+ CommandLine commandLine;
+
+ try {
+ commandLine = parser.parse(options, args);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Network Partition deployment");
+ }
+
+ if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Resource path option is passed");
+ }
+ resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH);
+ partitionJson = readResource(resourcePath);
+ }
+
+ if (resourcePath == null) {
+ System.out.println("usage: " + getName() + " [-p <resource path>]");
+ return CliConstants.COMMAND_FAILED;
+ }
+
+ RestCommandLineService.getInstance().addNetworkPartition(partitionJson);
+ 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) {
+ 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();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/52120c9a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListNetworkPartitionCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListNetworkPartitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListNetworkPartitionCommand.java
new file mode 100644
index 0000000..f18a260
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListNetworkPartitionCommand.java
@@ -0,0 +1,66 @@
+/**
+ * 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 ListNetworkPartitionCommand implements Command<StratosCommandContext> {
+ private static final Logger logger = LoggerFactory.getLogger(ListNetworkPartitionCommand.class);
+
+ public ListNetworkPartitionCommand() {
+ }
+
+ public String getName() {
+ return "list-network-partitions";
+ }
+
+ public String getDescription() {
+ return "List available network partitions";
+ }
+
+ 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().listNetworkPartitions();
+ 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/52120c9a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveNetworkPartitionCommand.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveNetworkPartitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveNetworkPartitionCommand.java
new file mode 100644
index 0000000..4d03daa
--- /dev/null
+++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveNetworkPartitionCommand.java
@@ -0,0 +1,72 @@
+/**
+ * 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 RemoveNetworkPartitionCommand implements Command<StratosCommandContext> {
+ private static final Logger logger = LoggerFactory.getLogger(RemoveNetworkPartitionCommand.class);
+
+ @Override
+ public String getName() {
+ return CliConstants.REMOVE_NETWORK_PARTITION;
+ }
+
+ @Override
+ public String getDescription() {
+ return "Remove network partition definition";
+ }
+
+ @Override
+ public String getArgumentSyntax() {
+ return "[id]";
+ }
+
+ @Override
+ public Options getOptions() {
+ return null;
+ }
+
+ @Override
+ public int execute(StratosCommandContext context, String[] args) throws CommandException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Executing {} command...", getName());
+ }
+ if (args != null && args.length == 1) {
+ String id = args[0];
+ if (logger.isDebugEnabled()) {
+ logger.debug("Getting Remove network partition info {}", id);
+ }
+ RestCommandLineService.getInstance().removeNetworkPartition(id);
+ return CliConstants.COMMAND_SUCCESSFULL;
+ } else {
+ context.getStratosApplication().printUsage(getName());
+ return CliConstants.COMMAND_FAILED;
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/stratos/blob/52120c9a/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 986315b..4e39bca 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
@@ -24,46 +24,51 @@ package org.apache.stratos.cli.utils;
*/
public class CliConstants {
- public static final String STRATOS_APPLICATION_NAME = "stratos";
- public static final String STRATOS_URL_ENV_PROPERTY = "STRATOS_URL";
- public static final String STRATOS_USERNAME_ENV_PROPERTY = "STRATOS_USERNAME";
- public static final String STRATOS_PASSWORD_ENV_PROPERTY = "STRATOS_PASSWORD";
- public static final String STRATOS_SHELL_PROMPT = "stratos> ";
-
- public static final int COMMAND_SUCCESSFULL = 0;
- public static final int COMMAND_FAILED = 1;
- public static final int ERROR_CODE = 2;
-
-
- /**
- * The Directory for storing configuration
- */
- public static final String STRATOS_DIR = ".stratos";
- public static final String STRATOS_HISTORY_DIR = ".history";
-
- public static final String HELP_ACTION = "help";
-
- /**
- * Subscribe to a cartridge.
- */
- public static final String SUBSCRIBE_ACTION = "subscribe-cartridge";
-
- public static final String UNSUBSCRIBE_ACTION = "unsubscribe-cartridge";
-
- /**
- * List the subscribed cartridges
- */
- public static final String LIST_ACTION = "list-subscribed-cartridges";
-
- /**
- * List the subscribed cartridges' information
- */
- public static final String LIST_INFO_ACTION = "subscribed-cartridges-info";
-
- /**
- * List the available cartridges
- */
- public static final String CARTRIDGES_ACTION = "list-cartridges";
+ public static final String STRATOS_APPLICATION_NAME = "stratos";
+ public static final String STRATOS_URL_ENV_PROPERTY = "STRATOS_URL";
+ public static final String STRATOS_USERNAME_ENV_PROPERTY = "STRATOS_USERNAME";
+ public static final String STRATOS_PASSWORD_ENV_PROPERTY = "STRATOS_PASSWORD";
+ public static final String STRATOS_SHELL_PROMPT = "stratos> ";
+
+ public static final int COMMAND_SUCCESSFULL = 0;
+ public static final int COMMAND_FAILED = 1;
+ public static final int ERROR_CODE = 2;
+
+
+ /**
+ * The Directory for storing configuration
+ */
+ public static final String STRATOS_DIR = ".stratos";
+ public static final String STRATOS_HISTORY_DIR = ".history";
+
+ public static final String HELP_ACTION = "help";
+
+ /**
+ * Subscribe to a cartridge.
+ */
+ public static final String SUBSCRIBE_ACTION = "subscribe-cartridge";
+
+ public static final String UNSUBSCRIBE_ACTION = "unsubscribe-cartridge";
+
+ /**
+ * List the subscribed cartridges
+ */
+ public static final String LIST_ACTION = "list-subscribed-cartridges";
+
+ /**
+ * List the subscribed cartridges' information
+ */
+ public static final String LIST_INFO_ACTION = "subscribed-cartridges-info";
+
+ /**
+ * List the available cartridges
+ */
+ public static final String CARTRIDGES_ACTION = "list-cartridges";
+
+ /**
+ * List the available network partitions
+ */
+ public static final String NETWORK_PARTITION_ACTION = "list-network-partitions";
/**
* List the available autoscaling policies
@@ -79,12 +84,12 @@ public class CliConstants {
* Add tenant
*/
public static final String ADD_TENANT = "create-tenant";
-
+
/**
* Add application
*/
public static final String ADD_APPLICATION = "create-application";
-
+
/**
* Add application signup
*/
@@ -109,7 +114,7 @@ public class CliConstants {
* List applications
*/
public static final String LIST_APPLICATIONS = "list-applications";
-
+
/**
* List partitions
*/
@@ -135,7 +140,7 @@ public class CliConstants {
*/
public static final String LIST_MEMBERS = "list-members";
- /**
+ /**
* List members with LB
*/
public static final String LIST_MEMBERS_WITH_LB = "list-lb-members";
@@ -155,22 +160,22 @@ public class CliConstants {
*/
public static final String DEPLOYMENT_POLICY_DEPLOYMENT = "deploy-deployment-policy";
- /**
- * Give information of a cartridge.
- */
- public static final String INFO_ACTION = "info";
-
- /**
+ /**
+ * Give information of a cartridge.
+ */
+ public static final String INFO_ACTION = "info";
+
+ /**
* Update a subscription.
*/
public static final String UPDATE_SUBSCRIPTION_ACTION = "update-subscription";
- /**
- * Synchronize repository
- */
- public static final String SYNC_ACTION = "sync";
-
- /**
+ /**
+ * Synchronize repository
+ */
+ public static final String SYNC_ACTION = "sync";
+
+ /**
* Describe the application signup
*/
public static final String DESCRIBE_APPLICATION_SIGNUP = "describe-application-signup";
@@ -178,11 +183,11 @@ public class CliConstants {
* Describe the application
*/
public static final String DESCRIBE_APPLICATION = "describe-application";
- /**
+ /**
* Describe the cartridge
*/
public static final String DESCRIBE_CARTRIDGE = "describe-cartridge";
- /**
+ /**
* Describe the partition
*/
public static final String DESCRIBE_PARTITION = "describe-partition";
@@ -190,7 +195,7 @@ public class CliConstants {
* Describe the auto scaling policy
*/
public static final String DESCRIBE_AUTO_SCALING_POLICY = "describe-autoscaling-policy";
-
+
/**
* Undeploy application
*/
@@ -203,7 +208,7 @@ public class CliConstants {
* Undeploy cartridge definition
*/
public static final String UNDEPLOY_CARTRIDGE_DEFINITION = "remove-cartridge";
-
+
/**
* Delete tenant
*/
@@ -215,64 +220,70 @@ public class CliConstants {
/**
* Deactivate tenant
*/
-
+
public static final String DEACTIVATE_TENANT = "deactivate-tenant";
/**
* Activate tenant
*/
public static final String ACTIVATE_TENANT = "activate-tenant";
-
+
/**
* Describe the deployment policy
*/
public static final String DESCRIBE_DEPLOYMENT_POLICY = "describe-deployment-policy";
- /**
- * Domain mapping
- */
- public static final String ADD_DOMAIN_MAPPING_ACTION = "add-domain-mapping";
- /**
- * Remove Domain mapping
- */
- public static final String REMOVE_DOMAIN_MAPPING_ACTION = "remove-domain-mapping";
-
- /**
- * List the available policies
- */
- public static final String POLICIES_ACTION = "policies";
-
- /**
+ /**
+ * Domain mapping
+ */
+ public static final String ADD_DOMAIN_MAPPING_ACTION = "add-domain-mapping";
+ /**
+ * Remove Domain mapping
+ */
+ public static final String REMOVE_DOMAIN_MAPPING_ACTION = "remove-domain-mapping";
+
+ /**
+ * List the available policies
+ */
+ public static final String POLICIES_ACTION = "policies";
+
+ /**
+ * remove network partition
+ */
+ public static final String REMOVE_NETWORK_PARTITION= "remove-network-partition";
+
+ /**
* Delete application
*/
public static final String DELETE_APPLICATION= "remove-application";
-
+
+
/**
* Delete application signup
*/
public static final String DELETE_APPLICATION_SIGNUP= "remove-application-signup";
- /**
- * Exit action
- */
- public static final String EXIT_ACTION = "exit";
+ /**
+ * Exit action
+ */
+ public static final String EXIT_ACTION = "exit";
- public static final String REPO_URL_OPTION = "r";
- public static final String REPO_URL_LONG_OPTION = "repo-url";
-
- public static final String PRIVATE_REPO_OPTION = "i";
- public static final String PRIVATE_REPO_LONG_OPTION = "private-repo";
+ public static final String REPO_URL_OPTION = "r";
+ public static final String REPO_URL_LONG_OPTION = "repo-url";
- public static final String USERNAME_OPTION = "u";
- public static final String USERNAME_LONG_OPTION = "username";
+ public static final String PRIVATE_REPO_OPTION = "i";
+ public static final String PRIVATE_REPO_LONG_OPTION = "private-repo";
- public static final String PASSWORD_OPTION = "p";
- public static final String PASSWORD_LONG_OPTION = "password";
+ public static final String USERNAME_OPTION = "u";
+ public static final String USERNAME_LONG_OPTION = "username";
- public static final String HELP_OPTION = "h";
- public static final String HELP_LONG_OPTION = "help";
-
- public static final String POLICY_OPTION = "o";
- public static final String POLICY_LONG_OPTION = "policy";
+ public static final String PASSWORD_OPTION = "p";
+ public static final String PASSWORD_LONG_OPTION = "password";
+
+ public static final String HELP_OPTION = "h";
+ public static final String HELP_LONG_OPTION = "help";
+
+ public static final String POLICY_OPTION = "o";
+ public static final String POLICY_LONG_OPTION = "policy";
public static final String REMOVE_ON_TERMINATION_OPTION = "t";
public static final String REMOVE_ON_TERMINATION_LONG_OPTION = "remove-on-termination";
@@ -291,28 +302,28 @@ public class CliConstants {
public static final String DEPLOYMENT_POLICY_OPTION = "dp";
public static final String DEPLOYMENT_POLICY_LONG_OPTION = "deployment-policy";
-
- public static final String DATA_ALIAS_OPTION = "d";
- public static final String DATA_ALIAS_LONG_OPTION = "data-alias";
+
+ public static final String DATA_ALIAS_OPTION = "d";
+ public static final String DATA_ALIAS_LONG_OPTION = "data-alias";
public static final String ALIAS_OPTION = "a";
- public static final String ALIAS_LONG_OPTION = "alias";
+ public static final String ALIAS_LONG_OPTION = "alias";
public static final String CARTRIDGE_TYPE_OPTION = "t";
- public static final String CARTRIDGE_TYPE_LONG_OPTION = "cartridge-type";
-
- public static final String FULL_OPTION = "f";
- public static final String FULL_LONG_OPTION = "full";
-
- public static final String FORCE_OPTION = "f";
- public static final String FORCE_LONG_OPTION = "force";
-
- public static final String TRACE_OPTION = "trace";
-
- public static final String DEBUG_OPTION = "debug";
-
- public static final String ENABLE_COMMITS_OPTION = "cm";
- public static final String ENABLE_COMMITS_LONG_OPTION = "enable-commits";
+ public static final String CARTRIDGE_TYPE_LONG_OPTION = "cartridge-type";
+
+ public static final String FULL_OPTION = "f";
+ public static final String FULL_LONG_OPTION = "full";
+
+ public static final String FORCE_OPTION = "f";
+ public static final String FORCE_LONG_OPTION = "force";
+
+ public static final String TRACE_OPTION = "trace";
+
+ public static final String DEBUG_OPTION = "debug";
+
+ public static final String ENABLE_COMMITS_OPTION = "cm";
+ public static final String ENABLE_COMMITS_LONG_OPTION = "enable-commits";
// Add tenant options
public static final String FIRST_NAME_OPTION = "f";
@@ -340,18 +351,18 @@ public class CliConstants {
// Deployment options
public static final String RESOURCE_PATH = "p";
public static final String RESOURCE_PATH_LONG_OPTION = "resource-path";
-
+
// Kubernetes options
public static final String CLUSTER_ID_OPTION = "c";
public static final String CLUSTER_ID_LONG_OPTION = "cluster-id";
-
+
public static final String HOST_ID_OPTION = "h";
public static final String HOST_ID_LONG_OPTION = "host-id";
-
+
// Application options
public static final String APPLICATION_ID_OPTION = "app";
public static final String APPLICATION_ID_LONG_OPTION = "application-id";
-
+
public static final String RESPONSE_INTERNAL_SERVER_ERROR = "500";
public static final String RESPONSE_AUTHORIZATION_FAIL = "403";
public static final String RESPONSE_NO_CONTENT = "204";