From aaee4e42a0b723d119ef27f9a504cdb28180c475 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Wed, 25 Apr 2018 09:51:51 -0400 Subject: [PATCH] Fix net_config_override validations There is an issue with the _validate_no_ip_change function where it doesn't work correctly with a custom net_config_override file. This patch resolves validation issue so that custom os-net-config templates are taken into account. Additionally it makes it so that the net_config_override can be empty, thus providing the user a means of disabling os-net-config if they choose to do so. Change-Id: I127c2742522e695dd1fd15413a47bf4d8ebea8fa Related-bug: #1764507 --- tripleoclient/v1/undercloud_config.py | 6 ++---- tripleoclient/v1/undercloud_preflight.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tripleoclient/v1/undercloud_config.py b/tripleoclient/v1/undercloud_config.py index 632379f07..c798edd1a 100644 --- a/tripleoclient/v1/undercloud_config.py +++ b/tripleoclient/v1/undercloud_config.py @@ -241,10 +241,8 @@ _opts = [ help=('Path to network config override template. If set, this ' 'template will be used to configure the networking via ' 'os-net-config. Must be in json format. ' - 'Templated tags can be used within the ' - 'template, see ' - 'instack-undercloud/elements/undercloud-stack-config/' - 'net-config.json.template for example tags') + 'If you wish to disable os-net-config you can set this' + 'location to an empty file.') ), cfg.StrOpt('inspection_interface', default='br-ctlplane', diff --git a/tripleoclient/v1/undercloud_preflight.py b/tripleoclient/v1/undercloud_preflight.py index f6c3858fc..3ec4c0886 100644 --- a/tripleoclient/v1/undercloud_preflight.py +++ b/tripleoclient/v1/undercloud_preflight.py @@ -327,16 +327,22 @@ def _validate_no_ip_change(): need to disallow it early in the install before configurations start to be changed. """ - os_net_config_file = '/etc/os-net-config/config.json' + if CONF.net_config_override: + os_net_config_file = CONF.net_config_override + else: + os_net_config_file = '/etc/os-net-config/config.json' # Nothing to do if we haven't already installed if not os.path.isfile( os.path.expanduser(os_net_config_file)): return - with open(os_net_config_file) as f: - network_config = json.loads(f.read()) try: + with open(os_net_config_file) as f: + network_config = json.loads(f.read()) ctlplane = [i for i in network_config.get('network_config', []) if i['name'] == 'br-ctlplane'][0] + except ValueError: + # File was empty + return except IndexError: # Nothing to check if br-ctlplane wasn't configured return