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 B252F18461 for ; Fri, 22 May 2015 09:05:09 +0000 (UTC) Received: (qmail 90812 invoked by uid 500); 22 May 2015 09:05:09 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 90790 invoked by uid 500); 22 May 2015 09:05:09 -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 90781 invoked by uid 99); 22 May 2015 09:05:09 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 May 2015 09:05:09 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 35D93C0044 for ; Fri, 22 May 2015 09:05:09 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id sypqVNlk7RGe for ; Fri, 22 May 2015 09:04:58 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 60C3D2309A for ; Fri, 22 May 2015 09:04:47 +0000 (UTC) Received: (qmail 89909 invoked by uid 99); 22 May 2015 09:04:47 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 22 May 2015 09:04:47 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0AC87E1124; Fri, 22 May 2015 09:04:47 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: heneveld@apache.org To: commits@brooklyn.incubator.apache.org Date: Fri, 22 May 2015 09:05:02 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [17/23] incubator-brooklyn git commit: tidying and bug-fixing around domain names and hostname salting tidying and bug-fixing around domain names and hostname salting Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/5d767b69 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/5d767b69 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/5d767b69 Branch: refs/heads/master Commit: 5d767b69500fb26e2100bac300f881d425a8930b Parents: b4518dd Author: Alex Heneveld Authored: Fri May 8 17:48:12 2015 +0100 Committer: Alex Heneveld Committed: Fri May 8 18:51:51 2015 +0100 ---------------------------------------------------------------------- .../location/cloud/CloudLocationConfig.java | 4 ++-- .../cloud/names/AbstractCloudMachineNamer.java | 1 + docs/guide/ops/locations/index.md | 5 +++-- .../location/jclouds/JcloudsLocation.java | 19 +++++++++---------- 4 files changed, 15 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5d767b69/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 6831726..6c941a3 100644 --- a/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java +++ b/core/src/main/java/brooklyn/location/cloud/CloudLocationConfig.java @@ -57,9 +57,9 @@ public interface CloudLocationConfig { /** @deprecated since 0.6.0; included here so it gets picked up in auto-detect routines */ @Deprecated public static final ConfigKey LEGACY_PRIVATE_KEY_PASSPHRASE = LocationConfigKeys.LEGACY_PRIVATE_KEY_PASSPHRASE; - // default is just shy of common 64-char boundary (could perhaps increase slightly...) + // default is just shy of common 64-char boundary, leaving 4 chars plus our salt allowance (default 4+1) which allows up to -12345678 by jclouds public static final ConfigKey VM_NAME_MAX_LENGTH = ConfigKeys.newIntegerConfigKey( - "vmNameMaxLength", "Maximum length of VM name", 61); + "vmNameMaxLength", "Maximum length of VM name", 60); public static final ConfigKey VM_NAME_SALT_LENGTH = ConfigKeys.newIntegerConfigKey( "vmNameSaltLength", "Number of characters to use for a random identifier inserted in hostname " http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5d767b69/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java b/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java index 4e81a46..8e4cd41 100644 --- a/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java +++ b/core/src/main/java/brooklyn/location/cloud/names/AbstractCloudMachineNamer.java @@ -95,6 +95,7 @@ public abstract class AbstractCloudMachineNamer implements CloudMachineNamer { return defaultMachineNameMaxLength; } + // sometimes we create salt string, sometimes jclouds does public int getLengthForMachineUniqueNameSalt(ConfigBag setup, boolean includeSeparator) { int saltLen; if (setup.containsKey(CloudLocationConfig.VM_NAME_SALT_LENGTH)) { http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5d767b69/docs/guide/ops/locations/index.md ---------------------------------------------------------------------- diff --git a/docs/guide/ops/locations/index.md b/docs/guide/ops/locations/index.md index 02e82bb..78f185d 100644 --- a/docs/guide/ops/locations/index.md +++ b/docs/guide/ops/locations/index.md @@ -136,8 +136,9 @@ For more keys and more detail on the keys below, see `cloudMachineNamer: brooklyn.location.cloud.names.CustomMachineNamer`. {% include java_link.html class_name="CustomMachineNamer" package_path="brooklyn/location/cloud/names" project_subpath="core" %} will use the entity's name or following a template you supply. - For all names, a random suffix will be appended to help guarantee uniqueness; - this can be removed by setting `vmNameSaltLength: 0`. + On many clouds, a random suffix will be appended to help guarantee uniqueness; + this can be removed by setting `vmNameSaltLength: 0` (selected clouds only). + - A DNS domain name where this host should be placed can be specified with `domainName` (in selected clouds only) http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5d767b69/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 c74cfe2..4cef9d0 100644 --- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java +++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsLocation.java @@ -600,7 +600,9 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im } templateTimestamp = Duration.of(provisioningStopwatch); - // "Name" sets jclouds hostname + // "Name" metadata seems to set the display name; at least in AWS + // TODO it would be nice if this salt comes from the location's ID (but we don't know that yet as the ssh machine location isn't created yet) + // TODO in softlayer we want to control the suffix of the hostname which is 3 random hex digits template.getOptions().getUserMetadata().put("Name", cloudMachineNamer.generateNewMachineUniqueNameFromGroupId(setup, groupId)); if (setup.get(JcloudsLocationConfig.INCLUDE_BROOKLYN_USER_METADATA)) { @@ -1068,7 +1070,7 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im .put(DOMAIN_NAME, new CustomizeTemplateOptions() { public void apply(TemplateOptions t, ConfigBag props, Object v) { if (t instanceof SoftLayerTemplateOptions) { - ((SoftLayerTemplateOptions)t).domainName((String)v); + ((SoftLayerTemplateOptions)t).domainName(TypeCoercions.coerce(v, String.class)); } else { LOG.info("ignoring domain-name({}) in VM creation because not supported for cloud/type ({})", v, t); } @@ -1122,20 +1124,17 @@ public class JcloudsLocation extends AbstractCloudMachineProvisioningLocation im // these things are nice on softlayer if (template.getOptions() instanceof SoftLayerTemplateOptions) { SoftLayerTemplateOptions slT = ((SoftLayerTemplateOptions)template.getOptions()); - if (Strings.isEmpty(slT.getDomainName())) { - // set a quasi-sensible domain name if none was provided (better than the default, jclouds.org) - slT.domainName("brooklyn.local"); + if (Strings.isBlank(slT.getDomainName()) || "jclouds.org".equals(slT.getDomainName())) { + // set a quasi-sensible domain name if none was provided (better than the default, jclouds.org) + // NB: things like brooklyn.local are disallowed + slT.domainName("local.brooklyncentral.org"); } // convert user metadata to tags because user metadata is otherwise ignored Map md = slT.getUserMetadata(); if (md!=null && !md.isEmpty()) { Set tags = MutableSet.copyOf(slT.getTags()); for (Map.Entry entry: md.entrySet()) { - if ("Name".equalsIgnoreCase(entry.getKey())) { - // skip "Name" but use the other tags - } else { - tags.add(AbstractCloudMachineNamer.sanitize(entry.getKey())+":"+AbstractCloudMachineNamer.sanitize(entry.getValue())); - } + tags.add(AbstractCloudMachineNamer.sanitize(entry.getKey())+":"+AbstractCloudMachineNamer.sanitize(entry.getValue())); } slT.tags(tags); }