Merge "Add numa_node field to PciDevicePool"
This commit is contained in:
commit
1e3412deec
|
@ -37,7 +37,8 @@ class ComputeNode(base.NovaPersistentObject, base.NovaObject,
|
|||
# Version 1.8: Added get_by_host_and_nodename()
|
||||
# Version 1.9: Added pci_device_pools
|
||||
# Version 1.10: Added get_first_node_by_host_for_old_compat()
|
||||
VERSION = '1.10'
|
||||
# Version 1.11: PciDevicePoolList version 1.1
|
||||
VERSION = '1.11'
|
||||
|
||||
fields = {
|
||||
'id': fields.IntegerField(read_only=True),
|
||||
|
@ -72,7 +73,7 @@ class ComputeNode(base.NovaPersistentObject, base.NovaObject,
|
|||
}
|
||||
|
||||
obj_relationships = {
|
||||
'pci_device_pools': [('1.9', '1.0')],
|
||||
'pci_device_pools': [('1.9', '1.0'), ('1.11', '1.1')],
|
||||
'supported_hv_specs': [('1.6', '1.0')],
|
||||
}
|
||||
|
||||
|
@ -283,7 +284,8 @@ class ComputeNodeList(base.ObjectListBase, base.NovaObject):
|
|||
# Version 1.8 ComputeNode version 1.8 + add get_all_by_host()
|
||||
# Version 1.9 ComputeNode version 1.9
|
||||
# Version 1.10 ComputeNode version 1.10
|
||||
VERSION = '1.10'
|
||||
# Version 1.11 ComputeNode version 1.11
|
||||
VERSION = '1.11'
|
||||
fields = {
|
||||
'objects': fields.ListOfObjectsField('ComputeNode'),
|
||||
}
|
||||
|
@ -300,6 +302,7 @@ class ComputeNodeList(base.ObjectListBase, base.NovaObject):
|
|||
'1.8': '1.8',
|
||||
'1.9': '1.9',
|
||||
'1.10': '1.10',
|
||||
'1.11': '1.11',
|
||||
}
|
||||
|
||||
@base.remotable_classmethod
|
||||
|
|
|
@ -21,19 +21,27 @@ import six
|
|||
from nova import objects
|
||||
from nova.objects import base
|
||||
from nova.objects import fields
|
||||
from nova import utils
|
||||
|
||||
|
||||
class PciDevicePool(base.NovaObject):
|
||||
# Version 1.0: Initial version
|
||||
VERSION = '1.0'
|
||||
# Version 1.1: Added numa_node field
|
||||
VERSION = '1.1'
|
||||
|
||||
fields = {
|
||||
'product_id': fields.StringField(),
|
||||
'vendor_id': fields.StringField(),
|
||||
'numa_node': fields.IntegerField(nullable=True),
|
||||
'tags': fields.DictOfNullableStringsField(),
|
||||
'count': fields.IntegerField(),
|
||||
}
|
||||
|
||||
def obj_make_compatible(self, primitive, target_version):
|
||||
target_version = utils.convert_version_to_tuple(target_version)
|
||||
if target_version < (1, 1) and 'numa_node' in primitive:
|
||||
del primitive['numa_node']
|
||||
|
||||
# NOTE(pmurray): before this object existed the pci device pool data was
|
||||
# stored as a dict. For backward compatibility we need to be able to read
|
||||
# it in from a dict
|
||||
|
@ -43,6 +51,7 @@ class PciDevicePool(base.NovaObject):
|
|||
pool = cls()
|
||||
pool.vendor_id = pool_dict.pop("vendor_id")
|
||||
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)
|
||||
|
@ -62,12 +71,14 @@ class PciDevicePool(base.NovaObject):
|
|||
class PciDevicePoolList(base.ObjectListBase, base.NovaObject):
|
||||
# Version 1.0: Initial version
|
||||
# PciDevicePool <= 1.0
|
||||
VERSION = '1.0'
|
||||
# Version 1.1: PciDevicePool version 1.1
|
||||
VERSION = '1.1'
|
||||
fields = {
|
||||
'objects': fields.ListOfObjectsField('PciDevicePool'),
|
||||
}
|
||||
child_versions = {
|
||||
'1.0': '1.0',
|
||||
'1.1': '1.1',
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ class Service(base.NovaPersistentObject, base.NovaObject,
|
|||
# Version 1.9: ComputeNode version 1.10
|
||||
# Version 1.10: Changes behaviour of loading compute_node
|
||||
# Version 1.11: Added get_by_host_and_binary
|
||||
VERSION = '1.11'
|
||||
# Version 1.12: ComputeNode version 1.11
|
||||
VERSION = '1.12'
|
||||
|
||||
fields = {
|
||||
'id': fields.IntegerField(read_only=True),
|
||||
|
@ -57,7 +58,8 @@ class Service(base.NovaPersistentObject, base.NovaObject,
|
|||
|
||||
obj_relationships = {
|
||||
'compute_node': [('1.1', '1.4'), ('1.3', '1.5'), ('1.5', '1.6'),
|
||||
('1.7', '1.8'), ('1.8', '1.9'), ('1.9', '1.10')],
|
||||
('1.7', '1.8'), ('1.8', '1.9'), ('1.9', '1.10'),
|
||||
('1.12', '1.11')],
|
||||
}
|
||||
|
||||
def obj_make_compatible(self, primitive, target_version):
|
||||
|
@ -189,7 +191,8 @@ class ServiceList(base.ObjectListBase, base.NovaObject):
|
|||
# Version 1.7: Service version 1.9
|
||||
# Version 1.8: Service version 1.10
|
||||
# Version 1.9: Added get_by_binary() and Service version 1.11
|
||||
VERSION = '1.9'
|
||||
# Version 1.10: Service version 1.12
|
||||
VERSION = '1.10'
|
||||
|
||||
fields = {
|
||||
'objects': fields.ListOfObjectsField('Service'),
|
||||
|
@ -206,6 +209,7 @@ class ServiceList(base.ObjectListBase, base.NovaObject):
|
|||
'1.7': '1.9',
|
||||
'1.8': '1.10',
|
||||
'1.9': '1.11',
|
||||
'1.10': '1.12',
|
||||
}
|
||||
|
||||
@base.remotable_classmethod
|
||||
|
|
|
@ -31,6 +31,7 @@ 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"]]'}}]
|
||||
fake_compute_node = objects.ComputeNode(
|
||||
|
|
|
@ -21,6 +21,7 @@ from nova.objects import pci_device_pool
|
|||
fake_pool_dict = {
|
||||
'product_id': 'fake-product',
|
||||
'vendor_id': 'fake-vendor',
|
||||
'numa_node': 1,
|
||||
't1': 'v1',
|
||||
't2': 'v2',
|
||||
'count': 2,
|
||||
|
@ -29,6 +30,7 @@ fake_pool_dict = {
|
|||
fake_pool = pci_device_pool.PciDevicePool(count=5,
|
||||
product_id='foo',
|
||||
vendor_id='bar',
|
||||
numa_node=0,
|
||||
tags={'t1': 'v1', 't2': 'v2'})
|
||||
fake_pool_primitive = fake_pool.obj_to_primitive()
|
||||
|
||||
|
|
|
@ -1204,8 +1204,8 @@ object_data = {
|
|||
'BlockDeviceMapping': '1.9-c87e9c7e5cfd6a402f32727aa74aca95',
|
||||
'BlockDeviceMappingList': '1.10-fb22f945b9f304b8c9fb0c1b9571a52e',
|
||||
'CellMapping': '1.0-4b1616970814c3c819e10c7ef6b9c3d5',
|
||||
'ComputeNode': '1.10-5f8cd6948ad98fcc0c39b79d49acc4b6',
|
||||
'ComputeNodeList': '1.10-4ae1f844c247029fbcdb5fdccbe9e619',
|
||||
'ComputeNode': '1.11-5f8cd6948ad98fcc0c39b79d49acc4b6',
|
||||
'ComputeNodeList': '1.11-74155f002977bda12e843733c5fe3749',
|
||||
'DNSDomain': '1.0-5bdc288d7c3b723ce86ede998fd5c9ba',
|
||||
'DNSDomainList': '1.0-cfb3e7e82be661501c31099523154db4',
|
||||
'EC2Ids': '1.0-8e193896fa01cec598b875aea94da608',
|
||||
|
@ -1253,8 +1253,8 @@ object_data = {
|
|||
'NetworkRequestList': '1.1-beeab521ac9450f1f5ef4eaa945a783c',
|
||||
'PciDevice': '1.3-6d37f795ee934e7db75b5a6a1926def0',
|
||||
'PciDeviceList': '1.1-38cbe2d3c23b9e46f7a74b486abcad85',
|
||||
'PciDevicePool': '1.0-d6ed1abe611c9947345a44155abe6f11',
|
||||
'PciDevicePoolList': '1.0-d31e08e0ff620a4df7cc2014b6c50da8',
|
||||
'PciDevicePool': '1.1-2f352e08e128ec5bc84bc3007936cc6d',
|
||||
'PciDevicePoolList': '1.1-beeab521ac9450f1f5ef4eaa945a783c',
|
||||
'Quotas': '1.2-615ed622082c92d938119fd49e6d84ee',
|
||||
'QuotasNoOp': '1.2-164c628906b170fd946a7672e85e4935',
|
||||
'S3ImageMapping': '1.0-56d23342db8131d826797c7229dc4050',
|
||||
|
@ -1262,8 +1262,8 @@ object_data = {
|
|||
'SecurityGroupList': '1.0-528e6448adfeeb78921ebeda499ab72f',
|
||||
'SecurityGroupRule': '1.1-38290b6f9a35e416c2bcab5f18708967',
|
||||
'SecurityGroupRuleList': '1.1-667fca3a9928f23d2d10e61962c55f3c',
|
||||
'Service': '1.11-1a34a387914f90aacc33c8c43d45d0b3',
|
||||
'ServiceList': '1.9-54656820acc49b3cc0eb57b2a684b84a',
|
||||
'Service': '1.12-1a34a387914f90aacc33c8c43d45d0b3',
|
||||
'ServiceList': '1.10-15338ee1affe868479d2deba306cfd33',
|
||||
'Tag': '1.0-521693d0515aa031dff2b8ae3f86c8e0',
|
||||
'TagList': '1.0-e89bf8c8055f1f1d654fb44f0abf1f53',
|
||||
'TestSubclassedObject': '1.6-d0f7f126f87433003c4d2ced202d6c86',
|
||||
|
@ -1277,7 +1277,7 @@ object_data = {
|
|||
|
||||
object_relationships = {
|
||||
'BlockDeviceMapping': {'Instance': '1.20'},
|
||||
'ComputeNode': {'HVSpec': '1.0', 'PciDevicePoolList': '1.0'},
|
||||
'ComputeNode': {'HVSpec': '1.0', 'PciDevicePoolList': '1.1'},
|
||||
'FixedIP': {'Instance': '1.20', 'Network': '1.2',
|
||||
'VirtualInterface': '1.0',
|
||||
'FloatingIPList': '1.7'},
|
||||
|
@ -1300,7 +1300,7 @@ object_relationships = {
|
|||
'NUMACell': {'NUMAPagesTopology': '1.0'},
|
||||
'NUMATopology': {'NUMACell': '1.2'},
|
||||
'SecurityGroupRule': {'SecurityGroup': '1.1'},
|
||||
'Service': {'ComputeNode': '1.10'},
|
||||
'Service': {'ComputeNode': '1.11'},
|
||||
'TestSubclassedObject': {'MyOwnedObject': '1.0'},
|
||||
'VirtCPUModel': {'VirtCPUFeature': '1.0', 'VirtCPUTopology': '1.0'},
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ class _TestPciDevicePoolObject(object):
|
|||
pool_obj = objects.PciDevicePool.from_dict(fake_pci.fake_pool_dict)
|
||||
self.assertEqual(pool_obj.product_id, 'fake-product')
|
||||
self.assertEqual(pool_obj.vendor_id, 'fake-vendor')
|
||||
self.assertEqual(pool_obj.numa_node, 1)
|
||||
self.assertEqual(pool_obj.tags, {'t1': 'v1', 't2': 'v2'})
|
||||
self.assertEqual(pool_obj.count, 2)
|
||||
|
||||
|
@ -61,6 +62,13 @@ class _TestPciDevicePoolObject(object):
|
|||
pool_dict = pool_obj.to_dict()
|
||||
self.assertEqual({'product_id': 'pid'}, pool_dict)
|
||||
|
||||
def test_obj_make_compatible(self):
|
||||
pool_obj = objects.PciDevicePool(product_id='pid', numa_node=1)
|
||||
primitive = pool_obj.obj_to_primitive()
|
||||
self.assertIn('numa_node', primitive['nova_object.data'])
|
||||
pool_obj.obj_make_compatible(primitive['nova_object.data'], '1.0')
|
||||
self.assertNotIn('numa_node', primitive['nova_object.data'])
|
||||
|
||||
|
||||
class TestPciDevicePoolObject(test_objects._LocalTest,
|
||||
_TestPciDevicePoolObject):
|
||||
|
|
Loading…
Reference in New Issue