From 0052948de1dcaefcfcb5c8f334d5a973727d43e9 Mon Sep 17 00:00:00 2001 From: Timothy Kuhlman Date: Mon, 18 Apr 2016 15:37:32 -0600 Subject: [PATCH] Add SR-IOV device support Add a new configuration option to enable SR-IOV support across Neutron and Nova; this involves enabling the required mechanism driver, and informing the nova-cloud-controller charm that SR-IOV has been enabled, so that Nova can use the correct scheduler filters for PCI device management. Change-Id: I8938c22c8f4dc27bb0816fd8e5e6154a1407e93f --- config.yaml | 5 ++++ hooks/neutron_api_context.py | 1 + hooks/neutron_api_hooks.py | 1 + templates/kilo/ml2_conf.ini | 4 +++ unit_tests/test_neutron_api_context.py | 39 ++++++++++++++++++++++++++ unit_tests/test_neutron_api_hooks.py | 2 ++ 6 files changed, 52 insertions(+) diff --git a/config.yaml b/config.yaml index 6b476341..f556c4cf 100755 --- a/config.yaml +++ b/config.yaml @@ -517,6 +517,11 @@ options: description: | Connect timeout configuration in ms for haproxy, used in HA configurations. If not provided, default value of 5000ms is used. + enable-sriov: + type: boolean + default: False + description: | + Enable SR-IOV networking support across Neutron and Nova. midonet-origin: default: midonet-2015.06 type: string diff --git a/hooks/neutron_api_context.py b/hooks/neutron_api_context.py index a7946832..98c4c636 100644 --- a/hooks/neutron_api_context.py +++ b/hooks/neutron_api_context.py @@ -238,6 +238,7 @@ class NeutronCCContext(context.NeutronContext): ctxt['vni_ranges'] = ','.join(vni_ranges.split()) ctxt['enable_ml2_port_security'] = config('enable-ml2-port-security') + ctxt['enable_sriov'] = config('enable-sriov') return ctxt diff --git a/hooks/neutron_api_hooks.py b/hooks/neutron_api_hooks.py index 3f3eded7..2ba3eb4f 100755 --- a/hooks/neutron_api_hooks.py +++ b/hooks/neutron_api_hooks.py @@ -413,6 +413,7 @@ def neutron_api_relation_joined(rid=None): base_url = canonical_url(CONFIGS, INTERNAL) neutron_url = '%s:%s' % (base_url, api_port('neutron-server')) relation_data = { + 'enable-sriov': config('enable-sriov'), 'neutron-url': neutron_url, 'neutron-plugin': config('neutron-plugin'), } diff --git a/templates/kilo/ml2_conf.ini b/templates/kilo/ml2_conf.ini index bba9dde2..5589ffb5 100644 --- a/templates/kilo/ml2_conf.ini +++ b/templates/kilo/ml2_conf.ini @@ -14,7 +14,11 @@ mechanism_drivers = calico {% else -%} type_drivers = {{ overlay_network_type }},vlan,flat,local tenant_network_types = {{ overlay_network_type }},vlan,flat,local +{% if enable_sriov %} +mechanism_drivers = openvswitch,l2population,sriovnicswitch +{% else %} mechanism_drivers = openvswitch,l2population +{% endif %} [ml2_type_gre] tunnel_id_ranges = 1:1000 diff --git a/unit_tests/test_neutron_api_context.py b/unit_tests/test_neutron_api_context.py index acadd726..00150bfa 100644 --- a/unit_tests/test_neutron_api_context.py +++ b/unit_tests/test_neutron_api_context.py @@ -306,6 +306,7 @@ class NeutronCCContextTest(CharmTestCase): 'enable_dvr': False, 'l3_ha': False, 'dhcp_agents_per_network': 3, + 'enable_sriov': False, 'external_network': 'bob', 'neutron_bind_port': self.api_port, 'verbose': True, @@ -343,6 +344,7 @@ class NeutronCCContextTest(CharmTestCase): 'enable_dvr': False, 'l3_ha': False, 'dhcp_agents_per_network': 3, + 'enable_sriov': False, 'external_network': 'bob', 'neutron_bind_port': self.api_port, 'verbose': True, @@ -382,6 +384,7 @@ class NeutronCCContextTest(CharmTestCase): 'debug': True, 'enable_dvr': False, 'l3_ha': True, + 'enable_sriov': False, 'external_network': 'bob', 'neutron_bind_port': self.api_port, 'verbose': True, @@ -409,6 +412,42 @@ class NeutronCCContextTest(CharmTestCase): with patch.object(napi_ctxt, '_ensure_packages'): self.assertEquals(ctxt_data, napi_ctxt()) + @patch.object(context.NeutronCCContext, 'network_manager') + @patch.object(context.NeutronCCContext, 'plugin') + @patch('__builtin__.__import__') + def test_neutroncc_context_sriov(self, _import, plugin, nm): + plugin.return_value = None + self.test_config.set('enable-sriov', True) + ctxt_data = { + 'debug': True, + 'enable_dvr': False, + 'l3_ha': False, + 'dhcp_agents_per_network': 3, + 'enable_sriov': True, + 'external_network': 'bob', + 'neutron_bind_port': self.api_port, + 'verbose': True, + 'l2_population': True, + 'overlay_network_type': 'gre', + 'quota_floatingip': 50, + 'quota_health_monitors': -1, + 'quota_member': -1, + 'quota_network': 10, + 'quota_pool': 10, + 'quota_port': 50, + 'quota_router': 10, + 'quota_security_group': 10, + 'quota_security_group_rule': 100, + 'quota_subnet': 10, + 'quota_vip': 10, + 'vlan_ranges': 'physnet1:1000:2000', + 'vni_ranges': '1001:2000', + 'enable_ml2_port_security': True + } + napi_ctxt = context.NeutronCCContext() + with patch.object(napi_ctxt, '_ensure_packages'): + self.assertEquals(ctxt_data, napi_ctxt()) + @patch.object(context.NeutronCCContext, 'network_manager') @patch.object(context.NeutronCCContext, 'plugin') @patch('__builtin__.__import__') diff --git a/unit_tests/test_neutron_api_hooks.py b/unit_tests/test_neutron_api_hooks.py index 58324c9c..51b01fae 100644 --- a/unit_tests/test_neutron_api_hooks.py +++ b/unit_tests/test_neutron_api_hooks.py @@ -497,6 +497,7 @@ class NeutronAPIHooksTests(CharmTestCase): self.is_relation_made = False neutron_url = '%s:%s' % (host, port) _relation_data = { + 'enable-sriov': False, 'neutron-plugin': 'ovs', 'neutron-url': neutron_url, 'neutron-security-groups': 'no', @@ -527,6 +528,7 @@ class NeutronAPIHooksTests(CharmTestCase): self.is_relation_made = True neutron_url = '%s:%s' % (host, port) _relation_data = { + 'enable-sriov': False, 'neutron-plugin': 'ovs', 'neutron-url': neutron_url, 'neutron-security-groups': 'no',