brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [26/50] [abbrv] git commit: support OS_FAMILY and OS_VERSION_REGEX for jclouds
Date Fri, 23 May 2014 16:57:11 GMT
support OS_FAMILY and OS_VERSION_REGEX for jclouds


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

Branch: refs/pull/1414/merge
Commit: 37bf67ae7f352320a043b28e0e0cf2499108ecee
Parents: f54024f
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri May 23 10:08:07 2014 -0600
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri May 23 10:08:07 2014 -0600

----------------------------------------------------------------------
 .../brooklyn/location/jclouds/JcloudsLocation.java  | 16 +++++++++++++++-
 .../location/jclouds/JcloudsLocationConfig.java     |  7 ++++++-
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/37bf67ae/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
index 328baf3..e4c3fce 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java
@@ -43,6 +43,7 @@ import org.jclouds.compute.domain.Image;
 import org.jclouds.compute.domain.NodeMetadata;
 import org.jclouds.compute.domain.NodeMetadata.Status;
 import org.jclouds.compute.domain.NodeMetadataBuilder;
+import org.jclouds.compute.domain.OsFamily;
 import org.jclouds.compute.domain.Template;
 import org.jclouds.compute.domain.TemplateBuilder;
 import org.jclouds.compute.domain.TemplateBuilderSpec;
@@ -99,8 +100,10 @@ import brooklyn.util.exceptions.CompoundRuntimeException;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.flags.SetFromFlag;
 import brooklyn.util.flags.TypeCoercions;
+import brooklyn.util.guava.Maybe;
 import brooklyn.util.internal.ssh.ShellTool;
 import brooklyn.util.internal.ssh.SshTool;
+import brooklyn.util.javalang.Enums;
 import brooklyn.util.javalang.Reflections;
 import brooklyn.util.net.Cidr;
 import brooklyn.util.net.Networking;
@@ -851,6 +854,17 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
                     public void apply(TemplateBuilder tb, ConfigBag props, Object v) {
                         tb.imageNameMatches(((CharSequence)v).toString());
                     }})
+            .put(OS_FAMILY, new CustomizeTemplateBuilder() {
+                    public void apply(TemplateBuilder tb, ConfigBag props, Object v) {
+                        Maybe<OsFamily> osFamily = Enums.valueOfIgnoreCase(OsFamily.class,
v.toString());
+                        if (osFamily.isAbsent())
+                            throw new IllegalArgumentException("Invalid "+OS_FAMILY+" value
"+v);
+                        tb.osFamily(osFamily.get());
+                    }})
+            .put(OS_VERSION_REGEX, new CustomizeTemplateBuilder() {
+                    public void apply(TemplateBuilder tb, ConfigBag props, Object v) {
+                        tb.osVersionMatches( ((CharSequence)v).toString() );
+                    }})
             .put(TEMPLATE_SPEC, new CustomizeTemplateBuilder() {
                 public void apply(TemplateBuilder tb, ConfigBag props, Object v) {
                         tb.from(TemplateBuilderSpec.parse(((CharSequence)v).toString()));
@@ -864,7 +878,7 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation
im
                         /* done in the code, but included here so that it is in the map */
                     }})
             .build();
-   
+    
     /** properties which cause customization of the TemplateOptions */
     public static final Map<ConfigKey<?>,CustomizeTemplateOptions> SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES
= ImmutableMap.<ConfigKey<?>,CustomizeTemplateOptions>builder()
             .put(SECURITY_GROUPS, new CustomizeTemplateOptions() {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/37bf67ae/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
index 49729a1..73db853 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocationConfig.java
@@ -1,11 +1,11 @@
 package brooklyn.location.jclouds;
 
-import java.io.File;
 import java.util.Collection;
 import java.util.concurrent.Semaphore;
 
 import org.jclouds.Constants;
 import org.jclouds.compute.domain.Image;
+import org.jclouds.compute.domain.OsFamily;
 import org.jclouds.compute.domain.TemplateBuilder;
 import org.jclouds.domain.LoginCredentials;
 
@@ -187,6 +187,11 @@ public interface JcloudsLocationConfig extends CloudLocationConfig {
         "imageChooser", "An image chooser function to control which images are preferred",

         new BrooklynImageChooser().chooser());
 
+    public static final ConfigKey<OsFamily> OS_FAMILY = ConfigKeys.newConfigKey(OsFamily.class,
"osFamily", 
+        "OS family, e.g. CentOS, Debian, RHEL, Ubuntu");
+    public static final ConfigKey<String> OS_VERSION_REGEX = ConfigKeys.newStringConfigKey("osVersionRegex",

+        "Regular expression for the OS version to load");
+
     // TODO
     
 //  "noDefaultSshKeys" - hints that local ssh keys should not be read as defaults


Mime
View raw message