Merge "To fix miscellaneous bugs in OVOs"

This commit is contained in:
Jenkins 2016-11-03 04:52:59 +00:00 committed by Gerrit Code Review
commit f6ab36d9d1
3 changed files with 10 additions and 8 deletions

@ -41,7 +41,7 @@ class ViewBuilder(common.ViewBuilder):
'id': qos_spec.id,
'name': qos_spec.name,
'consumer': qos_spec.consumer,
'specs': qos_spec.specs
'specs': qos_spec.specs,
},
'links': self._get_links(request,
qos_spec.id),

@ -100,7 +100,7 @@ class QualityOfServiceSpecs(base.CinderPersistentObject,
return changes
def obj_load_attr(self, attrname):
if attrname not in QualityOfServiceSpecs.OPTIONAL_FIELDS:
if attrname not in self.OPTIONAL_FIELDS:
raise exception.ObjectActionError(
action='obj_load_attr',
reason=_('attribute %s not lazy-loadable') % attrname)
@ -112,13 +112,14 @@ class QualityOfServiceSpecs(base.CinderPersistentObject,
self.volume_types = objects.VolumeTypeList.get_all_types_for_qos(
self._context, self.id)
@staticmethod
def _from_db_object(context, qos_spec, db_qos_spec, expected_attrs=None):
@classmethod
def _from_db_object(cls, context, qos_spec, db_qos_spec,
expected_attrs=None):
if expected_attrs is None:
expected_attrs = []
for name, field in qos_spec.fields.items():
if name not in QualityOfServiceSpecs.OPTIONAL_FIELDS:
if name not in cls.OPTIONAL_FIELDS:
value = db_qos_spec.get(name)
# 'specs' could be null if only a consumer is given, so make
# it an empty dict instead of None

@ -114,12 +114,13 @@ class Snapshot(base.CinderPersistentObject, base.CinderObject,
super(Snapshot, self).obj_make_compatible(primitive, target_version)
target_version = versionutils.convert_version_to_tuple(target_version)
@staticmethod
def _from_db_object(context, snapshot, db_snapshot, expected_attrs=None):
@classmethod
def _from_db_object(cls, context, snapshot, db_snapshot,
expected_attrs=None):
if expected_attrs is None:
expected_attrs = []
for name, field in snapshot.fields.items():
if name in Snapshot.OPTIONAL_FIELDS:
if name in cls.OPTIONAL_FIELDS:
continue
value = db_snapshot.get(name)
if isinstance(field, fields.IntegerField):