Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CD10911963 for ; Fri, 23 May 2014 16:57:11 +0000 (UTC) Received: (qmail 52786 invoked by uid 500); 23 May 2014 16:57:11 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 52734 invoked by uid 500); 23 May 2014 16:57:11 -0000 Mailing-List: contact commits-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list commits@brooklyn.incubator.apache.org Received: (qmail 52697 invoked by uid 99); 23 May 2014 16:57:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 May 2014 16:57:11 +0000 X-ASF-Spam-Status: No, hits=-2000.7 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 23 May 2014 16:57:07 +0000 Received: (qmail 51393 invoked by uid 99); 23 May 2014 16:56:46 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 May 2014 16:56:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B4ED29A111E; Fri, 23 May 2014 16:56:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: richard@apache.org To: commits@brooklyn.incubator.apache.org Date: Fri, 23 May 2014 16:57:12 -0000 Message-Id: <392b9d4d4a3f4c779cf9103285475be2@git.apache.org> In-Reply-To: <9326865323a7471ea6f0e5bac0063885@git.apache.org> References: <9326865323a7471ea6f0e5bac0063885@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [27/50] [abbrv] git commit: support OS_FAMILY and OS_VERSION_REGEX for jclouds X-Virus-Checked: Checked by ClamAV on apache.org 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/head Commit: 37bf67ae7f352320a043b28e0e0cf2499108ecee Parents: f54024f Author: Alex Heneveld Authored: Fri May 23 10:08:07 2014 -0600 Committer: Alex Heneveld 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 = 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,CustomizeTemplateOptions> SUPPORTED_TEMPLATE_OPTIONS_PROPERTIES = ImmutableMap.,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 OS_FAMILY = ConfigKeys.newConfigKey(OsFamily.class, "osFamily", + "OS family, e.g. CentOS, Debian, RHEL, Ubuntu"); + public static final ConfigKey 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