diff --git a/hooks/neutron_ovs_utils.py b/hooks/neutron_ovs_utils.py index 469d3de3..9c0ed2ca 100644 --- a/hooks/neutron_ovs_utils.py +++ b/hooks/neutron_ovs_utils.py @@ -84,6 +84,7 @@ GIT_PACKAGE_BLACKLIST = [ 'neutron-server', 'neutron-plugin-openvswitch', 'neutron-plugin-openvswitch-agent', + 'neutron-openvswitch-agent', ] NOVA_CONF_DIR = "/etc/nova" @@ -94,6 +95,7 @@ NEUTRON_DEFAULT = '/etc/default/neutron-server' NEUTRON_L3_AGENT_CONF = "/etc/neutron/l3_agent.ini" NEUTRON_FWAAS_CONF = "/etc/neutron/fwaas_driver.ini" ML2_CONF = '%s/plugins/ml2/ml2_conf.ini' % NEUTRON_CONF_DIR +OVS_CONF = '%s/plugins/ml2/openvswitch_agent.ini' % NEUTRON_CONF_DIR EXT_PORT_CONF = '/etc/init/ext-port.conf' NEUTRON_METADATA_AGENT_CONF = "/etc/neutron/metadata_agent.ini" DVR_PACKAGES = ['neutron-l3-agent'] @@ -114,6 +116,10 @@ BASE_RESOURCE_MAP = OrderedDict([ 'services': ['neutron-plugin-openvswitch-agent'], 'contexts': [neutron_ovs_context.OVSPluginContext()], }), + (OVS_CONF, { + 'services': ['neutron-openvswitch-agent'], + 'contexts': [neutron_ovs_context.OVSPluginContext()], + }), (PHY_NIC_MTU_CONF, { 'services': ['os-charm-phy-nic-mtu'], 'contexts': [context.PhyNICMTUContext()], @@ -193,6 +199,11 @@ def determine_packages(): if p in pkgs: pkgs.remove(p) + release = os_release('neutron-common', base='icehouse') + if release >= 'mitaka' and 'neutron-plugin-openvswitch-agent' in pkgs: + pkgs.remove('neutron-plugin-openvswitch-agent') + pkgs.append('neutron-openvswitch-agent') + return pkgs @@ -221,6 +232,19 @@ 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 + if os_release('neutron-common', base='icehouse') >= 'mitaka': + # ml2_conf.ini -> openvswitch_agent.ini + del resource_map[ML2_CONF] + # drop of -plugin from service name + resource_map[NEUTRON_CONF]['services'].remove( + 'neutron-plugin-openvswitch-agent' + ) + resource_map[NEUTRON_CONF]['services'].append( + 'neutron-openvswitch-agent' + ) + else: + del resource_map[OVS_CONF] return resource_map diff --git a/templates/mitaka/openvswitch_agent.ini b/templates/mitaka/openvswitch_agent.ini new file mode 100644 index 00000000..7422de8d --- /dev/null +++ b/templates/mitaka/openvswitch_agent.ini @@ -0,0 +1,26 @@ +# mitaka +############################################################################### +# [ WARNING ] +# Configuration file maintained by Juju. Local changes may be overwritten. +# Config managed by neutron-openvswitch charm +############################################################################### +[ovs] +enable_tunneling = True +local_ip = {{ local_ip }} +bridge_mappings = {{ bridge_mappings }} + +[agent] +tunnel_types = {{ overlay_network_type }} +l2_population = {{ l2_population }} +enable_distributed_routing = {{ distributed_routing }} +{% if veth_mtu -%} +veth_mtu = {{ veth_mtu }} +{% endif %} + +[securitygroup] +{% if neutron_security_groups -%} +enable_security_group = True +firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver +{% else -%} +enable_security_group = False +{% endif -%} diff --git a/unit_tests/test_neutron_ovs_utils.py b/unit_tests/test_neutron_ovs_utils.py index 0125cffa..f5b8774b 100644 --- a/unit_tests/test_neutron_ovs_utils.py +++ b/unit_tests/test_neutron_ovs_utils.py @@ -111,12 +111,29 @@ class TestNeutronOVSUtils(CharmTestCase): self.test_config.set('enable-local-dhcp-and-metadata', False) _git_requested.return_value = False _use_dvr.return_value = False - _os_rel.return_value = 'trusty' + _os_rel.return_value = 'icehouse' + self.os_release.return_value = 'icehouse' _head_pkgs.return_value = head_pkg pkg_list = nutils.determine_packages() expect = ['neutron-plugin-openvswitch-agent', head_pkg] self.assertItemsEqual(pkg_list, expect) + @patch.object(nutils, 'use_dvr') + @patch.object(nutils, 'git_install_requested') + @patch.object(charmhelpers.contrib.openstack.neutron, 'os_release') + @patch.object(charmhelpers.contrib.openstack.neutron, 'headers_package') + def test_determine_packages_mitaka(self, _head_pkgs, _os_rel, + _git_requested, _use_dvr): + self.test_config.set('enable-local-dhcp-and-metadata', False) + _git_requested.return_value = False + _use_dvr.return_value = False + _os_rel.return_value = 'mitaka' + self.os_release.return_value = 'mitaka' + _head_pkgs.return_value = head_pkg + pkg_list = nutils.determine_packages() + expect = ['neutron-openvswitch-agent', head_pkg] + self.assertItemsEqual(pkg_list, expect) + @patch.object(nutils, 'use_dvr') @patch.object(nutils, 'git_install_requested') @patch.object(charmhelpers.contrib.openstack.neutron, 'os_release') @@ -126,7 +143,8 @@ class TestNeutronOVSUtils(CharmTestCase): self.test_config.set('enable-local-dhcp-and-metadata', True) _git_requested.return_value = False _use_dvr.return_value = False - _os_rel.return_value = 'trusty' + _os_rel.return_value = 'icehouse' + self.os_release.return_value = 'icehouse' _head_pkgs.return_value = head_pkg pkg_list = nutils.determine_packages() expect = ['neutron-plugin-openvswitch-agent', head_pkg, @@ -142,7 +160,8 @@ class TestNeutronOVSUtils(CharmTestCase): self.test_config.set('enable-local-dhcp-and-metadata', False) _git_requested.return_value = True _use_dvr.return_value = True - _os_rel.return_value = 'trusty' + _os_rel.return_value = 'icehouse' + self.os_release.return_value = 'icehouse' _head_pkgs.return_value = head_pkg pkg_list = nutils.determine_packages() self.assertFalse('neutron-l3-agent' in pkg_list) @@ -159,7 +178,7 @@ class TestNeutronOVSUtils(CharmTestCase): self.ctxts.append(ctxt) _use_dvr.return_value = False - self.os_release.return_value = 'trusty' + self.os_release.return_value = 'icehouse' templating.OSConfigRenderer.side_effect = _mock_OSConfigRenderer _regconfs = nutils.register_configs() confs = ['/etc/neutron/neutron.conf', @@ -167,18 +186,50 @@ class TestNeutronOVSUtils(CharmTestCase): '/etc/init/os-charm-phy-nic-mtu.conf'] self.assertItemsEqual(_regconfs.configs, confs) + @patch.object(nutils, 'use_dvr') + def test_register_configs_mitaka(self, _use_dvr): + class _mock_OSConfigRenderer(): + def __init__(self, templates_dir=None, openstack_release=None): + self.configs = [] + self.ctxts = [] + + def register(self, config, ctxt): + self.configs.append(config) + self.ctxts.append(ctxt) + + _use_dvr.return_value = False + self.os_release.return_value = 'mitaka' + templating.OSConfigRenderer.side_effect = _mock_OSConfigRenderer + _regconfs = nutils.register_configs() + confs = ['/etc/neutron/neutron.conf', + '/etc/neutron/plugins/ml2/openvswitch_agent.ini', + '/etc/init/os-charm-phy-nic-mtu.conf'] + self.assertItemsEqual(_regconfs.configs, confs) + @patch.object(nutils, 'use_dvr') def test_resource_map(self, _use_dvr): _use_dvr.return_value = False + self.os_release.return_value = 'icehouse' _map = nutils.resource_map() svcs = ['neutron-plugin-openvswitch-agent'] confs = [nutils.NEUTRON_CONF] [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_mitaka(self, _use_dvr): + _use_dvr.return_value = False + self.os_release.return_value = 'mitaka' + _map = nutils.resource_map() + svcs = ['neutron-openvswitch-agent'] + confs = [nutils.NEUTRON_CONF] + [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_dvr(self, _use_dvr): _use_dvr.return_value = True + self.os_release.return_value = 'icehouse' _map = nutils.resource_map() svcs = ['neutron-plugin-openvswitch-agent', 'neutron-metadata-agent', 'neutron-l3-agent']