diff --git a/hooks/charmhelpers/contrib/openstack/context.py b/hooks/charmhelpers/contrib/openstack/context.py index b67dafda..0ec935eb 100644 --- a/hooks/charmhelpers/contrib/openstack/context.py +++ b/hooks/charmhelpers/contrib/openstack/context.py @@ -2379,6 +2379,12 @@ class DHCPAgentContext(OSContextGenerator): ctxt['enable_metadata_network'] = True ctxt['enable_isolated_metadata'] = True + ctxt['append_ovs_config'] = False + cmp_release = CompareOpenStackReleases( + os_release('neutron-common', base='icehouse')) + if cmp_release >= 'queens' and config('enable-dpdk'): + ctxt['append_ovs_config'] = True + return ctxt @staticmethod diff --git a/hooks/neutron_ovs_utils.py b/hooks/neutron_ovs_utils.py index f086102f..02525c3b 100644 --- a/hooks/neutron_ovs_utils.py +++ b/hooks/neutron_ovs_utils.py @@ -147,6 +147,7 @@ PURGE_PACKAGES = [ PHY_NIC_MTU_CONF = '/etc/init/os-charm-phy-nic-mtu.conf' TEMPLATES = 'templates/' OVS_DEFAULT = '/etc/default/openvswitch-switch' +NEUTRON_DHCP_DEFAULT = '/etc/default/neutron-dhcp-agent' DPDK_INTERFACES = '/etc/dpdk/interfaces' NEUTRON_SRIOV_AGENT_CONF = os.path.join(NEUTRON_CONF_DIR, 'plugins/ml2/sriov_agent.ini') @@ -211,6 +212,10 @@ DHCP_RESOURCE_MAP = OrderedDict([ 'services': ['neutron-dhcp-agent'], 'contexts': [DHCPAgentContext()], }), + (NEUTRON_DHCP_DEFAULT, { + 'services': ['neutron-dhcp-agent'], + 'contexts': [DHCPAgentContext()], + }), ]) DVR_RESOURCE_MAP = OrderedDict([ (NEUTRON_L3_AGENT_CONF, { @@ -387,6 +392,8 @@ def resource_map(): """ drop_config = [] resource_map = deepcopy(BASE_RESOURCE_MAP) + # Remap any service names as required + _os_release = os_release('neutron-common', base='icehouse') if use_dvr(): resource_map.update(DVR_RESOURCE_MAP) resource_map.update(METADATA_RESOURCE_MAP) @@ -397,8 +404,8 @@ def resource_map(): resource_map.update(DHCP_RESOURCE_MAP) metadata_services = ['neutron-metadata-agent', 'neutron-dhcp-agent'] resource_map[NEUTRON_CONF]['services'] += metadata_services - # Remap any service names as required - _os_release = os_release('neutron-common', base='icehouse') + if use_dpdk() and CompareOpenStackReleases(_os_release) >= 'queens': + resource_map[OVS_CONF]['services'] += ['neutron-dhcp-agent'] if CompareOpenStackReleases(_os_release) >= 'mitaka': # ml2_conf.ini -> openvswitch_agent.ini drop_config.append(ML2_CONF) diff --git a/templates/neutron-dhcp-agent b/templates/neutron-dhcp-agent new file mode 100644 index 00000000..eaf647ce --- /dev/null +++ b/templates/neutron-dhcp-agent @@ -0,0 +1,11 @@ +# This is a POSIX shell fragment -*- sh -*- +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +# Configuration managed by neutron-openvswitch charm +# Service restart triggered by remote application: {{ restart_trigger }} +# {{ restart_trigger_ovs }} +############################################################################### +{% if append_ovs_config -%} +DAEMON_ARGS="$DAEMON_ARGS --config-file=/etc/neutron/plugins/ml2/openvswitch_agent.ini" +{% endif -%} diff --git a/unit_tests/test_neutron_ovs_utils.py b/unit_tests/test_neutron_ovs_utils.py index a897fe53..d9f02077 100644 --- a/unit_tests/test_neutron_ovs_utils.py +++ b/unit_tests/test_neutron_ovs_utils.py @@ -569,10 +569,13 @@ class TestNeutronOVSUtils(CharmTestCase): @patch.object(nutils, 'use_l3ha') @patch.object(nutils, 'use_dpdk') @patch.object(nutils, 'use_dvr') - def test_restart_map(self, mock_use_dvr, mock_use_dpdk, mock_use_l3ha): + @patch.object(nutils, 'enable_local_dhcp') + def test_restart_map(self, mock_enable_local_dhcp, mock_use_dvr, + mock_use_dpdk, mock_use_l3ha): mock_use_dvr.return_value = False mock_use_l3ha.return_value = False mock_use_dpdk.return_value = False + mock_enable_local_dhcp.return_value = False self.os_release.return_value = "mitaka" self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'} ML2CONF = "/etc/neutron/plugins/ml2/openvswitch_agent.ini" @@ -580,7 +583,7 @@ class TestNeutronOVSUtils(CharmTestCase): expect = OrderedDict([ (nutils.NEUTRON_CONF, ['neutron-openvswitch-agent']), (ML2CONF, ['neutron-openvswitch-agent']), - (nutils.OVS_DEFAULT, ['openvswitch-switch']), + (nutils.OVS_DEFAULT, ['openvswitch-switch']) ]) for item in _restart_map: self.assertTrue(item in _restart_map)