From 2a7edfb036dcba89b99bd5e1c3763aef7dbf7f28 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Tue, 4 Feb 2020 19:23:42 +0200 Subject: [PATCH] Do not append container_name for metal containers dynamic_inventory.py fails in case of hostname+container_name length is more than 52 symbols. While it's valid appriach for containers, it shouldn't raise error when container is deployed on metal, since nothing will be appended to it's current hostname. Change-Id: Ifeed116a026042ae32985aaa7ff3f167ef3923f4 --- osa_toolkit/generate.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/osa_toolkit/generate.py b/osa_toolkit/generate.py index a3ddd5ab6b..444315b1c5 100755 --- a/osa_toolkit/generate.py +++ b/osa_toolkit/generate.py @@ -370,15 +370,27 @@ def _add_container_hosts(assignment, config, container_name, container_type, type_and_name = '{}_{}'.format(host_type, container_name) logger.debug("Generated container name %s", type_and_name) max_hostname_len = 52 - if len(type_and_name) > max_hostname_len: + if len(type_and_name) > max_hostname_len and \ + not properties['is_metal']: raise SystemExit( 'The resulting combination of [ "{}" + "{}" ] is longer than' - ' 52 characters. This combination will result in a container' + ' {} characters. This combination will result in a container' ' name that is longer than the maximum allowable hostname of' ' 63 characters. Before this process can continue please' ' adjust the host entries in your "openstack_user_config.yml"' ' to use a short hostname. The recommended hostname length is' - ' < 20 characters long.'.format(host_type, container_name) + ' < 20 characters long.'.format( + host_type, container_name, max_hostname_len + ) + ) + elif len(host_type) > 63 and properties['is_metal']: + raise SystemExit( + 'The resulting hostname "{0}" is longer than 63 characters.' + ' This combination may result in a name that is longer than' + ' the maximum allowable hostname of 63 characters. Before' + ' this process can continue please adjust the host entries' + ' in your "openstack_user_config.yml" to use a short hostname' + '.'.format(host_type) ) physical_host = inventory['_meta']['hostvars'][host_type]