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__)
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