You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/04/28 11:55:42 UTC

[2/9] incubator-brooklyn git commit: create configKey ADDITIONAL_INBOUND_PORTS to augment getRequiredOpenPorts()

create configKey ADDITIONAL_INBOUND_PORTS to augment getRequiredOpenPorts()


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

Branch: refs/heads/master
Commit: 74232dff9d561d7f74ea726841ab7da2f0a9633d
Parents: 18b6c71
Author: Robert Moss <ro...@gmail.com>
Authored: Sun Apr 12 19:35:34 2015 +0100
Committer: Robert Moss <ro...@gmail.com>
Committed: Sun Apr 12 19:35:34 2015 +0100

----------------------------------------------------------------------
 .../location/cloud/CloudLocationConfig.java     |  5 ++++
 .../entity/basic/SoftwareProcessImpl.java       | 25 +++++++-------------
 2 files changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/74232dff/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java b/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
index 4d868ae..ad19f39 100644
--- a/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
+++ b/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java
@@ -75,6 +75,11 @@ public interface CloudLocationConfig {
     public static final ConfigKey<Object> INBOUND_PORTS = new BasicConfigKey<Object>(Object.class, "inboundPorts", 
         "Inbound ports to be applied when creating a VM, on supported clouds " +
             "(either a single port as a String, or an Iterable<Integer> or Integer[])", null);
+    
+    public static final ConfigKey<Object> ADDITIONAL_INBOUND_PORTS = new BasicConfigKey<Object>(Object.class, "required.ports", 
+            "Required additional ports to be applied when creating a VM, on supported clouds " +
+                    "(either a single port as an Integer, or an Iterable<Integer> or Integer[])", null);
+    
     public static final ConfigKey<Boolean> OS_64_BIT = ConfigKeys.newBooleanConfigKey("os64Bit", 
         "Whether to require 64-bit OS images (true), 32-bit images (false), or either (null)");
     

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/74232dff/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
index fed2830..a6c165d 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
@@ -21,8 +21,6 @@ package brooklyn.entity.basic;
 import groovy.time.TimeDuration;
 
 import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.Timer;
@@ -416,6 +414,14 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
         result.putAll(getConfig(PROVISIONING_PROPERTIES));
         if (result.get(CloudLocationConfig.INBOUND_PORTS) == null) {
             Collection<Integer> ports = getRequiredOpenPorts();
+            Object requiredPorts = result.get(CloudLocationConfig.ADDITIONAL_INBOUND_PORTS);
+            if (requiredPorts instanceof Integer){
+                ports.add((Integer)requiredPorts);
+            }else if (requiredPorts instanceof Iterable) {
+                for(Object o : (Iterable<?>)requiredPorts){
+                    if(o instanceof Integer) ports.add((Integer)o);
+                }
+            }
             if (ports != null && ports.size() > 0) result.put(CloudLocationConfig.INBOUND_PORTS, ports);
         }
         result.put(LocationConfigKeys.CALLER_CONTEXT, this);
@@ -423,8 +429,7 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
     }
 
     /** returns the ports that this entity wants to use;
-     * default implementation returns 22 plus first value for each PortAttributeSensorAndConfigKey config key PortRange
-     * and any ports specified in provisioning properties as required.
+     * default implementation returns 22 plus first value for each PortAttributeSensorAndConfigKey config key PortRange.
      */
     protected Collection<Integer> getRequiredOpenPorts() {
         Set<Integer> ports = MutableSet.of(22);
@@ -435,18 +440,6 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
             }   
         }
         
-        Map<String, Object> provisioningProperties = getConfig(PROVISIONING_PROPERTIES);
-        if(provisioningProperties.containsKey("required.ports")){
-            Object requiredPorts = provisioningProperties.get("required.ports");
-            if (requiredPorts instanceof Integer){
-                ports.add((Integer)requiredPorts);
-            }else if (requiredPorts instanceof List) {
-                for(Object o : (List<?>)requiredPorts){
-                    if(o instanceof Integer) ports.add((Integer)o);
-                }
-            }
-        }
-        
         log.debug("getRequiredOpenPorts detected default {} for {}", ports, this);
         return ports;
     }