diff --git a/hooks/neutron_ovs_context.py b/hooks/neutron_ovs_context.py index d9c5ec1e..920942f9 100644 --- a/hooks/neutron_ovs_context.py +++ b/hooks/neutron_ovs_context.py @@ -45,6 +45,10 @@ from charmhelpers.contrib.openstack.context import ( NeutronAPIContext, parse_data_port_mappings ) +from charmhelpers.contrib.openstack.utils import ( + os_release, + CompareOpenStackReleases, +) import charmhelpers.contrib.openstack.utils as os_utils from charmhelpers.core.unitdata import kv @@ -351,6 +355,22 @@ class L3AgentContext(OSContextGenerator): NFG_LOG_BURST_LIMIT_MIN ) + cmp_os_release = CompareOpenStackReleases(os_release('neutron-common')) + + l3_extension_plugins = neutron_api_settings.get( + 'l3_extension_plugins', []) + + # per Change-Id If1b332eb0f581e9acba111f79ba578a0b7081dd2 + # only enable it for stein although fwaasv2 was added in Queens + is_stein = cmp_os_release >= 'stein' + if is_stein: + l3_extension_plugins.append('fwaas_v2') + + if (is_stein and neutron_api_settings.get('enable_nfg_logging')): + l3_extension_plugins.append('fwaas_v2_log') + + ctxt['l3_extension_plugins'] = ','.join(l3_extension_plugins) + return ctxt diff --git a/templates/rocky/l3_agent.ini b/templates/rocky/l3_agent.ini new file mode 100644 index 00000000..4eb2f1c1 --- /dev/null +++ b/templates/rocky/l3_agent.ini @@ -0,0 +1,20 @@ +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +# {{ restart_trigger_l3agent }} +############################################################################### + +[DEFAULT] +interface_driver = openvswitch +agent_mode = {{ agent_mode }} +{% if external_configuration_new -%} +gateway_external_network_id = +external_network_bridge = +{% endif %} +{% if use_l3ha and agent_mode == 'dvr_snat' -%} +ha_vrrp_health_check_interval = 30 +{% endif %} + +[AGENT] +extensions = {{ l3_extension_plugins }} + diff --git a/templates/stein/l3_agent.ini b/templates/stein/l3_agent.ini index 8da1b9a3..929b48b3 100644 --- a/templates/stein/l3_agent.ini +++ b/templates/stein/l3_agent.ini @@ -14,8 +14,8 @@ external_network_bridge = {% endif %} [AGENT] +extensions = {{ l3_extension_plugins }} {% if enable_nfg_logging -%} -extensions = fwaas_v2,fwaas_v2_log [network_log] {% if nfg_log_rate_limit -%} rate_limit = {{ nfg_log_rate_limit }} @@ -24,6 +24,4 @@ burst_limit = {{ nfg_log_burst_limit }} {% if nfg_log_output_base -%} local_output_log_base = {{ nfg_log_output_base }} {% endif -%} -{% else %} -extensions = fwaas_v2 -{% endif -%} \ No newline at end of file +{% endif -%} diff --git a/unit_tests/test_neutron_ovs_context.py b/unit_tests/test_neutron_ovs_context.py index 44deb4a0..4ffd5632 100644 --- a/unit_tests/test_neutron_ovs_context.py +++ b/unit_tests/test_neutron_ovs_context.py @@ -458,18 +458,24 @@ class L3AgentContextTest(CharmTestCase): def tearDown(self): super(L3AgentContextTest, self).tearDown() + @patch.object(context, 'os_release') + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_package') @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids') @patch.object(charmhelpers.contrib.openstack.context, 'related_units') - def test_dvr_enabled(self, _runits, _rids, _rget): + def test_dvr_enabled(self, _runits, _rids, _rget, + _get_os_cdnm_pkg, _os_release): _runits.return_value = ['unit1'] _rids.return_value = ['rid2'] + _os_release.return_value = 'stein' rdata = { 'neutron-security-groups': 'True', 'enable-dvr': 'True', 'l2-population': 'True', 'overlay-network-type': 'vxlan', 'network-device-mtu': 1500, + 'l3_extension_plugins': 'fwaas_v2', } _rget.side_effect = lambda *args, **kwargs: rdata self.assertEqual( @@ -481,15 +487,21 @@ class L3AgentContextTest(CharmTestCase): 'nfg_log_burst_limit': 25, 'nfg_log_output_base': None, 'nfg_log_rate_limit': None, + 'l3_extension_plugins': 'fwaas_v2', } ) + @patch.object(context, 'os_release') + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_package') @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids') @patch.object(charmhelpers.contrib.openstack.context, 'related_units') - def test_dvr_enabled_l3ha_enabled(self, _runits, _rids, _rget): + def test_dvr_enabled_l3ha_enabled(self, _runits, _rids, _rget, + _get_os_cdnm_pkg, _os_release): _runits.return_value = ['unit1'] _rids.return_value = ['rid2'] + _os_release.return_value = 'rocky' rdata = { 'neutron-security-groups': 'True', 'enable-dvr': 'True', @@ -508,17 +520,23 @@ class L3AgentContextTest(CharmTestCase): 'nfg_log_burst_limit': 25, 'nfg_log_output_base': None, 'nfg_log_rate_limit': None, + 'l3_extension_plugins': '', } ) + @patch.object(context, 'os_release') + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_package') @patch.object(context, 'validate_nfg_log_path') @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids') @patch.object(charmhelpers.contrib.openstack.context, 'related_units') def test_dvr_nfg_enabled(self, _runits, _rids, _rget, - _validate_nfg_log_path): + _validate_nfg_log_path, + _get_os_cdnm_pkg, _os_release): _runits.return_value = ['unit1'] _rids.return_value = ['rid2'] + _os_release.return_value = 'stein' rdata = { 'neutron-security-groups': 'True', 'enable-dvr': 'True', @@ -527,6 +545,7 @@ class L3AgentContextTest(CharmTestCase): 'network-device-mtu': 1500, 'enable-nfg-logging': 'True', 'use_l3ha': False, + 'l3_extension_plugins': 'fwaas_v2,fwaas_v2_log', } _rget.side_effect = lambda *args, **kwargs: rdata _validate_nfg_log_path.side_effect = lambda x: x @@ -543,17 +562,23 @@ class L3AgentContextTest(CharmTestCase): 'nfg_log_output_base': '/var/log/neutron/firewall.log', 'nfg_log_rate_limit': 200, 'use_l3ha': False, + 'l3_extension_plugins': 'fwaas_v2,fwaas_v2_log', } ) + @patch.object(context, 'os_release') + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_package') @patch.object(context, 'validate_nfg_log_path') @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids') @patch.object(charmhelpers.contrib.openstack.context, 'related_units') def test_dvr_nfg_enabled_mins(self, _runits, _rids, _rget, - _validate_nfg_log_path): + _validate_nfg_log_path, + _get_os_cdnm_pkg, _os_release): _runits.return_value = ['unit1'] _rids.return_value = ['rid2'] + _os_release.return_value = 'stein' rdata = { 'neutron-security-groups': 'True', 'enable-dvr': 'True', @@ -561,6 +586,7 @@ class L3AgentContextTest(CharmTestCase): 'overlay-network-type': 'vxlan', 'network-device-mtu': 1500, 'enable-nfg-logging': 'True', + 'l3_extension_plugins': 'fwaas_v2,fwaas_v2_log', } _rget.side_effect = lambda *args, **kwargs: rdata _validate_nfg_log_path.side_effect = lambda x: x @@ -577,22 +603,29 @@ class L3AgentContextTest(CharmTestCase): 'nfg_log_output_base': '/var/log/neutron/firewall.log', 'nfg_log_rate_limit': 100, 'use_l3ha': False, + 'l3_extension_plugins': 'fwaas_v2,fwaas_v2_log', } ) + @patch.object(context, 'os_release') + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_package') @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids') @patch.object(charmhelpers.contrib.openstack.context, 'related_units') - def test_dvr_enabled_dvr_snat_enabled(self, _runits, _rids, _rget): + def test_dvr_enabled_dvr_snat_enabled(self, _runits, _rids, _rget, + _get_os_cdnm_pkg, _os_release): self.test_config.set('use-dvr-snat', True) _runits.return_value = ['unit1'] _rids.return_value = ['rid2'] + _os_release.return_value = 'stein' rdata = { 'neutron-security-groups': 'True', 'enable-dvr': 'True', 'l2-population': 'True', 'overlay-network-type': 'vxlan', 'network-device-mtu': 1500, + 'l3_extension_plugins': 'fwaas_v2,fwaas_v2_log', } _rget.side_effect = lambda *args, **kwargs: rdata self.assertEqual( @@ -604,21 +637,28 @@ class L3AgentContextTest(CharmTestCase): 'nfg_log_burst_limit': 25, 'nfg_log_output_base': None, 'nfg_log_rate_limit': None, + 'l3_extension_plugins': 'fwaas_v2', } ) + @patch.object(context, 'os_release') + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_package') @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids') @patch.object(charmhelpers.contrib.openstack.context, 'related_units') - def test_dvr_disabled(self, _runits, _rids, _rget): + def test_dvr_disabled(self, _runits, _rids, _rget, + _get_os_cdnm_pkg, _os_release): _runits.return_value = ['unit1'] _rids.return_value = ['rid2'] + _os_release.return_value = 'stein' rdata = { 'neutron-security-groups': 'True', 'enable-dvr': 'False', 'l2-population': 'True', 'overlay-network-type': 'vxlan', 'network-device-mtu': 1500, + 'l3_extension_plugins': 'fwaas_v2', } _rget.side_effect = lambda *args, **kwargs: rdata self.assertEqual(context.L3AgentContext()(), { @@ -627,6 +667,7 @@ class L3AgentContextTest(CharmTestCase): 'nfg_log_burst_limit': 25, 'nfg_log_output_base': None, 'nfg_log_rate_limit': None, + 'l3_extension_plugins': 'fwaas_v2', })