Repository: stratos
Updated Branches:
  refs/heads/tenant-isolation 366babaf2 -> 17c067139


Update network partition groups in application policy


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

Branch: refs/heads/tenant-isolation
Commit: 17c0671390ac070c816bb7e4bd66e0884397af54
Parents: 366baba
Author: Gayan Gunarathne <[email protected]>
Authored: Mon Aug 10 18:21:21 2015 +0530
Committer: Gayan Gunarathne <[email protected]>
Committed: Mon Aug 10 18:21:21 2015 +0530

----------------------------------------------------------------------
 .../stratos/autoscaler/util/AutoscalerUtil.java      | 15 +++++++++++----
 .../tests/application/ApplicationBurstingTest.java   | 10 +++++-----
 .../tests/application/SampleApplicationsTest.java    | 10 +++++-----
 .../tests/application/SingleClusterScalingTest.java  | 10 +++++-----
 .../tests/policies/ApplicationPolicyTest.java        |  4 ++--
 .../application-policies/application-policy-2.json   |  2 +-
 6 files changed, 29 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/17c06713/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
index c31e8a7..26ca7fb 100644
--- 
a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
+++ 
b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java
@@ -688,11 +688,14 @@ public class AutoscalerUtil {
                 if (networkPartitionGroupsPropertyValue != null) {
                     String[] networkPartitionGroups = 
networkPartitionGroupsPropertyValue.
                             
split(StratosConstants.APPLICATION_POLICY_NETWORK_PARTITION_GROUPS_SPLITTER);
+                    String[] networkPartitionGroupsUuid=null;
                     if (networkPartitionGroups != null) {
+                        int i=0;
                         for (String networkPartitionIdsString : 
networkPartitionGroups) {
                             networkPartitionIds = networkPartitionIdsString.
                                     
split(StratosConstants.APPLICATION_POLICY_NETWORK_PARTITIONS_SPLITTER);
-                            if (networkPartitionIds != null) {
+                             if (networkPartitionIds != null) {
+                                 networkPartitionGroupsUuid=new 
String[networkPartitionGroups.length];
                                 for (String networkPartitionId : 
networkPartitionIds) {
                                     // network-partition-id can't be null or 
empty
                                     if (null == networkPartitionId || 
networkPartitionId.isEmpty()) {
@@ -704,19 +707,23 @@ public class AutoscalerUtil {
                                     }
 
                                     // network partitions should be added 
already
-                                    if (null == 
CloudControllerServiceClient.getInstance().
-                                            
getNetworkPartition(networkPartitionId)) {
+                                    NetworkPartition networkPartition=    
CloudControllerServiceClient.getInstance().
+                                            
getNetworkPartitionByTenant(networkPartitionId,applicationPolicy.getTenantId());
+                                    if (null ==networkPartition) {
                                         String msg = String.format("Invalid 
Application Policy: "
                                                 + "Network partition not found 
for " +
                                                 "[network-partition-id] : %s", 
networkPartitionId);
                                         log.error(msg);
                                         throw new 
InvalidApplicationPolicyException(msg);
                                     }
+                                    else{
+                                         networkPartitionGroupsUuid[i] 
=networkPartition.getUuid();
+                                    }
                                 }
                             }
                         }
                         // populating network partition groups in application 
policy
-                        
applicationPolicy.setNetworkPartitionGroups(networkPartitionGroups);
+                        
applicationPolicy.setNetworkPartitionGroups(networkPartitionGroupsUuid);
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/stratos/blob/17c06713/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
index 815ccd8..4749faa 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/ApplicationBurstingTest.java
@@ -125,7 +125,7 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
 
         /*    boolean removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(removedGroup, false);
+            assertEquals(removedGroup, false);       */
 
             boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -139,7 +139,7 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
 
             boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-4", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, false);     */
+            assertEquals(removedDep, false);
 
             //Un-deploying the application
             String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"cartridge-group-app" +
@@ -187,15 +187,15 @@ public class ApplicationBurstingTest extends 
StratosTestServerManager {
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC3, true);
 
-            boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+            removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
             assertEquals(removedAuto, true);
 
-            boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+            removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-4", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, true);
 
-            boolean removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-9", 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedNet, false);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/17c06713/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
index 8737249..2e1c617 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SampleApplicationsTest.java
@@ -325,7 +325,7 @@ public class SampleApplicationsTest extends 
StratosTestServerManager {
 
           /*  boolean removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "G1",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(removedGroup, false);
+            assertEquals(removedGroup, false);      */
 
             boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -339,7 +339,7 @@ public class SampleApplicationsTest extends 
StratosTestServerManager {
 
             boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-1", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, false);     */
+            assertEquals(removedDep, false);
 
             //Un-deploying the application
             String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"g-sc-G123-1" +
@@ -387,15 +387,15 @@ public class SampleApplicationsTest extends 
StratosTestServerManager {
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC3, true);
 
-            boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+            removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
             assertEquals(removedAuto, true);
 
-            boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+            removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-1", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, true);
 
-            boolean removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-1", 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedNet, false);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/17c06713/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
index 633c456..5f2919d 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/application/SingleClusterScalingTest.java
@@ -125,7 +125,7 @@ public class SingleClusterScalingTest extends 
StratosTestServerManager {
 
            /* boolean removedGroup = 
restClient.removeEntity(RestConstants.CARTRIDGE_GROUPS, "esb-php-group",
                     RestConstants.CARTRIDGE_GROUPS_NAME);
-            assertEquals(removedGroup, false);
+            assertEquals(removedGroup, false);    */
 
             boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
@@ -139,7 +139,7 @@ public class SingleClusterScalingTest extends 
StratosTestServerManager {
 
             boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-4", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
-            assertEquals(removedDep, false);*/
+            assertEquals(removedDep, false);
 
             //Un-deploying the application
             String resourcePathUndeploy = RestConstants.APPLICATIONS + "/" + 
"cartridge-group-app" +
@@ -187,15 +187,15 @@ public class SingleClusterScalingTest extends 
StratosTestServerManager {
                     RestConstants.CARTRIDGES_NAME);
             assertEquals(removedC3, true);
 
-            boolean removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
+            removedAuto = 
restClient.removeEntity(RestConstants.AUTOSCALING_POLICIES,
                     autoscalingPolicyId, 
RestConstants.AUTOSCALING_POLICIES_NAME);
             assertEquals(removedAuto, true);
 
-            boolean removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
+            removedDep = 
restClient.removeEntity(RestConstants.DEPLOYMENT_POLICIES,
                     "deployment-policy-4", 
RestConstants.DEPLOYMENT_POLICIES_NAME);
             assertEquals(removedDep, true);
 
-            boolean removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
+            removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-9", 
RestConstants.NETWORK_PARTITIONS_NAME);
             assertEquals(removedNet, false);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/17c06713/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
index 08ac19f..4ed2a2e 100644
--- 
a/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
+++ 
b/products/stratos/modules/integration/src/test/java/org/apache/stratos/integration/tests/policies/ApplicationPolicyTest.java
@@ -76,7 +76,7 @@ public class ApplicationPolicyTest extends 
StratosTestServerManager {
             assertEquals(String.format("The Second network partition is not %s 
in %s",
                             "network-partition-8", applicationPolicyId), 
bean.getNetworkPartitions()[1],
                     "network-partition-8");
-          /*  boolean algoFound = false;
+            boolean algoFound = false;
             for (PropertyBean propertyBean : bean.getProperties()) {
                 if (propertyBean.getName().equals("networkPartitionGroups")) {
                     assertEquals(String.format("The networkPartitionGroups 
algorithm %s is not found in %s",
@@ -89,7 +89,7 @@ public class ApplicationPolicyTest extends 
StratosTestServerManager {
             if (!algoFound) {
                 assertTrue(String.format("The networkPartitionGroups property 
is not found in %s",
                         applicationPolicyId), false);
-            }   */
+            }
 
             boolean removedNet = 
restClient.removeEntity(RestConstants.NETWORK_PARTITIONS,
                     "network-partition-7", 
RestConstants.NETWORK_PARTITIONS_NAME);

http://git-wip-us.apache.org/repos/asf/stratos/blob/17c06713/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json
----------------------------------------------------------------------
diff --git 
a/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json
 
b/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json
index 82e85a0..1137942 100644
--- 
a/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json
+++ 
b/products/stratos/modules/integration/src/test/resources/application-policy-test/application-policies/application-policy-2.json
@@ -7,7 +7,7 @@
     ],
     "properties": [
         {
-            "name": "key-1",
+            "name": "networkPartitionGroups",
             "value": "network-partition-7,network-partition-8"
         },
         {

Reply via email to