Merge "Include OPTIONAL_FIELDS in VolumeType OVO class" into stable/newton
This commit is contained in:
commit
ea5b7a80e7
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue