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/05/22 11:05:02 UTC
[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 <al...@cloudsoftcorp.com>
Authored: Fri May 8 17:48:12 2015 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
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<String> 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<Integer> VM_NAME_MAX_LENGTH = ConfigKeys.newIntegerConfigKey(
- "vmNameMaxLength", "Maximum length of VM name", 61);
+ "vmNameMaxLength", "Maximum length of VM name", 60);
public static final ConfigKey<Integer> 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).
+ <!-- TODO jclouds softlayer includes a 3-char hex suffix -->
- 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<String, String> md = slT.getUserMetadata();
if (md!=null && !md.isEmpty()) {
Set<String> tags = MutableSet.copyOf(slT.getTags());
for (Map.Entry<String,String> 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);
}