You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ga...@apache.org on 2015/08/05 09:30:28 UTC

stratos git commit: Update the deployement policy update method

Repository: stratos
Updated Branches:
  refs/heads/tenant-isolation 31a496fd3 -> 72863002b


Update the deployement policy update method


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

Branch: refs/heads/tenant-isolation
Commit: 72863002b0b367dd902b1517032e184dc552f924
Parents: 31a496f
Author: Gayan Gunarathne <ga...@wso2.com>
Authored: Wed Aug 5 13:00:10 2015 +0530
Committer: Gayan Gunarathne <ga...@wso2.com>
Committed: Wed Aug 5 13:00:10 2015 +0530

----------------------------------------------------------------------
 .../rest/endpoint/api/StratosApiV41Utils.java   | 27 ++++++++++++++++++--
 .../tests/SampleApplicationsTest.java           |  4 +--
 2 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/72863002/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/api/StratosApiV41Utils.java
----------------------------------------------------------------------
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 47f1164..60a52fe 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
@@ -3064,8 +3064,31 @@ public class StratosApiV41Utils {
             AutoscalerServiceInvalidDeploymentPolicyExceptionException,
             AutoscalerServiceDeploymentPolicyNotExistsExceptionException {
         try {
-            AutoscalerServiceClient serviceClient = AutoscalerServiceClient.getInstance();
             PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+            int tenantId=carbonContext.getTenantId();
+            NetworkPartitionBean[] networkPartitions = getNetworkPartitions();
+            for (NetworkPartitionReferenceBean networkPartitionReferenceBean : deploymentPolicyDefinitionBean
+                    .getNetworkPartitions()) {
+                NetworkPartition networkPartition = CloudControllerServiceClient.getInstance()
+                        .getNetworkPartitionByTenant(networkPartitionReferenceBean.getId(), tenantId);
+                for (NetworkPartitionBean networkPartitionBean : networkPartitions) {
+                    if (networkPartition.getTenantId() == tenantId && networkPartitionBean.getId().equals
+                            (networkPartitionReferenceBean.getId())) {
+                        networkPartitionReferenceBean.setUuid(networkPartition.getUuid());
+                        for (PartitionReferenceBean partition : networkPartitionReferenceBean.getPartitions()) {
+                            for (PartitionBean existingPartition : networkPartitionBean.getPartitions()) {
+                                if (existingPartition.getTenantId() == tenantId &&
+                                        partition.getId().equals(existingPartition.getId())) {
+                                    partition.setUuid(existingPartition.getUuid());
+                                    partition.setTenantId(tenantId);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            AutoscalerServiceClient serviceClient = AutoscalerServiceClient.getInstance();
+
             DeploymentPolicy deploymentPolicy = serviceClient.getDeploymentPolicyByTenant
                     (deploymentPolicyDefinitionBean.getId(), carbonContext.getTenantId());
             if (log.isDebugEnabled()) {
@@ -3075,7 +3098,7 @@ public class StratosApiV41Utils {
             }
             AutoscalerServiceClient.getInstance().updateDeploymentPolicy(ObjectConverter
                     .convertDeploymentPolicyBeanToASDeploymentPolicy(deploymentPolicyDefinitionBean,
-                            deploymentPolicy.getUuid(), deploymentPolicy.getTenantId()));
+                            deploymentPolicy.getUuid(), carbonContext.getTenantId()));
 
             if (log.isDebugEnabled()) {
                 log.debug(String.format("DeploymentPolicy updated successfully : [deployment-policy-uuid] %s " +

http://git-wip-us.apache.org/repos/asf/stratos/blob/72863002/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
index 0d71ddd..eef6a69 100644
--- a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
+++ b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/SampleApplicationsTest.java
@@ -622,7 +622,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(updated, true);
 
             //update deployment policy with new partition and max values
-            /*
+
             boolean updatedDep = deploymentPolicyTest.updateDeploymentPolicy("deployment-policy-1.json",
                     endpoint, restClient);
             assertEquals(updatedDep, true);
@@ -648,7 +648,7 @@ public class SampleApplicationsTest extends StratosTestServerManager {
             assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getId(),
                     "network-partition-2-partition-2");
             assertEquals(updatedBean.getNetworkPartitions().get(1).getPartitions().get(1).getPartitionMax(), 5);
-             */
+
             boolean removedNet = networkPartitionTest.removeNetworkPartition("network-partition-1", endpoint,
                     restClient);
             //Trying to remove the used network partition