summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2018-04-24 08:57:34 -0400
committerDan Prince <dprince@redhat.com>2018-04-24 08:57:34 -0400
commitc64a1c823e021b050c7eccaee1c42f4040b6b4e8 (patch)
tree055529eda9e4ebd31b0cf714603bea6335967e01
parente49688be9844b9ae32e14747ad95a07be0fa142c (diff)
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: Iada099a6bddc7927d26b19776e705b1ac231b2e5 Depends-On: I69eb812af2d653cb3eb29694ae29b57ebb2de53d Closes-bug: #1764507
Notes
Notes (review): Verified+1: RDO Third Party CI <dmsimard+rdothirdparty@redhat.com> Code-Review+2: Emilien Macchi <emilien@redhat.com> Code-Review+2: Bogdan Dobrelya <bdobreli@redhat.com> Workflow+1: Bogdan Dobrelya <bdobreli@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 26 Apr 2018 13:10:10 +0000 Reviewed-on: https://review.openstack.org/563937 Project: openstack/instack-undercloud Branch: refs/heads/master
-rw-r--r--instack_undercloud/tests/test_undercloud.py9
-rw-r--r--instack_undercloud/undercloud.py12
-rw-r--r--undercloud.conf.sample5
3 files changed, 20 insertions, 6 deletions
diff --git a/instack_undercloud/tests/test_undercloud.py b/instack_undercloud/tests/test_undercloud.py
index 652f311..f163c41 100644
--- a/instack_undercloud/tests/test_undercloud.py
+++ b/instack_undercloud/tests/test_undercloud.py
@@ -380,6 +380,15 @@ class TestNoIPChange(BaseTestCase):
380 undercloud._validate_no_ip_change() 380 undercloud._validate_no_ip_change()
381 381
382 @mock.patch('instack_undercloud.undercloud.open') 382 @mock.patch('instack_undercloud.undercloud.open')
383 @mock.patch('os.path.isfile', return_value=True)
384 def test_update_empty(self, mock_isfile, mock_open):
385 # This would be a way to disable os-net-config from running
386 mock_open.side_effect = [
387 mock.mock_open(read_data='').return_value,
388 ]
389 undercloud._validate_no_ip_change()
390
391 @mock.patch('instack_undercloud.undercloud.open')
383 @mock.patch('json.loads') 392 @mock.patch('json.loads')
384 @mock.patch('os.path.isfile', return_value=True) 393 @mock.patch('os.path.isfile', return_value=True)
385 def test_update_mismatch(self, mock_isfile, mock_loads, mock_open): 394 def test_update_mismatch(self, mock_isfile, mock_loads, mock_open):
diff --git a/instack_undercloud/undercloud.py b/instack_undercloud/undercloud.py
index 44da860..aad7006 100644
--- a/instack_undercloud/undercloud.py
+++ b/instack_undercloud/undercloud.py
@@ -818,16 +818,22 @@ def _validate_no_ip_change():
818 need to disallow it early in the install before configurations start to 818 need to disallow it early in the install before configurations start to
819 be changed. 819 be changed.
820 """ 820 """
821 os_net_config_file = '/etc/os-net-config/config.json' 821 if CONF.net_config_override:
822 os_net_config_file = CONF.net_config_override
823 else:
824 os_net_config_file = '/etc/os-net-config/config.json'
822 # Nothing to do if we haven't already installed 825 # Nothing to do if we haven't already installed
823 if not os.path.isfile( 826 if not os.path.isfile(
824 os.path.expanduser(os_net_config_file)): 827 os.path.expanduser(os_net_config_file)):
825 return 828 return
826 with open(os_net_config_file) as f:
827 network_config = json.loads(f.read())
828 try: 829 try:
830 with open(os_net_config_file) as f:
831 network_config = json.loads(f.read())
829 ctlplane = [i for i in network_config.get('network_config', []) 832 ctlplane = [i for i in network_config.get('network_config', [])
830 if i['name'] == 'br-ctlplane'][0] 833 if i['name'] == 'br-ctlplane'][0]
834 except ValueError:
835 # File was empty
836 return
831 except IndexError: 837 except IndexError:
832 # Nothing to check if br-ctlplane wasn't configured 838 # Nothing to check if br-ctlplane wasn't configured
833 return 839 return
diff --git a/undercloud.conf.sample b/undercloud.conf.sample
index 78a3aae..9696746 100644
--- a/undercloud.conf.sample
+++ b/undercloud.conf.sample
@@ -120,9 +120,8 @@
120 120
121# Path to network config override template. If set, this template will 121# Path to network config override template. If set, this template will
122# be used to configure the networking via os-net-config. Must be in 122# be used to configure the networking via os-net-config. Must be in
123# json format. Templated tags can be used within the template, see 123# json format. If you wish to disable os-net-config you can use an
124# instack-undercloud/elements/undercloud-stack-config/net- 124# set this location to point to an empty file.
125# config.json.template for example tags (string value)
126#net_config_override = 125#net_config_override =
127 126
128# Network interface on which inspection dnsmasq will listen. If in 127# Network interface on which inspection dnsmasq will listen. If in