From 5d499395ac8028f4863e9a892453a197b254d384 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Thu, 19 Sep 2013 13:05:05 -0600 Subject: [PATCH] Fix type change in bootable setting of volume view 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 | 8 +++++++- cinder/tests/api/v1/test_volumes.py | 32 ++++++++++++++--------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/cinder/api/v1/volumes.py b/cinder/api/v1/volumes.py index 1cef31058..92f0ba022 100644 --- a/cinder/api/v1/volumes.py +++ b/cinder/api/v1/volumes.py @@ -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': diff --git a/cinder/tests/api/v1/test_volumes.py b/cinder/tests/api/v1/test_volumes.py index b09b39ed2..28f651a45 100644 --- a/cinder/tests/api/v1/test_volumes.py +++ b/cinder/tests/api/v1/test_volumes.py @@ -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', -- 2.45.2