diff --git a/hooks/neutron_utils.py b/hooks/neutron_utils.py index 90255f21..48b20bea 100644 --- a/hooks/neutron_utils.py +++ b/hooks/neutron_utils.py @@ -269,7 +269,16 @@ def get_packages(): plugin = config('plugin') packages = deepcopy(GATEWAY_PKGS[plugin]) source = os_release('neutron-common') - if plugin == 'ovs': + if plugin == OVS: + if source >= 'liberty': + # Switch out mysql driver + packages.remove('python-mysqldb') + packages.append('python-pymysql') + if source >= 'mitaka': + # Switch out to actual ovs agent package + packages.remove('neutron-plugin-openvswitch-agent') + packages.append('neutron-openvswitch-agent') + if plugin in (OVS, OVS_ODL): if (source >= 'icehouse' and lsb_release()['DISTRIB_CODENAME'] < 'utopic'): # NOTE(jamespage) neutron-vpn-agent supercedes l3-agent for @@ -279,14 +288,6 @@ def get_packages(): packages.append('openswan') if source >= 'kilo': packages.append('python-neutron-fwaas') - if source >= 'liberty': - # Switch out mysql driver - packages.remove('python-mysqldb') - packages.append('python-pymysql') - if source >= 'mitaka': - # Switch out to actual ovs agent package - packages.remove('neutron-plugin-openvswitch-agent') - packages.append('neutron-openvswitch-agent') if source >= 'newton': # LBaaS v1 dropped in newton packages.remove('neutron-lbaas-agent') diff --git a/unit_tests/test_neutron_utils.py b/unit_tests/test_neutron_utils.py index c6c8b01d..a04fccf1 100644 --- a/unit_tests/test_neutron_utils.py +++ b/unit_tests/test_neutron_utils.py @@ -179,6 +179,31 @@ class TestNeutronUtils(CharmTestCase): self.assertFalse('python-mysqldb' in packages) self.assertTrue('python-pymysql' in packages) + @patch.object(neutron_utils, 'git_install_requested') + def test_get_packages_ovsodl_icehouse(self, git_requested): + git_requested.return_value = False + self.config.return_value = 'ovs-odl' + self.os_release.return_value = 'icehouse' + packages = neutron_utils.get_packages() + self.assertTrue('neutron-metering-agent' in packages) + self.assertFalse('neutron-plugin-metering-agent' in packages) + self.assertFalse('neutron-plugin-openvswitch-agent' in packages) + self.assertFalse('neutron-openvswitch-agent' in packages) + self.assertTrue('neutron-lbaas-agent' in packages) + + @patch.object(neutron_utils, 'git_install_requested') + def test_get_packages_ovsodl_newton(self, git_requested): + git_requested.return_value = False + self.config.return_value = 'ovs-odl' + self.os_release.return_value = 'newton' + packages = neutron_utils.get_packages() + self.assertTrue('neutron-metering-agent' in packages) + self.assertFalse('neutron-plugin-metering-agent' in packages) + self.assertFalse('neutron-plugin-openvswitch-agent' in packages) + self.assertFalse('neutron-openvswitch-agent' in packages) + self.assertFalse('neutron-lbaas-agent' in packages) + self.assertTrue('neutron-lbaasv2-agent' in packages) + @patch.object(neutron_utils, 'git_install_requested') def test_get_packages_l3ha(self, git_requested): git_requested.return_value = False @@ -500,6 +525,45 @@ class TestNeutronUtils(CharmTestCase): self.assertDictEqual(neutron_utils.restart_map(), ex_map) + @patch.object(neutron_utils, 'get_packages') + def test_restart_map_ovs_odl_newton(self, mock_get_packages): + self.config.return_value = 'ovs-odl' + mock_get_packages.return_value = ['neutron-vpn-agent'] + self.os_release.return_value = 'newton' + ex_map = { + neutron_utils.NEUTRON_CONF: ['neutron-dhcp-agent', + 'neutron-metadata-agent', + 'neutron-metering-agent', + 'neutron-lbaasv2-agent', + 'neutron-vpn-agent'], + neutron_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'], + neutron_utils.NEUTRON_LBAAS_AGENT_CONF: + ['neutron-lbaasv2-agent'], + neutron_utils.NEUTRON_METADATA_AGENT_CONF: + ['neutron-metadata-agent'], + neutron_utils.NEUTRON_VPNAAS_AGENT_CONF: ['neutron-vpn-agent'], + neutron_utils.NEUTRON_L3_AGENT_CONF: ['neutron-vpn-agent'], + neutron_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'], + neutron_utils.NEUTRON_FWAAS_CONF: ['neutron-vpn-agent'], + neutron_utils.NEUTRON_METERING_AGENT_CONF: + ['neutron-metering-agent'], + neutron_utils.NOVA_CONF: ['nova-api-metadata'], + neutron_utils.EXT_PORT_CONF: ['ext-port'], + neutron_utils.PHY_NIC_MTU_CONF: ['os-charm-phy-nic-mtu'], + neutron_utils.NEUTRON_DHCP_AA_PROFILE_PATH: ['neutron-dhcp-agent'], + neutron_utils.NEUTRON_L3_AA_PROFILE_PATH: ['neutron-vpn-agent'], + neutron_utils.NEUTRON_LBAAS_AA_PROFILE_PATH: + ['neutron-lbaasv2-agent'], + neutron_utils.NEUTRON_METADATA_AA_PROFILE_PATH: + ['neutron-metadata-agent'], + neutron_utils.NEUTRON_METERING_AA_PROFILE_PATH: + ['neutron-metering-agent'], + neutron_utils.NOVA_API_METADATA_AA_PROFILE_PATH: + ['nova-api-metadata'], + } + + self.assertEqual(neutron_utils.restart_map(), ex_map) + @patch('charmhelpers.contrib.openstack.templating.OSConfigRenderer') def test_register_configs_nsx(self, mock_renderer): self.config.return_value = 'nsx'