diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index 68d84921..3efaf01e 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -10,10 +10,12 @@ from charmhelpers.contrib.hahelpers.cluster import ( determine_apache_port, ) + def get_l2population(): plugin = config('neutron-plugin') return config('l2-population') if plugin == "ovs" else False + class ApacheSSLContext(context.ApacheSSLContext): interfaces = ['https'] diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index e81ac10f..6cb970f4 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -127,6 +127,7 @@ class NeutronAPIContextsTest(CharmTestCase): 'external_network': 'bob', 'neutron_bind_port': self.api_port, 'verbose': True, + 'l2_population': True, } with patch.object(napi_ctxt, '_ensure_packages'): self.assertEquals(ctxt_data, napi_ctxt()) diff --git a/unit_tests/test_neutron_api_hooks.py b/unit_tests/test_neutron_api_hooks.py index 04d73901..6bda03c7 100644 --- a/unit_tests/test_neutron_api_hooks.py +++ b/unit_tests/test_neutron_api_hooks.py @@ -30,6 +30,9 @@ TO_PATCH = [ 'determine_ports', 'do_openstack_upgrade', 'execd_preinstall', + 'get_iface_for_address', + 'get_l2population', + 'get_netmask_for_address', 'is_leader', 'is_relation_made', 'log', @@ -40,8 +43,6 @@ TO_PATCH = [ 'relation_ids', 'relation_set', 'unit_get', - 'get_iface_for_address', - 'get_netmask_for_address', ] NEUTRON_CONF_DIR = "/etc/neutron" @@ -256,10 +257,12 @@ class NeutronAPIHooksTests(CharmTestCase): self._call_hook('neutron-api-relation-changed') self.assertTrue(self.CONFIGS.write.called_with(NEUTRON_CONF)) - def test_neutron_plugin_api_relation_joined(self): + def test_neutron_plugin_api_relation_joined_nol2(self): _relation_data = { 'neutron-security-groups': False, + 'l2-population': False, } + self.get_l2population.return_value = False self._call_hook('neutron-plugin-api-relation-joined') self.relation_set.assert_called_with( relation_id=None,