diff options
| author | Dan Smith <danms@us.ibm.com> | 2013-06-14 13:34:14 -0700 |
|---|---|---|
| committer | Dan Smith <danms@us.ibm.com> | 2013-06-18 10:17:23 -0700 |
| commit | dcb68d436edbbe57dac6a2a9dd8b36cbc42af867 (patch) | |
| tree | e90344cb2893cd681797c33a039af80816e00099 /nova/objects | |
| parent | 086ec7a5b857fa1b88877c10991801761d819c98 (diff) | |
Fill context on objects in lists
This fixes object lists to not contain orphaned objects after
making an RPC trip.
Fixes bug 1191113
Change-Id: Ia90321da2f480835e1c7213a52eb5731840dbd6a
Diffstat (limited to 'nova/objects')
| -rw-r--r-- | nova/objects/base.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/nova/objects/base.py b/nova/objects/base.py index 398e70ce9..008ea667c 100644 --- a/nova/objects/base.py +++ b/nova/objects/base.py @@ -236,7 +236,7 @@ class NovaObject(object): return value @classmethod - def obj_from_primitive(cls, primitive): + def obj_from_primitive(cls, primitive, context=None): """Simple base-case hydration. This calls self._attr_from_primitive() for each item in fields. @@ -252,6 +252,7 @@ class NovaObject(object): objdata = primitive['nova_object.data'] objclass = cls.obj_class_from_name(objname, objver) self = objclass() + self._context = context for name in self.fields: if name in objdata: setattr(self, name, @@ -409,7 +410,11 @@ class ObjectListBase(object): def _attr_objects_from_primitive(self, value): """Deserialization of object list.""" - return [NovaObject.obj_from_primitive(x) for x in value] + objects = [] + for entity in value: + obj = NovaObject.obj_from_primitive(entity, context=self._context) + objects.append(obj) + return objects class NovaObjectSerializer(nova.openstack.common.rpc.serializer.Serializer): @@ -428,6 +433,5 @@ class NovaObjectSerializer(nova.openstack.common.rpc.serializer.Serializer): def deserialize_entity(self, context, entity): if isinstance(entity, dict) and 'nova_object.name' in entity: - entity = NovaObject.obj_from_primitive(entity) - entity._context = context + entity = NovaObject.obj_from_primitive(entity, context=context) return entity |
