Merge "Fix net_config_override validations"

This commit is contained in:
Zuul 2018-04-26 13:10:10 +00:00 committed by Gerrit Code Review
commit 64c9d2e610
3 changed files with 20 additions and 6 deletions

View File

@ -379,6 +379,15 @@ class TestNoIPChange(BaseTestCase):
mock_loads.return_value = mock_config
undercloud._validate_no_ip_change()
@mock.patch('instack_undercloud.undercloud.open')
@mock.patch('os.path.isfile', return_value=True)
def test_update_empty(self, mock_isfile, mock_open):
# This would be a way to disable os-net-config from running
mock_open.side_effect = [
mock.mock_open(read_data='').return_value,
]
undercloud._validate_no_ip_change()
@mock.patch('instack_undercloud.undercloud.open')
@mock.patch('json.loads')
@mock.patch('os.path.isfile', return_value=True)

View File

@ -818,16 +818,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

View File

@ -120,9 +120,8 @@
# 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 (string value)
# json format. If you wish to disable os-net-config you can use an
# set this location to point to an empty file.
#net_config_override =
# Network interface on which inspection dnsmasq will listen. If in