Add new unit tests for PCI stats

These unit tests make sure that the stats pools are created and
ordered properly.

Partially Implements: blueprint pci-passthrough-sriov

Change-Id: I81591b18d1045a4451ce009b091b22875eb04890
This commit is contained in:
Robert Li
2014-09-10 23:00:52 -04:00
parent 5a8ae0f1d0
commit 990561227d
2 changed files with 136 additions and 6 deletions

View File

@@ -120,12 +120,13 @@ class PciDeviceStats(object):
def remove_device(self, dev):
"""Remove one device from the first pool that it matches."""
dev_pool = self._create_pool_keys_from_dev(dev)
pool = self._find_pool(dev_pool)
if not pool:
raise exception.PciDevicePoolEmpty(
compute_node_id=dev.compute_node_id, address=dev.address)
pool['devices'].remove(dev)
self._decrease_pool_count(self.pools, pool)
if dev_pool:
pool = self._find_pool(dev_pool)
if not pool:
raise exception.PciDevicePoolEmpty(
compute_node_id=dev.compute_node_id, address=dev.address)
pool['devices'].remove(dev)
self._decrease_pool_count(self.pools, pool)
def get_free_devs(self):
free_devs = []