Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 52241ae61 -> aef4da8a0


With Clocker microservice only one security group on AWS for customizer


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

Branch: refs/heads/master
Commit: f8741ea9093faa2787f5214590a451c657188454
Parents: c2494dc
Author: Andrew Kennedy <[email protected]>
Authored: Tue Oct 20 12:29:52 2015 +0100
Committer: Andrew Kennedy <[email protected]>
Committed: Tue Oct 20 12:29:52 2015 +0100

----------------------------------------------------------------------
 .../JcloudsLocationSecurityGroupCustomizer.java | 50 ++++++++++----------
 1 file changed, 25 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f8741ea9/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsLocationSecurityGroupCustomizer.java
----------------------------------------------------------------------
diff --git 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsLocationSecurityGroupCustomizer.java
 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsLocationSecurityGroupCustomizer.java
index 60a5271..a3bd1ce 100644
--- 
a/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsLocationSecurityGroupCustomizer.java
+++ 
b/locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/JcloudsLocationSecurityGroupCustomizer.java
@@ -266,33 +266,33 @@ public class JcloudsLocationSecurityGroupCustomizer 
extends BasicJcloudsLocation
         Set<SecurityGroup> groupsOnNode = 
securityApi.listSecurityGroupsForNode(nodeId);
         SecurityGroup unique;
         if (locationId.equals("aws-ec2")) {
-            if (groupsOnNode.size() != 2) {
-                LOG.warn("Expected to find two security groups on node {} in 
app {} (one shared, one unique). Found {}: {}",
-                        new Object[]{nodeId, applicationId, 
groupsOnNode.size(), groupsOnNode});
-                return null;
-            }
-            String expectedSharedName = getNameForSharedSecurityGroup();
-            Iterator<SecurityGroup> it = groupsOnNode.iterator();
-            SecurityGroup shared = it.next();
-            if (shared.getName().endsWith(expectedSharedName)) {
-                unique = it.next();
+            if (groupsOnNode.size() == 2) {
+                String expectedSharedName = getNameForSharedSecurityGroup();
+                Iterator<SecurityGroup> it = groupsOnNode.iterator();
+                SecurityGroup shared = it.next();
+                if (shared.getName().endsWith(expectedSharedName)) {
+                    unique = it.next();
+                } else {
+                    unique = shared;
+                    shared = it.next();
+                }
+                if (!shared.getName().endsWith(expectedSharedName)) {
+                    LOG.warn("Couldn't determine which security group is 
shared between instances in app {}. Expected={}, found={}",
+                            new Object[]{ applicationId, expectedSharedName, 
groupsOnNode });
+                    return null;
+                }
+                // Shared entry might be missing if Brooklyn has rebound to an 
application
+                SecurityGroup old = 
sharedGroupCache.asMap().putIfAbsent(shared.getLocation(), shared);
+                LOG.info("Loaded unique security group for node {} (in {}): 
{}",
+                        new Object[]{nodeId, applicationId, unique});
+                if (old == null) {
+                    LOG.info("Proactively set shared group for app {} to: {}", 
applicationId, shared);
+                }
+                return unique;
             } else {
-                unique = shared;
-                shared = it.next();
-            }
-            if (!shared.getName().endsWith(expectedSharedName)) {
-                LOG.warn("Couldn't determine which security group is shared 
between instances in app {}. Expected={}, found={}",
-                        new Object[]{applicationId, expectedSharedName, 
groupsOnNode});
-                return null;
-            }
-            // Shared entry might be missing if Brooklyn has rebound to an 
application
-            SecurityGroup old = 
sharedGroupCache.asMap().putIfAbsent(shared.getLocation(), shared);
-            LOG.info("Loaded unique security group for node {} (in {}): {}",
-                    new Object[]{nodeId, applicationId, unique});
-            if (old == null) {
-                LOG.info("Proactively set shared group for app {} to: {}", 
applicationId, shared);
+                LOG.warn("Expected to find two security groups on node {} in 
app {} (one shared, one unique). Found {}: {}",
+                        new Object[]{ nodeId, applicationId, 
groupsOnNode.size(), groupsOnNode });
             }
-            return unique;
         }
         return Iterables.getOnlyElement(groupsOnNode);
     }

Reply via email to