Merge "Cleanups for pci stats in preparation for RT using ComputeNode"

This commit is contained in:
Jenkins 2015-06-03 03:02:57 +00:00 committed by Gerrit Code Review
commit 8f90a7c5c8
10 changed files with 31 additions and 31 deletions

View File

@ -20,13 +20,11 @@
"os-pci:pci_stats": [
{
"count": 5,
"extra_info": {
"key1": "value1",
"phys_function": "[[\"0x0000\", \"0x04\", \"0x00\", \"0x1\"]]"
},
"key1": "value1",
"keya": "valuea",
"product_id": "1520",
"vendor_id": "8086"
"vendor_id": "8086",
"numa_node": 1
}
],
"running_vms": 0,

View File

@ -19,13 +19,11 @@
"os-pci:pci_stats": [
{
"count": 5,
"extra_info": {
"key1": "value1",
"phys_function": "[[\"0x0000\", \"0x04\", \"0x00\", \"0x1\"]]"
},
"key1": "value1",
"keya": "valuea",
"product_id": "1520",
"vendor_id": "8086"
"vendor_id": "8086",
"numa_node": 1
}
],
"running_vms": 0,

View File

@ -53,8 +53,7 @@ class PciDevicePool(base.NovaObject):
pool.product_id = pool_dict.pop("product_id")
pool.numa_node = pool_dict.pop("numa_node", None)
pool.count = pool_dict.pop("count")
pool.tags = {}
pool.tags.update(pool_dict)
pool.tags = pool_dict
return pool
# NOTE(sbauza): Before using objects, pci stats was a list of

View File

@ -21,6 +21,7 @@ import six
from nova import exception
from nova.i18n import _LE
from nova.objects import pci_device_pool
from nova.pci import utils
from nova.pci import whitelist
@ -255,3 +256,8 @@ class PciDeviceStats(object):
def __ne__(self, other):
return not (self == other)
def to_device_pools_obj(self):
"""Return the contents of the pools as a PciDevicePoolList object."""
stats = [x for x in self]
return pci_device_pool.from_pci_stats(stats)

View File

@ -20,13 +20,11 @@
"os-pci:pci_stats": [
{
"count": 5,
"extra_info": {
"key1": "value1",
"phys_function": "[[\"0x0000\", \"0x04\", \"0x00\", \"0x1\"]]"
},
"key1": "value1",
"keya": "valuea",
"product_id": "1520",
"vendor_id": "8086"
"vendor_id": "8086",
"numa_node": 1
}
],
"running_vms": 0,

View File

@ -19,13 +19,11 @@
"os-pci:pci_stats": [
{
"count": 5,
"extra_info": {
"key1": "value1",
"phys_function": "[[\"0x0000\", \"0x04\", \"0x00\", \"0x1\"]]"
},
"key1": "value1",
"keya": "valuea",
"product_id": "1520",
"vendor_id": "8086"
"vendor_id": "8086",
"numa_node": 1
}
],
"running_vms": 0,

View File

@ -134,11 +134,8 @@ class ExtendedHyervisorPciSampleJsonTest(api_sample_base.ApiSampleTestBaseV3):
"vendor_id": "8086",
"product_id": "1520",
"keya": "valuea",
"extra_info": {
"phys_function": '[["0x0000", '
'"0x04", "0x00",'
' "0x1"]]',
"key1": "value1"}}),)
"key1": "value1",
"numa_node": 1}),)
self.fake_service = objects.Service(
id=2,
host='043b3cacf6f34c90a7245151fc8ebcda',

View File

@ -31,9 +31,8 @@ from nova.tests.unit.objects import test_pci_device
pci_stats = [{"count": 3,
"vendor_id": "8086",
"product_id": "1520",
"numa_node": 1,
"extra_info": {"phys_function": '[["0x0000", "0x04", '
'"0x00", "0x1"]]'}}]
"numa_node": 1}]
fake_compute_node = objects.ComputeNode(
pci_device_pools=pci_device_pool.from_pci_stats(pci_stats))

View File

@ -37,6 +37,13 @@ class _TestPciDevicePoolObject(object):
self.assertEqual(pool_obj.tags, {'t1': 'v1', 't2': 'v2'})
self.assertEqual(pool_obj.count, 2)
def test_pci_pool_from_dict_bad_tags(self):
bad_dict = copy.deepcopy(fake_pci.fake_pool_dict)
bad_dict['bad'] = {'foo': 'bar'}
self.assertRaises(ValueError,
objects.PciDevicePool.from_dict,
value=bad_dict)
def test_pci_pool_from_dict_no_tags(self):
dict_notag = copy.copy(fake_pci.fake_pool_dict)
dict_notag.pop('t1')

View File

@ -114,7 +114,7 @@ class PciDeviceStatsTestCase(test.NoDBTestCase):
self.assertNotEqual(self.pci_stats, pci_stats2)
def test_object_create(self):
m = objects.pci_device_pool.from_pci_stats(self.pci_stats.pools)
m = self.pci_stats.to_device_pools_obj()
new_stats = stats.PciDeviceStats(m)
self.assertEqual(len(new_stats.pools), 3)