diff --git a/cinder/objects/cgsnapshot.py b/cinder/objects/cgsnapshot.py index 9fa715a0287..d5ad3772e49 100644 --- a/cinder/objects/cgsnapshot.py +++ b/cinder/objects/cgsnapshot.py @@ -19,14 +19,14 @@ from cinder import objects from cinder.objects import base from oslo_versionedobjects import fields -OPTIONAL_FIELDS = ['consistencygroup', 'snapshots'] - @base.CinderObjectRegistry.register class CGSnapshot(base.CinderPersistentObject, base.CinderObject, base.CinderObjectDictCompat): VERSION = '1.0' + OPTIONAL_FIELDS = ['consistencygroup', 'snapshots'] + fields = { 'id': fields.UUIDField(), 'consistencygroup_id': fields.UUIDField(nullable=True), @@ -40,12 +40,12 @@ class CGSnapshot(base.CinderPersistentObject, base.CinderObject, 'snapshots': fields.ObjectField('SnapshotList', nullable=True), } - @staticmethod - def _from_db_object(context, cgsnapshot, db_cgsnapshots, + @classmethod + def _from_db_object(cls, context, cgsnapshot, db_cgsnapshots, expected_attrs=None): expected_attrs = expected_attrs or [] for name, field in cgsnapshot.fields.items(): - if name in OPTIONAL_FIELDS: + if name in cls.OPTIONAL_FIELDS: continue value = db_cgsnapshots.get(name) setattr(cgsnapshot, name, value) @@ -82,7 +82,7 @@ class CGSnapshot(base.CinderPersistentObject, base.CinderObject, self._from_db_object(self._context, self, db_cgsnapshots) def obj_load_attr(self, attrname): - if attrname not in OPTIONAL_FIELDS: + if attrname not in self.OPTIONAL_FIELDS: raise exception.ObjectActionError( action='obj_load_attr', reason=_('attribute %s not lazy-loadable') % attrname)