]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix type change in bootable setting of volume view
authorJohn Griffith <john.griffith@solidfire.com>
Thu, 19 Sep 2013 19:05:05 +0000 (13:05 -0600)
committerJohn Griffith <john.griffith@solidfire.com>
Thu, 19 Sep 2013 19:05:05 +0000 (13:05 -0600)
Change Idd47a0a8069ee905b81c7aae562b82767ad91930 fixed a db
query issue, by removing the image_metadata querie in the get/show
methods.

The problem however is that we just passed the setting from the volume
object directly in the summary view builder.  This results in changing
the type of the value from a string "true/false" to a bool True/False
which is no good.

This patch converts the object member back to a string like it used to
be so we don't break any compat or expectations in API behavior.

Fixes bug #1227837

Change-Id: I55c0e25134ae429802ddf313d6d26f1fad19ca94

cinder/api/v1/volumes.py
cinder/tests/api/v1/test_volumes.py

index 1cef310585aa8a89f7cd45a331db9d84df342f66..92f0ba02277923804db2eb0dc9899dda93123324 100644 (file)
@@ -80,7 +80,13 @@ def _translate_volume_summary_view(context, vol, image_id=None):
     d['size'] = vol['size']
     d['availability_zone'] = vol['availability_zone']
     d['created_at'] = vol['created_at']
-    d['bootable'] = vol['bootable']
+
+    # Need to form the string true/false explicitly here to
+    # maintain our API contract
+    if vol['bootable']:
+        d['bootable'] = 'true'
+    else:
+        d['bootable'] = 'false'
 
     d['attachments'] = []
     if vol['attach_status'] == 'attached':
index b09b39ed22ae547159d6f08b5784884464465804..28f651a457ed9d66a85a3355e352cc8a85f0c0f5 100644 (file)
@@ -85,7 +85,7 @@ class VolumeApiTest(test.TestCase):
                                                 'host_name': None,
                                                 'id': '1',
                                                 'volume_id': '1'}],
-                               'bootable': False,
+                               'bootable': 'false',
                                'volume_type': 'vol_type_name',
                                'snapshot_id': None,
                                'source_volid': None,
@@ -158,7 +158,7 @@ class VolumeApiTest(test.TestCase):
                                                 'host_name': None,
                                                 'id': '1',
                                                 'volume_id': '1'}],
-                               'bootable': False,
+                               'bootable': 'false',
                                'volume_type': 'vol_type_name',
                                'image_id': test_id,
                                'snapshot_id': None,
@@ -226,7 +226,7 @@ class VolumeApiTest(test.TestCase):
                 'host_name': None,
                 'device': '/'
             }],
-            'bootable': False,
+            'bootable': 'false',
             'volume_type': 'vol_type_name',
             'snapshot_id': None,
             'source_volid': None,
@@ -259,7 +259,7 @@ class VolumeApiTest(test.TestCase):
                 'host_name': None,
                 'device': '/'
             }],
-            'bootable': False,
+            'bootable': 'false',
             'volume_type': 'vol_type_name',
             'snapshot_id': None,
             'source_volid': None,
@@ -306,7 +306,7 @@ class VolumeApiTest(test.TestCase):
                 'host_name': None,
                 'device': '/'
             }],
-            'bootable': False,
+            'bootable': 'false',
             'volume_type': 'None',
             'snapshot_id': None,
             'source_volid': None,
@@ -358,7 +358,7 @@ class VolumeApiTest(test.TestCase):
                                                   'host_name': None,
                                                   'id': '1',
                                                   'volume_id': '1'}],
-                                 'bootable': False,
+                                 'bootable': 'false',
                                  'volume_type': 'vol_type_name',
                                  'snapshot_id': None,
                                  'source_volid': None,
@@ -395,7 +395,7 @@ class VolumeApiTest(test.TestCase):
                                                   'host_name': None,
                                                   'id': '1',
                                                   'volume_id': '1'}],
-                                 'bootable': False,
+                                 'bootable': 'false',
                                  'volume_type': 'None',
                                  'snapshot_id': None,
                                  'source_volid': None,
@@ -423,7 +423,7 @@ class VolumeApiTest(test.TestCase):
                                                   'host_name': None,
                                                   'id': '1',
                                                   'volume_id': '1'}],
-                                 'bootable': False,
+                                 'bootable': 'false',
                                  'volume_type': 'vol_type_name',
                                  'snapshot_id': None,
                                  'source_volid': None,
@@ -460,7 +460,7 @@ class VolumeApiTest(test.TestCase):
                                                   'host_name': None,
                                                   'id': '1',
                                                   'volume_id': '1'}],
-                                 'bootable': False,
+                                 'bootable': 'false',
                                  'volume_type': 'None',
                                  'snapshot_id': None,
                                  'source_volid': None,
@@ -610,7 +610,7 @@ class VolumeApiTest(test.TestCase):
                                                 'host_name': None,
                                                 'id': '1',
                                                 'volume_id': '1'}],
-                               'bootable': False,
+                               'bootable': 'false',
                                'volume_type': 'vol_type_name',
                                'snapshot_id': None,
                                'source_volid': None,
@@ -635,7 +635,7 @@ class VolumeApiTest(test.TestCase):
                                'availability_zone': 'fakeaz',
                                'display_name': 'displayname',
                                'attachments': [],
-                               'bootable': False,
+                               'bootable': 'false',
                                'volume_type': 'vol_type_name',
                                'snapshot_id': None,
                                'source_volid': None,
@@ -664,7 +664,7 @@ class VolumeApiTest(test.TestCase):
                                                 'host_name': None,
                                                 'id': '1',
                                                 'volume_id': '1'}],
-                               'bootable': True,
+                               'bootable': 'true',
                                'volume_type': 'vol_type_name',
                                'snapshot_id': None,
                                'source_volid': None,
@@ -736,7 +736,7 @@ class VolumeApiTest(test.TestCase):
                                                 'host_name': None,
                                                 'id': '1',
                                                 'volume_id': '1'}],
-                               'bootable': False,
+                               'bootable': 'false',
                                'volume_type': 'None',
                                'snapshot_id': None,
                                'source_volid': None,
@@ -867,7 +867,7 @@ class VolumeSerializerTest(test.TestCase):
             status='vol_status',
             size=1024,
             availability_zone='vol_availability',
-            bootable=False,
+            bootable='false',
             created_at=datetime.datetime.now(),
             attachments=[dict(id='vol_id',
                               volume_id='vol_id',
@@ -892,7 +892,7 @@ class VolumeSerializerTest(test.TestCase):
                             status='vol1_status',
                             size=1024,
                             availability_zone='vol1_availability',
-                            bootable=True,
+                            bootable='true',
                             created_at=datetime.datetime.now(),
                             attachments=[dict(id='vol1_id',
                                               volume_id='vol1_id',
@@ -909,7 +909,7 @@ class VolumeSerializerTest(test.TestCase):
                             status='vol2_status',
                             size=1024,
                             availability_zone='vol2_availability',
-                            bootable=False,
+                            bootable='true',
                             created_at=datetime.datetime.now(),
                             attachments=[dict(id='vol2_id',
                                               volume_id='vol2_id',