diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-04-22 18:55:37 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-04-22 18:55:37 +0000 |
commit | 7eb477ed25e41538a260179da966063c94931f4e (patch) | |
tree | c8bde2ebf2bc5c8c6932ba4e9869cf68ddfc4be7 | |
parent | 451e6bf69ca95cba5cc2287bb93f6d30f3d3f788 (diff) | |
parent | 7a609f153808f7cee1edbbb36accc292fa8df0d0 (diff) | |
download | nova-7eb477ed25e41538a260179da966063c94931f4e.tar.gz |
Merge "Add numa_node field to PciDevicePool" into stable/kilo
-rw-r--r-- | nova/objects/compute_node.py | 9 | ||||
-rw-r--r-- | nova/objects/pci_device_pool.py | 15 | ||||
-rw-r--r-- | nova/objects/service.py | 10 | ||||
-rw-r--r-- | nova/tests/unit/api/openstack/compute/contrib/test_pci.py | 1 | ||||
-rw-r--r-- | nova/tests/unit/fake_pci_device_pools.py | 2 | ||||
-rw-r--r-- | nova/tests/unit/objects/test_objects.py | 16 | ||||
-rw-r--r-- | nova/tests/unit/objects/test_pci_device_pool.py | 8 |
7 files changed, 45 insertions, 16 deletions
diff --git a/nova/objects/compute_node.py b/nova/objects/compute_node.py index 3fa7cdbb03..e11ca577b7 100644 --- a/nova/objects/compute_node.py +++ b/nova/objects/compute_node.py @@ -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 diff --git a/nova/objects/pci_device_pool.py b/nova/objects/pci_device_pool.py index 96df7bbdba..0de57f86b1 100644 --- a/nova/objects/pci_device_pool.py +++ b/nova/objects/pci_device_pool.py @@ -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', } diff --git a/nova/objects/service.py b/nova/objects/service.py index 36eee38aef..ca11066320 100644 --- a/nova/objects/service.py +++ b/nova/objects/service.py @@ -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 diff --git a/nova/tests/unit/api/openstack/compute/contrib/test_pci.py b/nova/tests/unit/api/openstack/compute/contrib/test_pci.py index 50eba5297b..899ca062a0 100644 --- a/nova/tests/unit/api/openstack/compute/contrib/test_pci.py +++ b/nova/tests/unit/api/openstack/compute/contrib/test_pci.py @@ -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( diff --git a/nova/tests/unit/fake_pci_device_pools.py b/nova/tests/unit/fake_pci_device_pools.py index cf8edf34ab..0e5772488e 100644 --- a/nova/tests/unit/fake_pci_device_pools.py +++ b/nova/tests/unit/fake_pci_device_pools.py @@ -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() diff --git a/nova/tests/unit/objects/test_objects.py b/nova/tests/unit/objects/test_objects.py index 02669a0d2b..f4a378e45f 100644 --- a/nova/tests/unit/objects/test_objects.py +++ b/nova/tests/unit/objects/test_objects.py @@ -1204,8 +1204,8 @@ object_data = { 'BlockDeviceMapping': '1.8-c87e9c7e5cfd6a402f32727aa74aca95', 'BlockDeviceMappingList': '1.9-0faaeebdca213010c791bc37a22546e3', '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', 'EC2InstanceMapping': '1.0-e9c3257badcc3aa14089b0a62f163108', @@ -1252,8 +1252,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', @@ -1261,8 +1261,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', @@ -1276,7 +1276,7 @@ object_data = { object_relationships = { 'BlockDeviceMapping': {'Instance': '1.19'}, - 'ComputeNode': {'HVSpec': '1.0', 'PciDevicePoolList': '1.0'}, + 'ComputeNode': {'HVSpec': '1.0', 'PciDevicePoolList': '1.1'}, 'FixedIP': {'Instance': '1.19', 'Network': '1.2', 'VirtualInterface': '1.0', 'FloatingIPList': '1.7'}, @@ -1298,7 +1298,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'}, } diff --git a/nova/tests/unit/objects/test_pci_device_pool.py b/nova/tests/unit/objects/test_pci_device_pool.py index a2df17ea6d..8ad5be8621 100644 --- a/nova/tests/unit/objects/test_pci_device_pool.py +++ b/nova/tests/unit/objects/test_pci_device_pool.py @@ -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): |