Repository: stratos Updated Branches: refs/heads/docker-grouping-merge b17c175a9 -> a61918598
Introducing list-applications command, removing list-cartridge-subscriptions command and refactoring service grouping code in CLI Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/414a93b7 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/414a93b7 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/414a93b7 Branch: refs/heads/docker-grouping-merge Commit: 414a93b7394de6eb3494f7d164e599006032ffcf Parents: b6cbba2 Author: Imesh Gunaratne <[email protected]> Authored: Sat Nov 8 21:37:45 2014 +0530 Committer: Imesh Gunaratne <[email protected]> Committed: Sat Nov 8 21:37:45 2014 +0530 ---------------------------------------------------------------------- .../stratos/cli/RestCommandLineService.java | 57 ++++++++++++-- .../apache/stratos/cli/StratosApplication.java | 12 +-- .../grouping/applications/Application.java | 70 +++++++++++++++++ .../grouping/applications/ApplicationBean.java | 10 +-- .../grouping/applications/Applications.java | 70 ----------------- .../beans/grouping/applications/Cluster.java | 81 +++++++++++++++++++ .../beans/grouping/applications/Clusters.java | 81 ------------------- .../cli/beans/grouping/applications/Group.java | 82 ++++++++++++++++++++ .../cli/beans/grouping/applications/Groups.java | 82 -------------------- .../beans/grouping/applications/SubGroup.java | 70 +++++++++++++++++ .../beans/grouping/applications/SubGroups.java | 70 ----------------- .../cli/commands/ListApplicationsCommand.java | 65 ++++++++++++++++ .../cli/commands/ListDeployServiceCommand.java | 65 ---------------- .../cli/commands/ListServicesCommand.java | 65 ++++++++++++++++ .../src/test/python/test_interactive.py | 18 ++--- 15 files changed, 505 insertions(+), 393 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/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 3d3dcfb..5cf36a4 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 @@ -50,6 +50,7 @@ import org.apache.stratos.cli.beans.cartridge.Cartridge; import org.apache.stratos.cli.beans.cartridge.CartridgeInfoBean; import org.apache.stratos.cli.beans.cartridge.PortMapping; import org.apache.stratos.cli.beans.cartridge.ServiceDefinitionBean; +import org.apache.stratos.cli.beans.grouping.applications.Application; import org.apache.stratos.cli.beans.grouping.applications.ApplicationBean; import org.apache.stratos.cli.beans.grouping.serviceGroups.ServiceGroupList; import org.apache.stratos.cli.beans.kubernetes.KubernetesGroup; @@ -108,8 +109,9 @@ public class RestCommandLineService { private static final String ENDPOINT_LIST_KUBERNETES_GROUPS = API_CONTEXT + "/kubernetes/group"; private static final String ENDPOINT_LIST_KUBERNETES_HOSTS = API_CONTEXT + "/kubernetes/hosts/{groupId}"; private static final String ENDPOINT_LIST_SERVICE_GROUP = API_CONTEXT + "/group/definition/{groupDefinitionName}"; - private static final String ENDPOINT_LIST_APPLICATION = API_CONTEXT + "/application/{appId}"; + private static final String ENDPOINT_LIST_APPLICATION = API_CONTEXT + "/application"; + private static final String ENDPOINT_GET_APPLICATION = API_CONTEXT + "/application/{appId}"; private static final String ENDPOINT_GET_CARTRIDGE_OF_TENANT = API_CONTEXT + "/cartridge/info/{id}"; private static final String ENDPOINT_GET_CLUSTER_OF_TENANT = API_CONTEXT + "/cluster/"; private static final String ENDPOINT_GET_KUBERNETES_GROUP = API_CONTEXT + "/kubernetes/group/{id}"; @@ -1270,7 +1272,6 @@ public class RestCommandLineService { data[3] = definition.getClusterDomain(); data[4] = definition.getTenantRange(); data[5] = definition.getIsPublic() ? "Public" : "Private"; - ; return data; } }; @@ -1288,6 +1289,36 @@ public class RestCommandLineService { } } + public void listApplications() throws CommandException { + try { + ApplicationList list = (ApplicationList) restClient.listEntity(ENDPOINT_LIST_APPLICATION, + ApplicationList.class, "application"); + + if ((list == null) || (list.getApplications() == null) || (list.getApplications().size() == 0)) { + System.out.println("No applications found"); + return; + } + + RowMapper<Application> rowMapper = new RowMapper<Application>() { + public String[] getData(Application definition) { + String[] data = new String[1]; + data[0] = definition.getId(); + return data; + } + }; + + Application[] array = new Application[list.getApplications().size()]; + array = list.getApplications().toArray(array); + + System.out.println("Applications found:"); + CliUtils.printTable(array, rowMapper, "Application ID"); + } catch (Exception e) { + String message = "Error in listing applications"; + System.out.println(message); + log.error(message, e); + } + } + // This method helps to deploy deployment polices public void deployDeploymentPolicy(String deploymentPolicy) throws CommandException { restClient.deployEntity(ENDPOINT_DEPLOY_DEPLOYMENT_POLICY, deploymentPolicy, "deployment policy"); @@ -1617,6 +1648,22 @@ public class RestCommandLineService { } } + private class ApplicationList { + private ArrayList<Application> applications; + + public ArrayList<Application> getApplications() { + return applications; + } + + public void setDeploymentPolicy(ArrayList<Application> applications) { + this.applications = applications; + } + + ApplicationList() { + applications = new ArrayList<Application>(); + } + } + // This class convert JSON string to servicedefinitionbean object private class ServiceDefinitionList { private ArrayList<ServiceDefinitionBean> serviceDefinitionBean; @@ -1858,16 +1905,16 @@ public class RestCommandLineService { // This method helps to describe applications public void describeApplication (String applicationID) { try { - ApplicationBean list = (ApplicationBean) restClient.listEntity(ENDPOINT_LIST_APPLICATION.replace("{appId}", applicationID), + ApplicationBean bean = (ApplicationBean) restClient.listEntity(ENDPOINT_GET_APPLICATION.replace("{appId}", applicationID), ApplicationBean.class, "applications"); - if ((list == null) || (list.getApplications() == null)) { + if ((bean == null) || (bean.getApplication() == null)) { System.out.println("Application not found: " + applicationID); return; } System.out.println("Application : " + applicationID); - System.out.println(getGson().toJson(list.getApplications())); + System.out.println(getGson().toJson(bean.getApplication())); } catch (Exception e) { String message = "Error in describing application: " + applicationID; System.out.println(message); http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/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 35ad657..1aa37fc 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 @@ -138,7 +138,10 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon command = new UndeployServiceDefinitionCommand(); commands.put(command.getName(), command); - command = new ListDeployServiceCommand(); + command = new ListApplicationsCommand(); + commands.put(command.getName(), command); + + command = new ListServicesCommand(); commands.put(command.getName(), command); command = new UndeployCartridgeDefinitionCommand(); @@ -146,9 +149,6 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon command = new DeployDeploymentPolicyCommand(); commands.put(command.getName(), command); - - command = new ListCartridgeSubscriptionsCommand(); - commands.put(command.getName(), command); command = new ListPartitionCommand(); commands.put(command.getName(), command); @@ -377,7 +377,7 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon } } else { if (login(usernameInput, passwordInput, true)) { - System.out.println("Successfully Authenticated."); + System.out.println("Successfully authenticated"); } else { // Exit return CliConstants.ERROR_CODE; @@ -436,7 +436,7 @@ public class StratosApplication extends CommandLineApplication<StratosCommandCon } if (success) { if (logger.isDebugEnabled()) { - logger.debug("Successfully Authenticated."); + logger.debug("Successfully authenticated"); } } else { if (logger.isDebugEnabled()) { http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Application.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Application.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Application.java new file mode 100644 index 0000000..73d3af6 --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Application.java @@ -0,0 +1,70 @@ +/** + * 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.beans.grouping.applications; + +public class Application +{ + private String id; + + private String tenantAdminUsername; + + private String tenantDomain; + + private Group group; + + public String getId () + { + return id; + } + + public void setId (String id) + { + this.id = id; + } + + public String getTenantAdminUsername () + { + return tenantAdminUsername; + } + + public void setTenantAdminUsername (String tenantAdminUsername) + { + this.tenantAdminUsername = tenantAdminUsername; + } + + public String getTenantDomain () + { + return tenantDomain; + } + + public void setTenantDomain (String tenantDomain) + { + this.tenantDomain = tenantDomain; + } + + public Group getGroup() + { + return group; + } + + public void setGroup(Group group) + { + this.group = group; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/ApplicationBean.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/ApplicationBean.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/ApplicationBean.java index de4365c..9d44b0c 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/ApplicationBean.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/ApplicationBean.java @@ -20,15 +20,15 @@ package org.apache.stratos.cli.beans.grouping.applications; public class ApplicationBean { - private Applications applications; + private Application application; - public Applications getApplications () + public Application getApplication() { - return applications; + return application; } - public void setApplications (Applications applications) + public void setApplication(Application application) { - this.applications = applications; + this.application = application; } } http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Applications.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Applications.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Applications.java deleted file mode 100644 index 44ad23c..0000000 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Applications.java +++ /dev/null @@ -1,70 +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.beans.grouping.applications; - -public class Applications -{ - private String id; - - private String tenantAdminUsername; - - private String tenantDomain; - - private Groups groups; - - public String getId () - { - return id; - } - - public void setId (String id) - { - this.id = id; - } - - public String getTenantAdminUsername () - { - return tenantAdminUsername; - } - - public void setTenantAdminUsername (String tenantAdminUsername) - { - this.tenantAdminUsername = tenantAdminUsername; - } - - public String getTenantDomain () - { - return tenantDomain; - } - - public void setTenantDomain (String tenantDomain) - { - this.tenantDomain = tenantDomain; - } - - public Groups getGroups () - { - return groups; - } - - public void setGroups (Groups groups) - { - this.groups = groups; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Cluster.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Cluster.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Cluster.java new file mode 100644 index 0000000..b5da48a --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Cluster.java @@ -0,0 +1,81 @@ +/** + * 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.beans.grouping.applications; + +public class Cluster { + private Member[] member; + + private String isLbCluster; + + private String[] hostNames; + + private String tenantRange; + + private String clusterId; + + private String serviceName; + + public Member[] getMember() { + return member; + } + + public void setMember(Member[] member) { + this.member = member; + } + + public String getIsLbCluster() { + return isLbCluster; + } + + public void setIsLbCluster(String isLbCluster) { + this.isLbCluster = isLbCluster; + } + + public String[] getHostNames() { + return hostNames; + } + + public void setHostNames(String[] hostNames) { + this.hostNames = hostNames; + } + + public String getTenantRange() { + return tenantRange; + } + + public void setTenantRange(String tenantRange) { + this.tenantRange = tenantRange; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Clusters.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Clusters.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Clusters.java deleted file mode 100644 index 3cc7761..0000000 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Clusters.java +++ /dev/null @@ -1,81 +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.beans.grouping.applications; - -public class Clusters { - private Member[] member; - - private String isLbCluster; - - private String[] hostNames; - - private String tenantRange; - - private String clusterId; - - private String serviceName; - - public Member[] getMember() { - return member; - } - - public void setMember(Member[] member) { - this.member = member; - } - - public String getIsLbCluster() { - return isLbCluster; - } - - public void setIsLbCluster(String isLbCluster) { - this.isLbCluster = isLbCluster; - } - - public String[] getHostNames() { - return hostNames; - } - - public void setHostNames(String[] hostNames) { - this.hostNames = hostNames; - } - - public String getTenantRange() { - return tenantRange; - } - - public void setTenantRange(String tenantRange) { - this.tenantRange = tenantRange; - } - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Group.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Group.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Group.java new file mode 100644 index 0000000..f100391 --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Group.java @@ -0,0 +1,82 @@ +/** + * 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.beans.grouping.applications; + +public class Group +{ + private String deploymentPolicy; + + private Cluster cluster; + + private String alias; + + private String autoScalingPolicy; + + private SubGroup[] subGroups; + + public String getDeploymentPolicy () + { + return deploymentPolicy; + } + + public void setDeploymentPolicy (String deploymentPolicy) + { + this.deploymentPolicy = deploymentPolicy; + } + + public Cluster getCluster() + { + return cluster; + } + + public void setCluster(Cluster cluster) + { + this.cluster = cluster; + } + + public String getAlias () + { + return alias; + } + + public void setAlias (String alias) + { + this.alias = alias; + } + + public String getAutoScalingPolicy () + { + return autoScalingPolicy; + } + + public void setAutoScalingPolicy (String autoScalingPolicy) + { + this.autoScalingPolicy = autoScalingPolicy; + } + + public SubGroup[] getSubGroups () + { + return subGroups; + } + + public void setSubGroups (SubGroup[] subGroups) + { + this.subGroups = subGroups; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Groups.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Groups.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Groups.java deleted file mode 100644 index e82cf05..0000000 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/Groups.java +++ /dev/null @@ -1,82 +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.beans.grouping.applications; - -public class Groups -{ - private String deploymentPolicy; - - private Clusters clusters; - - private String alias; - - private String autoScalingPolicy; - - private SubGroups[] subGroups; - - public String getDeploymentPolicy () - { - return deploymentPolicy; - } - - public void setDeploymentPolicy (String deploymentPolicy) - { - this.deploymentPolicy = deploymentPolicy; - } - - public Clusters getClusters () - { - return clusters; - } - - public void setClusters (Clusters clusters) - { - this.clusters = clusters; - } - - public String getAlias () - { - return alias; - } - - public void setAlias (String alias) - { - this.alias = alias; - } - - public String getAutoScalingPolicy () - { - return autoScalingPolicy; - } - - public void setAutoScalingPolicy (String autoScalingPolicy) - { - this.autoScalingPolicy = autoScalingPolicy; - } - - public SubGroups[] getSubGroups () - { - return subGroups; - } - - public void setSubGroups (SubGroups[] subGroups) - { - this.subGroups = subGroups; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/SubGroup.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/SubGroup.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/SubGroup.java new file mode 100644 index 0000000..d3567eb --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/SubGroup.java @@ -0,0 +1,70 @@ +/** + * 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.beans.grouping.applications; + +public class SubGroup +{ + private String deploymentPolicy; + + private Cluster cluster; + + private String alias; + + private String autoScalingPolicy; + + public String getDeploymentPolicy () + { + return deploymentPolicy; + } + + public void setDeploymentPolicy (String deploymentPolicy) + { + this.deploymentPolicy = deploymentPolicy; + } + + public Cluster getCluster() + { + return cluster; + } + + public void setCluster(Cluster cluster) + { + this.cluster = cluster; + } + + public String getAlias () + { + return alias; + } + + public void setAlias (String alias) + { + this.alias = alias; + } + + public String getAutoScalingPolicy () + { + return autoScalingPolicy; + } + + public void setAutoScalingPolicy (String autoScalingPolicy) + { + this.autoScalingPolicy = autoScalingPolicy; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/SubGroups.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/SubGroups.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/SubGroups.java deleted file mode 100644 index a1a85f9..0000000 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/grouping/applications/SubGroups.java +++ /dev/null @@ -1,70 +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.beans.grouping.applications; - -public class SubGroups -{ - private String deploymentPolicy; - - private Clusters clusters; - - private String alias; - - private String autoScalingPolicy; - - public String getDeploymentPolicy () - { - return deploymentPolicy; - } - - public void setDeploymentPolicy (String deploymentPolicy) - { - this.deploymentPolicy = deploymentPolicy; - } - - public Clusters getClusters () - { - return clusters; - } - - public void setClusters (Clusters clusters) - { - this.clusters = clusters; - } - - public String getAlias () - { - return alias; - } - - public void setAlias (String alias) - { - this.alias = alias; - } - - public String getAutoScalingPolicy () - { - return autoScalingPolicy; - } - - public void setAutoScalingPolicy (String autoScalingPolicy) - { - this.autoScalingPolicy = autoScalingPolicy; - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.java new file mode 100644 index 0000000..a59d131 --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListApplicationsCommand.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 ListApplicationsCommand implements Command<StratosCommandContext> { + + private static final Logger logger = LoggerFactory.getLogger(ListApplicationsCommand.class); + + public ListApplicationsCommand() { + } + + public String getName() { + return "list-applications"; + } + + public String getDescription() { + return "List available applications"; + } + + 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().listApplications(); + 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/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java deleted file mode 100644 index a45ac02..0000000 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.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 ListDeployServiceCommand implements Command<StratosCommandContext> { - - private static final Logger logger = LoggerFactory.getLogger(ListDeployServiceCommand.class); - - public ListDeployServiceCommand() { - } - - public String getName() { - return CliConstants.LIST_DEPLOY_SERVICE; - } - - public String getDescription() { - return "List available deploy services"; - } - - 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().listServices(); - 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/414a93b7/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListServicesCommand.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListServicesCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListServicesCommand.java new file mode 100644 index 0000000..a14d063 --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListServicesCommand.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 ListServicesCommand implements Command<StratosCommandContext> { + + private static final Logger logger = LoggerFactory.getLogger(ListServicesCommand.class); + + public ListServicesCommand() { + } + + public String getName() { + return CliConstants.LIST_DEPLOY_SERVICE; + } + + public String getDescription() { + return "List available deploy services"; + } + + 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().listServices(); + 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/414a93b7/components/org.apache.stratos.cli/src/test/python/test_interactive.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cli/src/test/python/test_interactive.py b/components/org.apache.stratos.cli/src/test/python/test_interactive.py index 8a17e7f..28665c8 100755 --- a/components/org.apache.stratos.cli/src/test/python/test_interactive.py +++ b/components/org.apache.stratos.cli/src/test/python/test_interactive.py @@ -60,7 +60,7 @@ class TestInteractive(unittest.TestCase): child.sendline ('1234') child.expect ('Password: ') child.sendline ('abcd') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('exit') child.expect (pexpect.EOF) @@ -72,7 +72,7 @@ class TestInteractive(unittest.TestCase): child.expect ('Username: xxx') child.expect ('Password: ') child.sendline ('zzz') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('exit') child.expect (pexpect.EOF) @@ -84,7 +84,7 @@ class TestInteractive(unittest.TestCase): child.expect ('Username: xxx') child.expect ('Password: ') child.sendline ('zzz') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('exit') child.expect (pexpect.EOF) @@ -96,7 +96,7 @@ class TestInteractive(unittest.TestCase): child.expect ('Username: xxx') child.expect ('Password: ') child.sendline ('zzz') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('exit') child.expect (pexpect.EOF) @@ -110,7 +110,7 @@ class TestInteractive(unittest.TestCase): child.expect ('Username: yyy') child.expect ('Password: ') child.sendline ('zzz') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('exit') child.expect (pexpect.EOF) @@ -121,7 +121,7 @@ class TestInteractive(unittest.TestCase): child = pexpect.spawn(TestInteractive.cli_cmd + " -password xxx", timeout=10) child.expect ('Username: ') child.sendline ('1234') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('exit') child.expect (pexpect.EOF) @@ -134,7 +134,7 @@ class TestInteractive(unittest.TestCase): child.sendline ('1234') child.expect ('\r\nPassword: ') # TODO - why do we need \r\n? child.sendline ('zzz') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('list-tenants') child.expect ('Available Tenants') @@ -158,7 +158,7 @@ class TestInteractive(unittest.TestCase): child.sendline ('1234') child.expect ('\r\nPassword: ') # TODO - why do we need \r\n? child.sendline ('zzz') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('create-tenant --username tenant1 --password secret --first-name John --last-name Doe --domain-name tenant.com --email [email protected]') child.expect ('Tenant added successfully') @@ -175,7 +175,7 @@ class TestInteractive(unittest.TestCase): child.sendline ('1234') child.expect ('\r\nPassword: ') # TODO - why do we need \r\n? child.sendline ('zzz') - child.expect ('Successfully Authenticated.') + child.expect ('Successfully authenticated') child.expect ('stratos> ') child.sendline ('deactivate-tenant tenant.com') child.expect ('You have succesfully deactivate tenant.com tenant')
