Remove DictCompat from instance_info_cache

This changes over all occurrences of dictionary syntax on the
instance_info_cache object to use object syntax.

Change-Id: I87f4acf99a6fa8061e08f8a941f8f0c60e26c51f
Partially-Implements: bp rm-object-dict-compat-newton
This commit is contained in:
Gage Hugo 2016-05-23 14:07:08 -05:00
parent 9ba80cc5d2
commit a586083a09
2 changed files with 6 additions and 7 deletions

View File

@ -25,10 +25,8 @@ from nova.objects import fields
LOG = logging.getLogger(__name__)
# TODO(berrange): Remove NovaObjectDictCompat
@base.NovaObjectRegistry.register
class InstanceInfoCache(base.NovaPersistentObject, base.NovaObject,
base.NovaObjectDictCompat):
class InstanceInfoCache(base.NovaPersistentObject, base.NovaObject):
# Version 1.0: Initial version
# Version 1.1: Converted network_info to store the model.
# Version 1.2: Added new() and update_cells kwarg to save().
@ -46,7 +44,7 @@ class InstanceInfoCache(base.NovaPersistentObject, base.NovaObject,
@staticmethod
def _from_db_object(context, info_cache, db_obj):
for field in info_cache.fields:
info_cache[field] = db_obj[field]
setattr(info_cache, field, db_obj[field])
info_cache.obj_reset_changes()
info_cache._context = context
return info_cache
@ -114,7 +112,8 @@ class InstanceInfoCache(base.NovaPersistentObject, base.NovaObject,
current._context = None
for field in self.fields:
if self.obj_attr_is_set(field) and self[field] != current[field]:
self[field] = current[field]
if (self.obj_attr_is_set(field) and
getattr(self, field) != getattr(current, field)):
setattr(self, field, getattr(current, field))
self.obj_reset_changes()

View File

@ -469,7 +469,7 @@ def _create_instances_with_cached_ips(orig_func, *args, **kwargs):
instances, reservation_id = orig_func(*args, **kwargs)
fake_cache = _get_fake_cache()
for instance in instances:
instance['info_cache']['network_info'] = fake_cache
instance['info_cache'].network_info = fake_cache
db.instance_info_cache_update(args[1], instance['uuid'],
{'network_info': fake_cache})
return (instances, reservation_id)