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
This commit is contained in:
parent
8b1803de14
commit
aaee4e42a0
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue