if volume['volume_type_id'] and volume.get('volume_type'):
return volume['volume_type']['name']
else:
- # TODO(bcwaldon): remove str cast once we use uuids
- return str(volume['volume_type_id'])
+ return volume['volume_type_id']
def _list_view(self, func, request, volumes):
"""Provide a view for a list of volumes."""
req_volume_type = volume.get('volume_type', None)
if req_volume_type:
try:
- kwargs['volume_type'] = volume_types.get_volume_type_by_name(
+ kwargs['volume_type'] = volume_types.get_volume_type(
context, req_volume_type)
except exception.VolumeTypeNotFound:
explanation = 'Volume type not found.'
self.assertEqual(res_dict, expected)
def test_volume_create_with_type(self):
- vol_type = FLAGS.default_volume_type
- db.volume_type_create(context.get_admin_context(),
- dict(name=vol_type, extra_specs={}))
+ vol_type = db.volume_type_create(context.get_admin_context(),
+ dict(name=FLAGS.default_volume_type,
+ extra_specs={}))
- db_vol_type = db.volume_type_get_by_name(context.get_admin_context(),
- vol_type)
+ db_vol_type = db.volume_type_get(context.get_admin_context(),
+ vol_type.id)
vol = {
"size": 100,
"name": "Volume Test Name",
"description": "Volume Test Desc",
"availability_zone": "zone1:host1",
- "volume_type": db_vol_type['name'],
+ "volume_type": db_vol_type['id'],
}
body = {"volume": vol}
req = fakes.HTTPRequest.blank('/v2/volumes')