Merge "Fix net_config_override validations"

This commit is contained in:
Zuul 2018-05-05 00:06:18 +00:00 committed by Gerrit Code Review
commit 2313accae7
2 changed files with 11 additions and 7 deletions

View File

@ -240,10 +240,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',

View File

@ -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