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).