From 8ac7fa02063386a8eb73380d83261f7174781383 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 15 Apr 2016 16:27:09 -0700 Subject: [PATCH] Allow the server name limit to be configurable For some deployments 53 may be to high of a value and a lower value may be used (ie for registration into active directory, which has lower name limits) so add the ability to reduce the valid length of server names (but preserve the current limits by default). Change-Id: Icd06aba14dbf156b9164b0e25233f2df7099fc9b --- heat/common/config.py | 7 +++++++ heat/engine/resources/aws/ec2/instance.py | 7 ++++--- heat/engine/resources/openstack/nova/server.py | 5 ++--- .../configurable-server-name-limit-947d9152fe9b43ee.yaml | 6 ++++++ 4 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/configurable-server-name-limit-947d9152fe9b43ee.yaml diff --git a/heat/common/config.py b/heat/common/config.py index 9996bb7f0c..61a8e36af5 100644 --- a/heat/common/config.py +++ b/heat/common/config.py @@ -132,6 +132,13 @@ engine_opts = [ help=_('Number of times to retry when a client encounters an ' 'expected intermittent error. Set to 0 to disable ' 'retries.')), + # Server host name limit to 53 characters by due to typical default + # linux HOST_NAME_MAX of 64, minus the .novalocal appended to the name + cfg.IntOpt('max_server_name_length', + default=53, + max=53, + help=_('Maximum length of a server name to be used ' + 'in nova.')), cfg.IntOpt('max_interface_check_attempts', min=1, default=10, diff --git a/heat/engine/resources/aws/ec2/instance.py b/heat/engine/resources/aws/ec2/instance.py index 3025019e1a..cd2b011724 100644 --- a/heat/engine/resources/aws/ec2/instance.py +++ b/heat/engine/resources/aws/ec2/instance.py @@ -13,9 +13,12 @@ import copy +from oslo_config import cfg from oslo_log import log as logging import six +cfg.CONF.import_opt('max_server_name_length', 'heat.common.config') + from heat.common import exception from heat.common.i18n import _ from heat.common.i18n import _LI @@ -340,9 +343,7 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin): ), } - # Server host name limit to 53 characters by due to typical default - # linux HOST_NAME_MAX of 64, minus the .novalocal appended to the name - physical_resource_name_limit = 53 + physical_resource_name_limit = cfg.CONF.max_server_name_length default_client_name = 'nova' diff --git a/heat/engine/resources/openstack/nova/server.py b/heat/engine/resources/openstack/nova/server.py index c41247b562..07ace1f35f 100644 --- a/heat/engine/resources/openstack/nova/server.py +++ b/heat/engine/resources/openstack/nova/server.py @@ -38,6 +38,7 @@ from heat.engine import translation from heat.rpc import api as rpc_api cfg.CONF.import_opt('default_software_config_transport', 'heat.common.config') +cfg.CONF.import_opt('max_server_name_length', 'heat.common.config') LOG = logging.getLogger(__name__) @@ -577,9 +578,7 @@ class Server(stack_user.StackUser, sh.SchedulerHintsMixin, ), } - # Server host name limit to 53 characters by due to typical default - # linux HOST_NAME_MAX of 64, minus the .novalocal appended to the name - physical_resource_name_limit = 53 + physical_resource_name_limit = cfg.CONF.max_server_name_length default_client_name = 'nova' diff --git a/releasenotes/notes/configurable-server-name-limit-947d9152fe9b43ee.yaml b/releasenotes/notes/configurable-server-name-limit-947d9152fe9b43ee.yaml new file mode 100644 index 0000000000..ee947b2810 --- /dev/null +++ b/releasenotes/notes/configurable-server-name-limit-947d9152fe9b43ee.yaml @@ -0,0 +1,6 @@ +--- +features: + - Adds new 'max_server_name_length' configuration option + which defaults to the prior upper bound (53) and can be + lowered by users (if they need to, for example due to + ldap or other internal name limit restrictions).