Only use PciPassthroughFilter when sriov enabled
Fixes code that inadvertently interprets strings as booleans resulting in them always being True. PciPassthroughFilter will now only be added to scheduler_default_filters if sriov is enabled. Change-Id: Ie2c79e98d7880e8172ac7e77febb51af04732bec Closes-Bug: 1730369
This commit is contained in:
parent
af5a4ec747
commit
05ea3a13f1
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user