Moving the OPTIONAL_FIELDS inside the OVO object group

In working patch 251989, Michal Dulko points out that
all the OVOs should have OPTIONAL_FIELDS inside object.

This patch will fix the issue in OVO, group.

Change-Id: Icdedf273333abefa5ce6daf81e7a94e0308c1a18
This commit is contained in:
Xinli Guan 2016-09-28 03:58:08 +00:00
parent d53f37db2b
commit fd5e2aadc3

View File

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