From d57a6e9a4e8ad65fab37fc6f09c66a8f87a0f383 Mon Sep 17 00:00:00 2001 From: Liam Young Date: Thu, 5 Jan 2017 13:49:04 +0000 Subject: [PATCH] Do not create MTU upstart scripts on xenial+ MTU scripts are no longer needed as MAAS 1.9 can set the mtu and bring up the interfaces. The charm has no systemd versions of the 'os-charm-phy-mic-mtu' and 'ext-port' scripts either so for xenial to set mtu sizes on physical nics use MAAS 1.9 and appropriate network config Change-Id: I3aa4d2a80a08dd605d4ae08d53f35282017e1009 Partial-Bug: 1566786 --- hooks/neutron_ovs_utils.py | 19 +++++++++++++++---- unit_tests/test_neutron_ovs_utils.py | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/hooks/neutron_ovs_utils.py b/hooks/neutron_ovs_utils.py index 6f03fd95..f24076d1 100644 --- a/hooks/neutron_ovs_utils.py +++ b/hooks/neutron_ovs_utils.py @@ -271,6 +271,7 @@ def resource_map(): Dynamically generate a map of resources that will be managed for a single hook execution. ''' + drop_config = [] resource_map = deepcopy(BASE_RESOURCE_MAP) if use_dvr(): resource_map.update(DVR_RESOURCE_MAP) @@ -285,7 +286,7 @@ def resource_map(): # Remap any service names as required if os_release('neutron-common', base='icehouse') >= 'mitaka': # ml2_conf.ini -> openvswitch_agent.ini - del resource_map[ML2_CONF] + drop_config.append(ML2_CONF) # drop of -plugin from service name resource_map[NEUTRON_CONF]['services'].remove( 'neutron-plugin-openvswitch-agent' @@ -294,10 +295,20 @@ def resource_map(): 'neutron-openvswitch-agent' ) if not use_dpdk(): - del resource_map[DPDK_INTERFACES] + drop_config.append(DPDK_INTERFACES) else: - del resource_map[OVS_CONF] - del resource_map[DPDK_INTERFACES] + drop_config.extend([OVS_CONF, DPDK_INTERFACES]) + + # Use MAAS1.9 for MTU and external port config on xenial and above + if float(lsb_release()['DISTRIB_RELEASE']) >= 16.04: + drop_config.extend([EXT_PORT_CONF, PHY_NIC_MTU_CONF]) + + for _conf in drop_config: + try: + del resource_map[_conf] + except KeyError: + pass + return resource_map diff --git a/unit_tests/test_neutron_ovs_utils.py b/unit_tests/test_neutron_ovs_utils.py index 765010a6..75a4f78c 100644 --- a/unit_tests/test_neutron_ovs_utils.py +++ b/unit_tests/test_neutron_ovs_utils.py @@ -274,6 +274,32 @@ class TestNeutronOVSUtils(CharmTestCase): [self.assertIn(q_conf, _map.keys()) for q_conf in confs] self.assertEqual(_map[nutils.NEUTRON_CONF]['services'], svcs) + @patch.object(nutils, 'use_dvr') + def test_resource_map_mtu_trusty(self, _use_dvr): + _use_dvr.return_value = False + self.os_release.return_value = 'mitaka' + self.lsb_release.return_value = {'DISTRIB_RELEASE': '14.04'} + _map = nutils.resource_map() + self.assertTrue(nutils.NEUTRON_CONF in _map.keys()) + self.assertTrue(nutils.PHY_NIC_MTU_CONF in _map.keys()) + self.assertFalse(nutils.EXT_PORT_CONF in _map.keys()) + _use_dvr.return_value = True + _map = nutils.resource_map() + self.assertTrue(nutils.EXT_PORT_CONF in _map.keys()) + + @patch.object(nutils, 'use_dvr') + def test_resource_map_mtu_xenial(self, _use_dvr): + _use_dvr.return_value = False + self.os_release.return_value = 'mitaka' + self.lsb_release.return_value = {'DISTRIB_RELEASE': '16.04'} + _map = nutils.resource_map() + self.assertTrue(nutils.NEUTRON_CONF in _map.keys()) + self.assertFalse(nutils.PHY_NIC_MTU_CONF in _map.keys()) + self.assertFalse(nutils.EXT_PORT_CONF in _map.keys()) + _use_dvr.return_value = True + _map = nutils.resource_map() + self.assertFalse(nutils.EXT_PORT_CONF in _map.keys()) + @patch.object(nutils, 'use_dvr') def test_restart_map(self, _use_dvr): _use_dvr.return_value = False