]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fetch volume_types by uuid and not by name in v2
authorMike Perez <thingee@gmail.com>
Fri, 22 Mar 2013 02:55:48 +0000 (19:55 -0700)
committerjohn-griffith <john.griffith@solidfire.com>
Sat, 23 Mar 2013 21:37:42 +0000 (15:37 -0600)
This was left over from the UUID switch. Looking up volume_types by name
is deprecated in v1 and removed in v2.

Fixes: bug #1087817
Change-Id: I02cc035565f9496cd5af228c55ced5cafef2ad81
(cherry picked from commit f5706319365dbd11cbc91bd69b09238afa51a626)

cinder/api/v2/views/volumes.py
cinder/api/v2/volumes.py
cinder/tests/api/v2/test_volumes.py

index c7b6eb7d4ea8e29ad2c5f3660beafc64b44b14ea..c1deec46636a4bfb9c040165fc8ab27f9f65ad26 100644 (file)
@@ -106,8 +106,7 @@ class ViewBuilder(common.ViewBuilder):
         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."""
index 3db80e7e29f10518ff2b8e95f4267563e001c1a7..e78d0207cadd569d4d767b93e9c250906d7b3405 100644 (file)
@@ -240,7 +240,7 @@ class VolumeController(wsgi.Controller):
         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.'
index df2d92f3d3953a4343e03f5d914d26cdbe6cc32d..baba2bdc852d53950a80735ab3f5b629067fee7b 100644 (file)
@@ -98,19 +98,19 @@ class VolumeApiTest(test.TestCase):
         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')