Merge "Moving the OPTIONAL_FIELDS inside the OVO object group"

This commit is contained in:
Jenkins 2016-09-28 22:31:16 +00:00 committed by Gerrit Code Review
commit 0d88d72362

View File

@ -20,8 +20,6 @@ from cinder.objects import base
from cinder.objects import fields as c_fields from cinder.objects import fields as c_fields
from oslo_versionedobjects import fields from oslo_versionedobjects import fields
OPTIONAL_FIELDS = ['volumes', 'volume_types', 'group_snapshots']
@base.CinderObjectRegistry.register @base.CinderObjectRegistry.register
class Group(base.CinderPersistentObject, base.CinderObject, class Group(base.CinderPersistentObject, base.CinderObject,
@ -31,6 +29,8 @@ class Group(base.CinderPersistentObject, base.CinderObject,
# source_group_id # source_group_id
VERSION = '1.1' VERSION = '1.1'
OPTIONAL_FIELDS = ['volumes', 'volume_types', 'group_snapshots']
fields = { fields = {
'id': fields.UUIDField(), 'id': fields.UUIDField(),
'user_id': fields.StringField(), 'user_id': fields.StringField(),
@ -58,7 +58,7 @@ class Group(base.CinderPersistentObject, base.CinderObject,
if expected_attrs is None: if expected_attrs is None:
expected_attrs = [] expected_attrs = []
for name, field in group.fields.items(): for name, field in group.fields.items():
if name in OPTIONAL_FIELDS: if name in Group.OPTIONAL_FIELDS:
continue continue
value = db_group.get(name) value = db_group.get(name)
setattr(group, name, value) setattr(group, name, value)
@ -115,7 +115,7 @@ class Group(base.CinderPersistentObject, base.CinderObject,
self._from_db_object(self._context, self, db_groups) self._from_db_object(self._context, self, db_groups)
def obj_load_attr(self, attrname): def obj_load_attr(self, attrname):
if attrname not in OPTIONAL_FIELDS: if attrname not in Group.OPTIONAL_FIELDS:
raise exception.ObjectActionError( raise exception.ObjectActionError(
action='obj_load_attr', action='obj_load_attr',
reason=_('attribute %s not lazy-loadable') % attrname) reason=_('attribute %s not lazy-loadable') % attrname)