From 1fb782a6dea63d506e150426038a6cbd20fcf14d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 24 Jan 2018 14:08:26 +0000 Subject: [PATCH] objects: Remove NUMATopologyLimits.obj_from_db_obj Part of this code function was intended to support RPC versions < 3.40, which haven't been supported since we bumped the minimum to 4.0 in Kilo. However, there are no callers for the entire function today, so the whole thing can be safely removed. Part of blueprint numa-aware-vswitches Change-Id: Ie8f3d8ee701da6956f2a5706fb6ef3095e6518bd --- nova/objects/numa.py | 24 ++++++------------------ nova/tests/unit/objects/test_numa.py | 13 ------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/nova/objects/numa.py b/nova/objects/numa.py index ad9d464221..cbfa8a2427 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 f6a89a5fa1..89e84a7755 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,