From: Jenkins Date: Fri, 11 Sep 2015 17:12:56 +0000 (+0000) Subject: Merge "Use version convert methods from oslo.utils" X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=b1cdd9e49f47a683f47211ea8f26d01c9bb1ed8e;p=openstack-build%2Fcinder-build.git Merge "Use version convert methods from oslo.utils" --- b1cdd9e49f47a683f47211ea8f26d01c9bb1ed8e diff --cc cinder/objects/volume.py index c2ece4203,46c3d8d8f..69435c308 --- a/cinder/objects/volume.py +++ b/cinder/objects/volume.py @@@ -21,11 -22,9 +22,10 @@@ from cinder import exceptio from cinder.i18n import _ from cinder import objects from cinder.objects import base - from cinder import utils CONF = cfg.CONF -OPTIONAL_FIELDS = [] +OPTIONAL_FIELDS = ['metadata', 'admin_metadata', + 'volume_type', 'volume_attachment'] LOG = logging.getLogger(__name__) @@@ -137,16 -97,12 +137,16 @@@ class Volume(base.CinderPersistentObjec def obj_make_compatible(self, primitive, target_version): """Make an object representation compatible with a target version.""" super(Volume, self).obj_make_compatible(primitive, target_version) - target_version = utils.convert_version_to_tuple(target_version) + target_version = versionutils.convert_version_to_tuple(target_version) @staticmethod - def _from_db_object(context, volume, db_volume): + def _from_db_object(context, volume, db_volume, expected_attrs=None): + if expected_attrs is None: + expected_attrs = [] for name, field in volume.fields.items(): - value = db_volume[name] + if name in OPTIONAL_FIELDS: + continue + value = db_volume.get(name) if isinstance(field, fields.IntegerField): value = value or 0 volume[name] = value