From 84d855d121adf7fbfc6a5b1bb4924068360d321e Mon Sep 17 00:00:00 2001 From: xiaoxi_chen Date: Thu, 1 Aug 2013 12:15:42 +0800 Subject: [PATCH] Set bootable flag for volume serializer In previous code we didn't set the bootable flag in volume serializer, and even didn't check it in test. This is the root cause for bug #1207155 This patch fixed this issue by set the bootable flag in serializer. Fixed bug #1207155 Change-Id: I0219785aa7f30036747c230800447e99c383042c --- cinder/api/v1/volumes.py | 1 + cinder/api/v2/volumes.py | 1 + cinder/tests/api/v1/test_volumes.py | 5 ++++- cinder/tests/api/v2/test_volumes.py | 5 ++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cinder/api/v1/volumes.py b/cinder/api/v1/volumes.py index 61eb48c23..3053119bb 100644 --- a/cinder/api/v1/volumes.py +++ b/cinder/api/v1/volumes.py @@ -131,6 +131,7 @@ def make_volume(elem): elem.set('availability_zone') elem.set('created_at') elem.set('display_name') + elem.set('bootable') elem.set('display_description') elem.set('volume_type') elem.set('snapshot_id') diff --git a/cinder/api/v2/volumes.py b/cinder/api/v2/volumes.py index 36e354dfb..c2b3f938f 100644 --- a/cinder/api/v2/volumes.py +++ b/cinder/api/v2/volumes.py @@ -52,6 +52,7 @@ def make_volume(elem): elem.set('availability_zone') elem.set('created_at') elem.set('name') + elem.set('bootable') elem.set('description') elem.set('volume_type') elem.set('snapshot_id') diff --git a/cinder/tests/api/v1/test_volumes.py b/cinder/tests/api/v1/test_volumes.py index 4c557efc9..787018662 100644 --- a/cinder/tests/api/v1/test_volumes.py +++ b/cinder/tests/api/v1/test_volumes.py @@ -622,7 +622,7 @@ class VolumeSerializerTest(test.TestCase): for attr in ('id', 'status', 'size', 'availability_zone', 'created_at', 'display_name', 'display_description', 'volume_type', - 'snapshot_id'): + 'bootable', 'snapshot_id'): self.assertEqual(str(vol[attr]), tree.get(attr)) for child in tree: @@ -648,6 +648,7 @@ class VolumeSerializerTest(test.TestCase): status='vol_status', size=1024, availability_zone='vol_availability', + bootable=False, created_at=datetime.datetime.now(), attachments=[dict(id='vol_id', volume_id='vol_id', @@ -673,6 +674,7 @@ class VolumeSerializerTest(test.TestCase): status='vol1_status', size=1024, availability_zone='vol1_availability', + bootable=True, created_at=datetime.datetime.now(), attachments=[dict(id='vol1_id', volume_id='vol1_id', @@ -689,6 +691,7 @@ class VolumeSerializerTest(test.TestCase): status='vol2_status', size=1024, availability_zone='vol2_availability', + bootable=False, created_at=datetime.datetime.now(), attachments=[dict(id='vol2_id', volume_id='vol2_id', diff --git a/cinder/tests/api/v2/test_volumes.py b/cinder/tests/api/v2/test_volumes.py index 828296b61..842f4fb5b 100644 --- a/cinder/tests/api/v2/test_volumes.py +++ b/cinder/tests/api/v2/test_volumes.py @@ -821,7 +821,7 @@ class VolumeSerializerTest(test.TestCase): self.assertEqual(tree.tag, NS + 'volume') for attr in ('id', 'status', 'size', 'availability_zone', 'created_at', - 'name', 'description', 'volume_type', + 'name', 'description', 'volume_type', 'bootable', 'snapshot_id', 'source_volid'): self.assertEqual(str(vol[attr]), tree.get(attr)) @@ -848,6 +848,7 @@ class VolumeSerializerTest(test.TestCase): status='vol_status', size=1024, availability_zone='vol_availability', + bootable=False, created_at=datetime.datetime.now(), attachments=[ dict( @@ -882,6 +883,7 @@ class VolumeSerializerTest(test.TestCase): status='vol1_status', size=1024, availability_zone='vol1_availability', + bootable=True, created_at=datetime.datetime.now(), attachments=[ dict( @@ -903,6 +905,7 @@ class VolumeSerializerTest(test.TestCase): status='vol2_status', size=1024, availability_zone='vol2_availability', + bootable=False, created_at=datetime.datetime.now(), attachments=[dict(id='vol2_id', volume_id='vol2_id', -- 2.45.2