diff --git a/nova/objects/numa.py b/nova/objects/numa.py index ad9d46422180..cbfa8a242738 100644 --- a/nova/objects/numa.py +++ b/nova/objects/numa.py @@ -226,8 +226,12 @@ class NUMATopology(base.NovaObject): @classmethod def obj_from_db_obj(cls, db_obj): - return cls.obj_from_primitive( - jsonutils.loads(db_obj)) + """Convert serialized representation to object. + + Deserialize instances of this object that have been stored as JSON + blobs in the database. + """ + return cls.obj_from_primitive(jsonutils.loads(db_obj)) def __len__(self): """Defined so that boolean testing works the same as for lists.""" @@ -265,19 +269,3 @@ class NUMATopologyLimits(base.NovaObject): 'cpu_limit': len(cell.cpuset) * self.cpu_allocation_ratio, 'id': cell.id}) return {'cells': cells} - - @classmethod - def obj_from_db_obj(cls, db_obj): - if 'nova_object.name' in db_obj: - obj_topology = cls.obj_from_primitive(db_obj) - else: - # NOTE(sahid): This compatibility code needs to stay until we can - # guarantee that all compute nodes are using RPC API => 3.40. - cell = db_obj['cells'][0] - ram_ratio = cell['mem']['limit'] / float(cell['mem']['total']) - cpu_ratio = cell['cpu_limit'] / float(len(hardware.parse_cpu_spec( - cell['cpus']))) - obj_topology = NUMATopologyLimits( - cpu_allocation_ratio=cpu_ratio, - ram_allocation_ratio=ram_ratio) - return obj_topology diff --git a/nova/tests/unit/objects/test_numa.py b/nova/tests/unit/objects/test_numa.py index f6a89a5fa17c..89e84a775528 100644 --- a/nova/tests/unit/objects/test_numa.py +++ b/nova/tests/unit/objects/test_numa.py @@ -38,19 +38,6 @@ class _TestNUMA(object): self.assertEqual(d1, d2) - def test_from_legacy_limits(self): - old_style = {"cells": [ - {"mem": { - "total": 1024, - "limit": 2048}, - "cpu_limit": 96.0, - "cpus": "0,1,2,3,4,5", - "id": 0}]} - - limits = objects.NUMATopologyLimits.obj_from_db_obj(old_style) - self.assertEqual(16.0, limits.cpu_allocation_ratio) - self.assertEqual(2.0, limits.ram_allocation_ratio) - def test_to_legacy_limits(self): limits = objects.NUMATopologyLimits( cpu_allocation_ratio=16,