From 5a10779e4533cb38d42a15f01923789769aeb683 Mon Sep 17 00:00:00 2001 From: Frode Nordahl Date: Tue, 8 Sep 2020 16:11:39 +0200 Subject: [PATCH] Re-order checks in networking auto-detection To support OVS to OVN migration checks we want the basic overcloud configure job to set up N-OVS and/or N-GW when present and the OVN pre migration configure job will copy the configuration for us. --- .../test_zaza_utilities_openstack.py | 13 ++++++++++-- zaza/openstack/utilities/openstack.py | 20 +++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/unit_tests/utilities/test_zaza_utilities_openstack.py b/unit_tests/utilities/test_zaza_utilities_openstack.py index e15ce96..02bd578 100644 --- a/unit_tests/utilities/test_zaza_utilities_openstack.py +++ b/unit_tests/utilities/test_zaza_utilities_openstack.py @@ -1227,6 +1227,13 @@ class TestOpenStackUtils(ut_utils.BaseTestCase): self.get_application.side_effect = [KeyError, KeyError] self.assertFalse(openstack_utils.ovn_present()) + def test_ngw_present(self): + self.patch_object(openstack_utils.model, 'get_application') + self.get_application.side_effect = None + self.assertTrue(openstack_utils.ngw_present()) + self.get_application.side_effect = KeyError + self.assertFalse(openstack_utils.ngw_present()) + def test_configure_gateway_ext_port(self): # FIXME: this is not a complete unit test for the function as one did # not exist at all I'm adding this to test one bit and we'll add more @@ -1234,10 +1241,12 @@ class TestOpenStackUtils(ut_utils.BaseTestCase): self.patch_object(openstack_utils, 'deprecated_external_networking') self.patch_object(openstack_utils, 'dvr_enabled') self.patch_object(openstack_utils, 'ovn_present') + self.patch_object(openstack_utils, 'ngw_present') self.patch_object(openstack_utils, 'get_gateway_uuids') self.patch_object(openstack_utils, 'get_admin_net') - self.dvr_enabled = False - self.ovn_present = False + self.dvr_enabled.return_value = False + self.ovn_present.return_value = False + self.ngw_present.return_value = True self.get_admin_net.return_value = {'id': 'fakeid'} novaclient = mock.MagicMock() diff --git a/zaza/openstack/utilities/openstack.py b/zaza/openstack/utilities/openstack.py index 8d6c172..e524f79 100644 --- a/zaza/openstack/utilities/openstack.py +++ b/zaza/openstack/utilities/openstack.py @@ -554,6 +554,20 @@ def dvr_enabled(): return get_application_config_option('neutron-api', 'enable-dvr') +def ngw_present(): + """Check whether Neutron Gateway is present in deployment. + + :returns: True when Neutron Gateway is present, False otherwise + :rtype: bool + """ + try: + model.get_application('neutron-gateway') + return True + except KeyError: + pass + return False + + def ovn_present(): """Check whether OVN is present in deployment. @@ -721,6 +735,9 @@ def configure_gateway_ext_port(novaclient, neutronclient, net_id=None, except KeyError: # neutron-gateway not in deployment pass + elif ngw_present(): + uuids = itertools.islice(get_gateway_uuids(), limit_gws) + application_names = ['neutron-gateway'] elif ovn_present(): uuids = itertools.islice(get_ovn_uuids(), limit_gws) application_names = ['ovn-chassis'] @@ -735,8 +752,7 @@ def configure_gateway_ext_port(novaclient, neutronclient, net_id=None, config.update({'ovn-bridge-mappings': 'physnet1:br-ex'}) add_dataport_to_netplan = True else: - uuids = itertools.islice(get_gateway_uuids(), limit_gws) - application_names = ['neutron-gateway'] + raise RuntimeError('Unable to determine charm network topology.') if not net_id: net_id = get_admin_net(neutronclient)['id']