Merge "objects: Remove NUMATopologyLimits.obj_from_db_obj"
This commit is contained in:
commit
2fb5be45e6
nova
@ -226,8 +226,12 @@ class NUMATopology(base.NovaObject):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def obj_from_db_obj(cls, db_obj):
|
def obj_from_db_obj(cls, db_obj):
|
||||||
return cls.obj_from_primitive(
|
"""Convert serialized representation to object.
|
||||||
jsonutils.loads(db_obj))
|
|
||||||
|
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):
|
def __len__(self):
|
||||||
"""Defined so that boolean testing works the same as for lists."""
|
"""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,
|
'cpu_limit': len(cell.cpuset) * self.cpu_allocation_ratio,
|
||||||
'id': cell.id})
|
'id': cell.id})
|
||||||
return {'cells': cells}
|
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
|
|
||||||
|
@ -38,19 +38,6 @@ class _TestNUMA(object):
|
|||||||
|
|
||||||
self.assertEqual(d1, d2)
|
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):
|
def test_to_legacy_limits(self):
|
||||||
limits = objects.NUMATopologyLimits(
|
limits = objects.NUMATopologyLimits(
|
||||||
cpu_allocation_ratio=16,
|
cpu_allocation_ratio=16,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user