From b5a1cee26cb3906e5d4d640f93b5e1c6ca9616c8 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Wed, 7 Sep 2016 16:17:37 +0200 Subject: [PATCH] Include OPTIONAL_FIELDS in VolumeType OVO class Current code has OPTIONAL_FIELDS as part of the VolumeType library instead of as a class attribute of the VolumeType OVO class. This is not how it should be, as there are methods -like conditional update- that rely on the OPTIONAL_FIELDS being there. This patch moves the OPTIONAL_FIELDS inside the VolumeType class. Change-Id: I18404a2f32abc6c9d9b7d932a7acd299c4e708e5 (cherry picked from commit f63f1463c69850e80267feaad18ddd251add2b85) --- cinder/objects/volume_type.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cinder/objects/volume_type.py b/cinder/objects/volume_type.py index 0d033a98b..10215b102 100644 --- a/cinder/objects/volume_type.py +++ b/cinder/objects/volume_type.py @@ -23,9 +23,6 @@ from cinder.objects import base from cinder.volume import volume_types -OPTIONAL_FIELDS = ['extra_specs', 'projects', 'qos_specs'] - - @base.CinderObjectRegistry.register class VolumeType(base.CinderPersistentObject, base.CinderObject, base.CinderObjectDictCompat, base.CinderComparableObject): @@ -34,6 +31,8 @@ class VolumeType(base.CinderPersistentObject, base.CinderObject, # Version 1.2: Added qos_specs VERSION = '1.2' + OPTIONAL_FIELDS = ('extra_specs', 'projects', 'qos_specs') + fields = { 'id': fields.UUIDField(), 'name': fields.StringField(nullable=True), @@ -62,12 +61,12 @@ class VolumeType(base.CinderPersistentObject, base.CinderObject, def _get_expected_attrs(cls, context, *args, **kwargs): return 'extra_specs', 'projects' - @staticmethod - def _from_db_object(context, type, db_type, expected_attrs=None): + @classmethod + def _from_db_object(cls, context, type, db_type, expected_attrs=None): if expected_attrs is None: expected_attrs = ['extra_specs', 'projects'] for name, field in type.fields.items(): - if name in OPTIONAL_FIELDS: + if name in cls.OPTIONAL_FIELDS: continue value = db_type[name] if isinstance(field, fields.IntegerField):