Merge "Only use PciPassthroughFilter when sriov enabled"

This commit is contained in:
Zuul 2017-11-07 17:38:58 +00:00 committed by Gerrit Code Review
commit 0ab4dff278
2 changed files with 29 additions and 1 deletions

View File

@ -135,7 +135,7 @@ class NeutronAPIContext(context.OSContextGenerator):
rdata.get('neutron-security-groups'),
'network_manager': 'neutron',
}
if rdata.get('enable-sriov'):
if rdata.get('enable-sriov', '').lower() == 'true':
ctxt['additional_neutron_filters'] = 'PciPassthroughFilter'
if context_complete(ctxt):
return ctxt

View File

@ -362,3 +362,31 @@ class NovaComputeContextTests(CharmTestCase):
{'novaapi_password': 'changeme',
'novacell0_password': 'passw0rd',
'nova_password': '1234'})
@mock.patch.object(context, 'context_complete', lambda *args: True)
def test_NeutronAPIContext(self):
self.relation_ids.return_value = ['neutron-api:12']
self.related_units.return_value = ['neutron-api/0']
settings = {'neutron-plugin': 'ovs',
'enable-sriov': 'False',
'neutron-security-groups': 'yes',
'neutron-url': 'http://neutron:9696'}
def fake_rel_get(attribute=None, unit=None, rid=None):
if attribute:
return settings.get(attribute)
return settings
self.relation_get.side_effect = fake_rel_get
ctxt = context.NeutronAPIContext()()
expected = {'network_manager': 'neutron',
'neutron_plugin': 'ovs',
'neutron_security_groups': 'yes',
'neutron_url': 'http://neutron:9696'}
self.assertEqual(ctxt, expected)
settings['enable-sriov'] = 'True'
expected['additional_neutron_filters'] = 'PciPassthroughFilter'
ctxt = context.NeutronAPIContext()()
self.assertEqual(ctxt, expected)