From 945a2754a92063688236d64a64c80253a5096ab2 Mon Sep 17 00:00:00 2001 From: TommyLike Date: Mon, 13 Nov 2017 14:26:33 +0800 Subject: [PATCH] Add missing 'obj_make_compatible' in RequestSpec object RequestSpec is converted to OVO, thus need to add the 'obj_make_compatible' to support backward compatibility. Change-Id: Ifbb5248e3ad5bad4b8fb6957156540cdf97babde --- cinder/objects/request_spec.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cinder/objects/request_spec.py b/cinder/objects/request_spec.py index 58b719aa8d7..1e3859a28b0 100644 --- a/cinder/objects/request_spec.py +++ b/cinder/objects/request_spec.py @@ -12,6 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_utils import versionutils from oslo_versionedobjects import fields from cinder import objects @@ -88,6 +89,17 @@ class RequestSpec(base.CinderObject, base.CinderObjectDictCompat, return spec_obj + def obj_make_compatible(self, primitive, target_version): + """Make an object representation compatible with target version.""" + super(RequestSpec, self).obj_make_compatible(primitive, target_version) + target_version = versionutils.convert_version_to_tuple(target_version) + added_fields = (((1, 1), ('group_id', 'group_backend')), + ((1, 2), ('resource_backend'))) + for version, remove_fields in added_fields: + if target_version < version: + for obj_field in remove_fields: + primitive.pop(obj_field, None) + @base.CinderObjectRegistry.register class VolumeProperties(base.CinderObject, base.CinderObjectDictCompat):