pci passthrough bug fix:hasattr dones not work for dict
hasattr only work in object model, scheduler does not use the object model yet. so fall back to dict model. Closes-Bug: #1226348 Change-Id: Ifab4165be67abfe2bbe9ac7280b8715cb7f04f1c Signed-off-by: Yongli He <yongli.he@intel.com>
This commit is contained in:
parent
d0a7a32a7c
commit
67adc54f34
@ -168,7 +168,7 @@ class HostState(object):
|
||||
self.vcpus_total = compute['vcpus']
|
||||
self.vcpus_used = compute['vcpus_used']
|
||||
self.updated = compute['updated_at']
|
||||
if hasattr(compute, 'pci_stats'):
|
||||
if 'pci_stats' in compute:
|
||||
self.pci_stats = pci_stats.PciDeviceStats(compute['pci_stats'])
|
||||
else:
|
||||
self.pci_stats = None
|
||||
|
@ -1574,3 +1574,16 @@ class HostFiltersTestCase(test.NoDBTestCase):
|
||||
filter_properties = {}
|
||||
host = fakes.FakeHostState('h1', 'n1', {})
|
||||
self.assertTrue(filt_cls.host_passes(host, filter_properties))
|
||||
|
||||
def test_pci_passthrough_comopute_stats(self):
|
||||
filt_cls = self.class_map['PciPassthroughFilter']()
|
||||
requests = [{'count': 1, 'spec': [{'vendor_id': '8086'}]}]
|
||||
filter_properties = {'pci_requests': requests}
|
||||
self.stubs.Set(pci_stats.PciDeviceStats, 'support_requests',
|
||||
self._fake_pci_support_requests)
|
||||
host = fakes.FakeHostState(
|
||||
'host1', 'node1',
|
||||
attribute_dict={})
|
||||
self.pci_request_result = True
|
||||
self.assertRaises(AttributeError, filt_cls.host_passes,
|
||||
host, filter_properties)
|
||||
|
Loading…
Reference in New Issue
Block a user