From b2fcbf7442fe98f24d2482e833796ef7a1b4b8b2 Mon Sep 17 00:00:00 2001 From: Pubudu Gunatilaka Date: Wed, 27 May 2015 16:28:20 +0530 Subject: [PATCH 1/2] Fixed issues in network partition remove --- .../services/impl/AutoscalerServiceImpl.java | 16 + .../services/CloudControllerService.java | 3 +- .../impl/CloudControllerServiceImpl.java | 56 ++- .../client/CloudControllerServiceClient.java | 3 +- .../rest/endpoint/api/StratosApiV41.java | 5 + .../rest/endpoint/api/StratosApiV41Utils.java | 7 +- .../scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 5 +- .../wordpress-app/scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 7 +- .../scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 5 +- .../scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 5 +- .../sample-groups/scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 5 +- .../scripts/common/undeploy.sh | 6 +- .../scripts/common/undeploy.sh | 7 +- .../src/main/resources/AutoscalerService.wsdl | 252 +++++----- .../resources/CloudControllerService.wsdl | 474 +++++++++--------- 24 files changed, 500 insertions(+), 410 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java index 8587279f1e..eed70b75dc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/services/impl/AutoscalerServiceImpl.java @@ -53,6 +53,7 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidPartitionExceptionException; import org.apache.stratos.cloud.controller.stub.domain.MemberContext; import org.apache.stratos.cloud.controller.stub.domain.NetworkPartition; +import org.apache.stratos.cloud.controller.stub.domain.Partition; import org.apache.stratos.common.Properties; import org.apache.stratos.common.client.CloudControllerServiceClient; import org.apache.stratos.common.client.StratosManagerServiceClient; @@ -1049,6 +1050,21 @@ private void validateDeploymentPolicy(DeploymentPolicy deploymentPolicy) throws throw new InvalidDeploymentPolicyException(msg); } + // network partition - partition id should be already added + for (PartitionRef partitionRef : networkPartitionRef.getPartitionRefs()) { + String partitionId = partitionRef.getId(); + + for (Partition partition : networkPartition.getPartitions()) { + if (!partition.getId().equals(partitionId)) { + String msg = String.format("Partition Id is not found: [deployment-policy-id] %s " + + "[network-partition-id] %s [partition-id] %s", + deploymentPolicyId, networkPartitionId, partitionId); + log.error(msg); + throw new InvalidDeploymentPolicyException(msg); + } + } + } + // partition algorithm can't be null or empty String partitionAlgorithm = networkPartitionRef.getPartitionAlgo(); if (StringUtils.isBlank(partitionAlgorithm)) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/CloudControllerService.java index 5c417e1c2e..a6572c7b86 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/CloudControllerService.java @@ -364,7 +364,8 @@ public boolean addNetworkPartition(NetworkPartition networkPartition) throws Net * @param networkPartitionId * @throws NetworkPartitionNotExistsException */ - public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException; + public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException, + InvalidNetworkPartitionException; /** * Update network partition diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java index 13d84ac300..45250b0333 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java @@ -21,6 +21,8 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.stub.deployment.policy.ApplicationPolicy; +import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy; import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable; import org.apache.stratos.cloud.controller.config.CloudControllerConfig; import org.apache.stratos.cloud.controller.context.CloudControllerContext; @@ -35,6 +37,7 @@ import org.apache.stratos.cloud.controller.services.CloudControllerService; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.common.Property; +import org.apache.stratos.common.client.AutoscalerServiceClient; import org.apache.stratos.common.domain.LoadBalancingIPType; import org.apache.stratos.common.threading.StratosThreadPool; import org.apache.stratos.messaging.domain.topology.*; @@ -1480,7 +1483,7 @@ public boolean addNetworkPartition(NetworkPartition networkPartition) throws } else { //Following message is shown to the end user in all the the API clients(GUI/CLI/Rest API) throw new InvalidNetworkPartitionException(String.format("Network partition: " + - "%s doesn't not have any partitions ", networkPartition.getId())); + "%s doesn't not have any partitions ", networkPartition.getId())); } // adding network partition to CC-Context @@ -1495,7 +1498,8 @@ public boolean addNetworkPartition(NetworkPartition networkPartition) throws } @Override - public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException { + public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException, + InvalidNetworkPartitionException { try { if (log.isInfoEnabled()) { @@ -1509,6 +1513,7 @@ public boolean removeNetworkPartition(String networkPartitionId) throws NetworkP throw new NetworkPartitionNotExistsException(message); } // removing from CC-Context + validateNetworkPartition(networkPartitionId); CloudControllerContext.getInstance().removeNetworkPartition(networkPartitionId); // persisting CC-Context CloudControllerContext.getInstance().persist(); @@ -1524,6 +1529,53 @@ public boolean removeNetworkPartition(String networkPartitionId) throws NetworkP return true; } + private void validateNetworkPartition(String networkPartitionId) { + + try { + DeploymentPolicy[] deploymentPolicies = AutoscalerServiceClient.getInstance().getDeploymentPolicies(); + + if (deploymentPolicies != null) { + for (DeploymentPolicy deploymentPolicy : deploymentPolicies) { + for (org.apache.stratos.autoscaler.stub.partition.NetworkPartitionRef networkPartitionRef : + deploymentPolicy.getNetworkPartitionRefs()) { + if (networkPartitionRef.getId().equals(networkPartitionId)) { + String message = String.format("Cannot remove the network partition %s, since" + + " it is used in deployment policy %s", networkPartitionId, + deploymentPolicy.getDeploymentPolicyID()); + log.error(message); + throw new InvalidNetworkPartitionException(message); + } + } + } + } + + ApplicationPolicy[] applicationPolicies = AutoscalerServiceClient.getInstance().getApplicationPolicies(); + + if (applicationPolicies != null) { + for (ApplicationPolicy applicationPolicy : applicationPolicies) { + + for (String networkPartition : + applicationPolicy.getNetworkPartitions()) { + + if (networkPartition.equals(networkPartitionId)) { + String message = String.format("Cannot remove the network partition %s, since" + + " it is used in application policy %s", networkPartitionId, + applicationPolicy.getId()); + log.error(message); + throw new InvalidNetworkPartitionException(message); + } + } + } + } + } catch (Exception e) { + String message = e.getMessage(); + log.error(message, e); + throw new CloudControllerException(message, e); + } + + + } + @Override public boolean updateNetworkPartition(NetworkPartition networkPartition) throws NetworkPartitionNotExistsException { try { diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java index 50d424491a..4bf537fdec 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java @@ -233,7 +233,8 @@ public void addNetworkPartition(NetworkPartition networkPartition) throws Remote } public void removeNetworkPartition(String networkPartitionId) throws RemoteException, - CloudControllerServiceNetworkPartitionNotExistsExceptionException { + CloudControllerServiceNetworkPartitionNotExistsExceptionException, + CloudControllerServiceInvalidNetworkPartitionExceptionException { stub.removeNetworkPartition(networkPartitionId); } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index fc363eeee3..38b6d20318 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.stub.*; import org.apache.stratos.cloud.controller.stub.*; +import org.apache.stratos.cloud.controller.stub.exception.InvalidNetworkPartitionException; import org.apache.stratos.common.beans.ResponseMessageBean; import org.apache.stratos.common.beans.TenantInfoBean; import org.apache.stratos.common.beans.UserInfoBean; @@ -714,6 +715,10 @@ public Response removeNetworkPartition( } catch (CloudControllerServiceNetworkPartitionNotExistsExceptionException e) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( ResponseMessageBean.ERROR, "Network partition is not found")).build(); + } catch (CloudControllerServiceInvalidNetworkPartitionExceptionException e) { + return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( + ResponseMessageBean.ERROR, "Network partition is not found")).build(); + } return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS, String.format("Network partition deleted successfully: [network-partition] %s", diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 99f57a7994..9051748631 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -29,6 +29,7 @@ import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.domain.Cartridge; +import org.apache.stratos.cloud.controller.stub.exception.InvalidNetworkPartitionException; import org.apache.stratos.common.beans.PropertyBean; import org.apache.stratos.common.beans.TenantInfoBean; import org.apache.stratos.common.beans.UserInfoBean; @@ -56,6 +57,7 @@ import org.apache.stratos.common.client.StratosManagerServiceClient; import org.apache.stratos.common.exception.ApacheStratosException; import org.apache.stratos.common.exception.InvalidEmailException; +import org.apache.stratos.common.partition.NetworkPartitionRef; import org.apache.stratos.common.util.ClaimsMgtUtil; import org.apache.stratos.common.util.CommonUtil; import org.apache.stratos.manager.service.stub.StratosManagerServiceApplicationSignUpExceptionException; @@ -2614,7 +2616,8 @@ public static NetworkPartitionBean[] getNetworkPartitions() throws RestAPIExcept * @param networkPartitionId networkPartitionId */ public static void removeNetworkPartition(String networkPartitionId) throws RestAPIException, - CloudControllerServiceNetworkPartitionNotExistsExceptionException { + CloudControllerServiceNetworkPartitionNotExistsExceptionException, + CloudControllerServiceInvalidNetworkPartitionExceptionException { try { ApplicationContext[] applicationContexts = AutoscalerServiceClient.getInstance().getApplications(); if (applicationContexts != null) { @@ -2626,7 +2629,7 @@ public static void removeNetworkPartition(String networkPartitionId) throws Rest for (int i = 0; i < networkPartitions.length; i++) { if (networkPartitions[i].equals(networkPartitionId)) { String message = String.format("Cannot remove the network partition %s, since" + - " it is used in application %s", networkPartitionId, + " it is used in application %s", networkPartitionId, applicationContext.getApplicationId()); log.error(message); throw new RestAPIException(message); diff --git a/samples/applications/complex/php-tomcat-group-postgres-mysql-group-esb/scripts/common/undeploy.sh b/samples/applications/complex/php-tomcat-group-postgres-mysql-group-esb/scripts/common/undeploy.sh index 1d0ada0bd9..b9fa3d09b1 100644 --- a/samples/applications/complex/php-tomcat-group-postgres-mysql-group-esb/scripts/common/undeploy.sh +++ b/samples/applications/complex/php-tomcat-group-postgres-mysql-group-esb/scripts/common/undeploy.sh @@ -52,10 +52,10 @@ echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-2 +echo "Removing application policies..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 + echo "Removing network partitions..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 -echo "Removing application policies..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 - diff --git a/samples/applications/complex/tomcat-single-signon/scripts/common/undeploy.sh b/samples/applications/complex/tomcat-single-signon/scripts/common/undeploy.sh index 093aec50b4..419074d859 100755 --- a/samples/applications/complex/tomcat-single-signon/scripts/common/undeploy.sh +++ b/samples/applications/complex/tomcat-single-signon/scripts/common/undeploy.sh @@ -41,9 +41,10 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-3 -echo "Removing network partitions..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-3 echo "Removing application policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-2 +echo "Removing network partitions..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-3 + diff --git a/samples/applications/complex/wordpress-app/scripts/common/undeploy.sh b/samples/applications/complex/wordpress-app/scripts/common/undeploy.sh index 8a962732d2..462691d21a 100644 --- a/samples/applications/complex/wordpress-app/scripts/common/undeploy.sh +++ b/samples/applications/complex/wordpress-app/scripts/common/undeploy.sh @@ -46,9 +46,9 @@ echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-2 +echo "Removing application policies..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 + echo "Removing network partitions..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 - -echo "Removing application policies..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 diff --git a/samples/applications/nested/complex-app-with-lb/scripts/common/undeploy.sh b/samples/applications/nested/complex-app-with-lb/scripts/common/undeploy.sh index 8860f9912e..b115f0351a 100644 --- a/samples/applications/nested/complex-app-with-lb/scripts/common/undeploy.sh +++ b/samples/applications/nested/complex-app-with-lb/scripts/common/undeploy.sh @@ -48,10 +48,11 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 -echo "Removing network partitions..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 - echo "Removing application policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 +echo "Removing network partitions..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 + + diff --git a/samples/applications/nested/esb-php-nested-with-esb-php-nested-with-mysql-php-app/scripts/common/undeploy.sh b/samples/applications/nested/esb-php-nested-with-esb-php-nested-with-mysql-php-app/scripts/common/undeploy.sh index 0650635124..13b578761f 100644 --- a/samples/applications/nested/esb-php-nested-with-esb-php-nested-with-mysql-php-app/scripts/common/undeploy.sh +++ b/samples/applications/nested/esb-php-nested-with-esb-php-nested-with-mysql-php-app/scripts/common/undeploy.sh @@ -47,9 +47,9 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 +echo "Removing application policies..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 + echo "Removing network partitions..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 - -echo "Removing application policies..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 diff --git a/samples/applications/nested/five-levels-nested-groups-app/scripts/common/undeploy.sh b/samples/applications/nested/five-levels-nested-groups-app/scripts/common/undeploy.sh index 724c97d98b..fd78115798 100644 --- a/samples/applications/nested/five-levels-nested-groups-app/scripts/common/undeploy.sh +++ b/samples/applications/nested/five-levels-nested-groups-app/scripts/common/undeploy.sh @@ -49,9 +49,11 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 +echo "Removing application policies..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 + echo "Removing network partitions..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 -echo "Removing application policies..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 + diff --git a/samples/applications/nested/single-level-nested-group-app/scripts/common/undeploy.sh b/samples/applications/nested/single-level-nested-group-app/scripts/common/undeploy.sh index 122543675f..c310b680da 100644 --- a/samples/applications/nested/single-level-nested-group-app/scripts/common/undeploy.sh +++ b/samples/applications/nested/single-level-nested-group-app/scripts/common/undeploy.sh @@ -47,10 +47,11 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-2 +echo "Removing application policies..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 + echo "Removing network partitions..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 -echo "Removing application policies..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 diff --git a/samples/applications/nested/single-level-nested-groups-app/scripts/common/undeploy.sh b/samples/applications/nested/single-level-nested-groups-app/scripts/common/undeploy.sh index ca8b946ce3..453523cfaf 100644 --- a/samples/applications/nested/single-level-nested-groups-app/scripts/common/undeploy.sh +++ b/samples/applications/nested/single-level-nested-groups-app/scripts/common/undeploy.sh @@ -48,9 +48,9 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 -echo "Removing network partitions..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 - echo "Removing application policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 +echo "Removing network partitions..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 + diff --git a/samples/applications/scaling/app-bursting-pattern/scripts/common/undeploy.sh b/samples/applications/scaling/app-bursting-pattern/scripts/common/undeploy.sh index a47531c213..fc43693159 100644 --- a/samples/applications/scaling/app-bursting-pattern/scripts/common/undeploy.sh +++ b/samples/applications/scaling/app-bursting-pattern/scripts/common/undeploy.sh @@ -42,12 +42,12 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-4 +echo "Removing application policies..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-4 + echo "Removing network partitions..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-3 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-4 -echo "Removing application policies..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-4 - diff --git a/samples/applications/scaling/dependent-scaling/sample-cartridges/scripts/common/undeploy.sh b/samples/applications/scaling/dependent-scaling/sample-cartridges/scripts/common/undeploy.sh index 26d9c0ccdf..26fca1d79b 100644 --- a/samples/applications/scaling/dependent-scaling/sample-cartridges/scripts/common/undeploy.sh +++ b/samples/applications/scaling/dependent-scaling/sample-cartridges/scripts/common/undeploy.sh @@ -43,8 +43,9 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 +echo "Removing application policies..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 + echo "Removing network partitions..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 -echo "Removing application policies..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 diff --git a/samples/applications/scaling/dependent-scaling/sample-groups/scripts/common/undeploy.sh b/samples/applications/scaling/dependent-scaling/sample-groups/scripts/common/undeploy.sh index 178bb2922d..f2d19d239d 100644 --- a/samples/applications/scaling/dependent-scaling/sample-groups/scripts/common/undeploy.sh +++ b/samples/applications/scaling/dependent-scaling/sample-groups/scripts/common/undeploy.sh @@ -47,9 +47,9 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 -echo "Removing network partitions..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 - echo "Removing application policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 +echo "Removing network partitions..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 + diff --git a/samples/applications/scaling/group-scaling/group-scaling-app/scripts/common/undeploy.sh b/samples/applications/scaling/group-scaling/group-scaling-app/scripts/common/undeploy.sh index e7956c0a46..718c913328 100644 --- a/samples/applications/scaling/group-scaling/group-scaling-app/scripts/common/undeploy.sh +++ b/samples/applications/scaling/group-scaling/group-scaling-app/scripts/common/undeploy.sh @@ -51,9 +51,9 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 -echo "Removing network partitions..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 - echo "Removing application policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 +echo "Removing network partitions..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 + diff --git a/samples/applications/scaling/group-scaling/group-scaling-v1/scripts/common/undeploy.sh b/samples/applications/scaling/group-scaling/group-scaling-v1/scripts/common/undeploy.sh index 00c23847e8..2183fbc299 100644 --- a/samples/applications/scaling/group-scaling/group-scaling-v1/scripts/common/undeploy.sh +++ b/samples/applications/scaling/group-scaling/group-scaling-v1/scripts/common/undeploy.sh @@ -47,9 +47,9 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 -echo "Removing network partitions..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 - echo "Removing application policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 +echo "Removing network partitions..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 + diff --git a/samples/applications/scaling/group-scaling/single-group-group-scaling/scripts/common/undeploy.sh b/samples/applications/scaling/group-scaling/single-group-group-scaling/scripts/common/undeploy.sh index fcc543ab09..8eb5dd0ad4 100644 --- a/samples/applications/scaling/group-scaling/single-group-group-scaling/scripts/common/undeploy.sh +++ b/samples/applications/scaling/group-scaling/single-group-group-scaling/scripts/common/undeploy.sh @@ -45,12 +45,11 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 -echo "Removing network partitions..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 - echo "Removing application policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 +echo "Removing network partitions..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 diff --git a/samples/applications/simple/single-cartridge-app/scripts/common/undeploy.sh b/samples/applications/simple/single-cartridge-app/scripts/common/undeploy.sh index 3076ee04e5..938c7784c3 100644 --- a/samples/applications/simple/single-cartridge-app/scripts/common/undeploy.sh +++ b/samples/applications/simple/single-cartridge-app/scripts/common/undeploy.sh @@ -42,10 +42,10 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 +echo "Removing application policies..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 + echo "Removing network partitions..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 -echo "Removing application policies..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 - diff --git a/samples/applications/simple/single-group-app/scripts/common/undeploy.sh b/samples/applications/simple/single-group-app/scripts/common/undeploy.sh index 5e540c5c69..e294fd1f8a 100644 --- a/samples/applications/simple/single-group-app/scripts/common/undeploy.sh +++ b/samples/applications/simple/single-group-app/scripts/common/undeploy.sh @@ -47,11 +47,10 @@ curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https:// echo "Removing deployment policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/deploymentPolicies/deployment-policy-1 -echo "Removing network partitions..." -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 -curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 - echo "Removing application policies..." curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/applicationPolicies/application-policy-1 +echo "Removing network partitions..." +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-1 +curl -X DELETE -H "Content-Type: application/json" -k -v -u admin:admin https://${host_ip}:${host_port}/api/networkPartitions/network-partition-2 diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl index 4705610581..3a6896e2df 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoscalerService.wsdl @@ -1,4 +1,4 @@ - + @@ -21,7 +21,7 @@ - + @@ -33,17 +33,17 @@ - + - + - + @@ -52,10 +52,10 @@ - - - - + + + + @@ -66,8 +66,8 @@ - - + + @@ -75,7 +75,7 @@ - + @@ -94,21 +94,21 @@ - + - + - - + + @@ -130,9 +130,9 @@ - + - + @@ -156,27 +156,28 @@ - - + + + - - + - + + - + - + @@ -188,7 +189,7 @@ - + @@ -202,7 +203,42 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -216,7 +252,7 @@ - + @@ -228,21 +264,42 @@ - + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -270,21 +327,21 @@ - + - + - + @@ -298,7 +355,7 @@ - + @@ -384,14 +441,14 @@ - + - + @@ -412,14 +469,7 @@ - - - - - - - - + @@ -440,14 +490,14 @@ - + - + @@ -466,64 +516,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -531,7 +531,7 @@ - + @@ -608,7 +608,7 @@ - + @@ -629,21 +629,21 @@ - + - + - + @@ -657,21 +657,21 @@ - + - + - + @@ -704,7 +704,7 @@ - + @@ -749,13 +749,13 @@ - + - + @@ -764,17 +764,17 @@ - + - + - + @@ -783,7 +783,7 @@ - + @@ -807,7 +807,7 @@ - + @@ -817,18 +817,23 @@ - + + + + + + - + - + @@ -836,11 +841,6 @@ - - - - - @@ -864,6 +864,9 @@ + + + @@ -881,9 +884,6 @@ - - - diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index f8e0ea1dd5..ae3006b4fc 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,82 +1,26 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + - + - + - - - - - - + - + @@ -101,6 +45,13 @@ + + + + + + + @@ -197,6 +148,13 @@ + + + + + + + @@ -221,7 +179,7 @@ - + @@ -405,21 +363,42 @@ - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + @@ -468,116 +447,137 @@ - + - - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + - + - + - + - + - - - - + - + + + + + + + + + - + - + - + + + + + + + + + + + - + @@ -682,42 +682,42 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -769,29 +769,12 @@ - - - - - - - - - - - - - - - - - - + - + @@ -812,6 +795,11 @@ + + + + + @@ -842,7 +830,14 @@ - + + + + + + + + @@ -857,6 +852,11 @@ + + + + + @@ -883,16 +883,31 @@ - + + + + + + + + + + + + + + + + - - - - + + + + @@ -900,13 +915,13 @@ - + - + @@ -918,101 +933,9 @@ - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1088,6 +1011,18 @@ + + + + + + + + + + + + @@ -1107,6 +1042,17 @@ + + + + + + + + + + + @@ -1137,6 +1083,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1303,6 +1304,9 @@ + + + @@ -1450,9 +1454,6 @@ - - - @@ -1563,6 +1564,7 @@ + @@ -1878,6 +1880,9 @@ + + + @@ -2388,6 +2393,9 @@ + + + From 2f287d9eb97a585b4d870cd371d3d1836c2a6d70 Mon Sep 17 00:00:00 2001 From: Pubudu Gunatilaka Date: Wed, 27 May 2015 17:17:54 +0530 Subject: [PATCH 2/2] Changed to call through stratos manager --- .../services/CloudControllerService.java | 3 +- .../impl/CloudControllerServiceImpl.java | 54 +------ .../client/CloudControllerServiceClient.java | 3 +- .../rest/endpoint/api/StratosApiV41.java | 5 - .../rest/endpoint/api/StratosApiV41Utils.java | 47 +++++- .../resources/CloudControllerService.wsdl | 153 +++++++++--------- 6 files changed, 118 insertions(+), 147 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/CloudControllerService.java index a6572c7b86..5c417e1c2e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/CloudControllerService.java @@ -364,8 +364,7 @@ public boolean addNetworkPartition(NetworkPartition networkPartition) throws Net * @param networkPartitionId * @throws NetworkPartitionNotExistsException */ - public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException, - InvalidNetworkPartitionException; + public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException; /** * Update network partition diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java index 45250b0333..dfb4f9231d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java @@ -21,8 +21,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.stub.deployment.policy.ApplicationPolicy; -import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy; import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable; import org.apache.stratos.cloud.controller.config.CloudControllerConfig; import org.apache.stratos.cloud.controller.context.CloudControllerContext; @@ -37,7 +35,6 @@ import org.apache.stratos.cloud.controller.services.CloudControllerService; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.common.Property; -import org.apache.stratos.common.client.AutoscalerServiceClient; import org.apache.stratos.common.domain.LoadBalancingIPType; import org.apache.stratos.common.threading.StratosThreadPool; import org.apache.stratos.messaging.domain.topology.*; @@ -1498,8 +1495,7 @@ public boolean addNetworkPartition(NetworkPartition networkPartition) throws } @Override - public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException, - InvalidNetworkPartitionException { + public boolean removeNetworkPartition(String networkPartitionId) throws NetworkPartitionNotExistsException { try { if (log.isInfoEnabled()) { @@ -1513,7 +1509,6 @@ public boolean removeNetworkPartition(String networkPartitionId) throws NetworkP throw new NetworkPartitionNotExistsException(message); } // removing from CC-Context - validateNetworkPartition(networkPartitionId); CloudControllerContext.getInstance().removeNetworkPartition(networkPartitionId); // persisting CC-Context CloudControllerContext.getInstance().persist(); @@ -1529,53 +1524,6 @@ public boolean removeNetworkPartition(String networkPartitionId) throws NetworkP return true; } - private void validateNetworkPartition(String networkPartitionId) { - - try { - DeploymentPolicy[] deploymentPolicies = AutoscalerServiceClient.getInstance().getDeploymentPolicies(); - - if (deploymentPolicies != null) { - for (DeploymentPolicy deploymentPolicy : deploymentPolicies) { - for (org.apache.stratos.autoscaler.stub.partition.NetworkPartitionRef networkPartitionRef : - deploymentPolicy.getNetworkPartitionRefs()) { - if (networkPartitionRef.getId().equals(networkPartitionId)) { - String message = String.format("Cannot remove the network partition %s, since" + - " it is used in deployment policy %s", networkPartitionId, - deploymentPolicy.getDeploymentPolicyID()); - log.error(message); - throw new InvalidNetworkPartitionException(message); - } - } - } - } - - ApplicationPolicy[] applicationPolicies = AutoscalerServiceClient.getInstance().getApplicationPolicies(); - - if (applicationPolicies != null) { - for (ApplicationPolicy applicationPolicy : applicationPolicies) { - - for (String networkPartition : - applicationPolicy.getNetworkPartitions()) { - - if (networkPartition.equals(networkPartitionId)) { - String message = String.format("Cannot remove the network partition %s, since" + - " it is used in application policy %s", networkPartitionId, - applicationPolicy.getId()); - log.error(message); - throw new InvalidNetworkPartitionException(message); - } - } - } - } - } catch (Exception e) { - String message = e.getMessage(); - log.error(message, e); - throw new CloudControllerException(message, e); - } - - - } - @Override public boolean updateNetworkPartition(NetworkPartition networkPartition) throws NetworkPartitionNotExistsException { try { diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java index 4bf537fdec..50d424491a 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/client/CloudControllerServiceClient.java @@ -233,8 +233,7 @@ public void addNetworkPartition(NetworkPartition networkPartition) throws Remote } public void removeNetworkPartition(String networkPartitionId) throws RemoteException, - CloudControllerServiceNetworkPartitionNotExistsExceptionException, - CloudControllerServiceInvalidNetworkPartitionExceptionException { + CloudControllerServiceNetworkPartitionNotExistsExceptionException { stub.removeNetworkPartition(networkPartitionId); } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java index 38b6d20318..fc363eeee3 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.stub.*; import org.apache.stratos.cloud.controller.stub.*; -import org.apache.stratos.cloud.controller.stub.exception.InvalidNetworkPartitionException; import org.apache.stratos.common.beans.ResponseMessageBean; import org.apache.stratos.common.beans.TenantInfoBean; import org.apache.stratos.common.beans.UserInfoBean; @@ -715,10 +714,6 @@ public Response removeNetworkPartition( } catch (CloudControllerServiceNetworkPartitionNotExistsExceptionException e) { return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( ResponseMessageBean.ERROR, "Network partition is not found")).build(); - } catch (CloudControllerServiceInvalidNetworkPartitionExceptionException e) { - return Response.status(Response.Status.NOT_FOUND).entity(new ResponseMessageBean( - ResponseMessageBean.ERROR, "Network partition is not found")).build(); - } return Response.ok().entity(new ResponseMessageBean(ResponseMessageBean.SUCCESS, String.format("Network partition deleted successfully: [network-partition] %s", diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java index 9051748631..1b86499ff6 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java @@ -25,11 +25,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.stub.*; import org.apache.stratos.autoscaler.stub.deployment.policy.ApplicationPolicy; +import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.stub.pojo.ApplicationContext; import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.domain.Cartridge; -import org.apache.stratos.cloud.controller.stub.exception.InvalidNetworkPartitionException; import org.apache.stratos.common.beans.PropertyBean; import org.apache.stratos.common.beans.TenantInfoBean; import org.apache.stratos.common.beans.UserInfoBean; @@ -57,7 +57,6 @@ import org.apache.stratos.common.client.StratosManagerServiceClient; import org.apache.stratos.common.exception.ApacheStratosException; import org.apache.stratos.common.exception.InvalidEmailException; -import org.apache.stratos.common.partition.NetworkPartitionRef; import org.apache.stratos.common.util.ClaimsMgtUtil; import org.apache.stratos.common.util.CommonUtil; import org.apache.stratos.manager.service.stub.StratosManagerServiceApplicationSignUpExceptionException; @@ -2616,10 +2615,11 @@ public static NetworkPartitionBean[] getNetworkPartitions() throws RestAPIExcept * @param networkPartitionId networkPartitionId */ public static void removeNetworkPartition(String networkPartitionId) throws RestAPIException, - CloudControllerServiceNetworkPartitionNotExistsExceptionException, - CloudControllerServiceInvalidNetworkPartitionExceptionException { + CloudControllerServiceNetworkPartitionNotExistsExceptionException { try { - ApplicationContext[] applicationContexts = AutoscalerServiceClient.getInstance().getApplications(); + + AutoscalerServiceClient autoscalerServiceClient = AutoscalerServiceClient.getInstance(); + ApplicationContext[] applicationContexts = autoscalerServiceClient.getApplications(); if (applicationContexts != null) { for (ApplicationContext applicationContext : applicationContexts) { if (applicationContext != null) { @@ -2639,6 +2639,43 @@ public static void removeNetworkPartition(String networkPartitionId) throws Rest } } } + + DeploymentPolicy[] deploymentPolicies = autoscalerServiceClient.getDeploymentPolicies(); + + if (deploymentPolicies != null) { + for (DeploymentPolicy deploymentPolicy : deploymentPolicies) { + for (org.apache.stratos.autoscaler.stub.partition.NetworkPartitionRef networkPartitionRef : + deploymentPolicy.getNetworkPartitionRefs()) { + if (networkPartitionRef.getId().equals(networkPartitionId)) { + String message = String.format("Cannot remove the network partition %s, since" + + " it is used in deployment policy %s", networkPartitionId, + deploymentPolicy.getDeploymentPolicyID()); + log.error(message); + throw new RestAPIException(message); + } + } + } + } + + ApplicationPolicy[] applicationPolicies = autoscalerServiceClient.getApplicationPolicies(); + + if (applicationPolicies != null) { + for (ApplicationPolicy applicationPolicy : applicationPolicies) { + + for (String networkPartition : + applicationPolicy.getNetworkPartitions()) { + + if (networkPartition.equals(networkPartitionId)) { + String message = String.format("Cannot remove the network partition %s, since" + + " it is used in application policy %s", networkPartitionId, + applicationPolicy.getId()); + log.error(message); + throw new RestAPIException(message); + } + } + } + } + CloudControllerServiceClient serviceClient = CloudControllerServiceClient.getInstance(); serviceClient.removeNetworkPartition(networkPartitionId); } catch (AutoscalerServiceAutoScalerExceptionException e) { diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index ae3006b4fc..c643dab30c 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,6 +1,6 @@ - + - + @@ -295,113 +295,113 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + - + - - - + - + - + @@ -820,16 +820,6 @@ - - - - - - - - - - @@ -842,6 +832,16 @@ + + + + + + + + + + @@ -883,31 +883,16 @@ - - - - - - - - - - - - - - - - + - - - - + + + + @@ -915,13 +900,13 @@ - + - + @@ -933,7 +918,22 @@ - + + + + + + + + + + + + + + + + @@ -1106,14 +1106,14 @@ - + - + @@ -1304,9 +1304,6 @@ - - - @@ -1454,6 +1451,9 @@ + + + @@ -1564,7 +1564,6 @@ - @@ -1880,9 +1879,6 @@ - - - @@ -2393,9 +2389,6 @@ - - -