Adds verfication for Bootable Volume
This submission is to verify the response body of Bootable Volume.
To do so, added required assertions in "test_volumes_get.py"
test script located at ./api/volume and also required modifications
are done in get_volume, list_volumes, list_volumes_with_detail
methods of volumes_client.py(XML)
Implements blueprint: cinder-grizzly1-blueprints-implementation
Change-Id: Id8ac81e268abde1df8d11055079e13e67d4e7ae1
diff --git a/tempest/api/volume/test_volumes_get.py b/tempest/api/volume/test_volumes_get.py
index 2e90f16..e5e350e 100644
--- a/tempest/api/volume/test_volumes_get.py
+++ b/tempest/api/volume/test_volumes_get.py
@@ -68,6 +68,10 @@
fetched_volume['metadata'],
'The fetched Volume is different '
'from the created Volume')
+ if 'imageRef' in kwargs:
+ self.assertEqual(fetched_volume['bootable'], True)
+ if 'imageRef' not in kwargs:
+ self.assertEqual(fetched_volume['bootable'], False)
@attr(type='gate')
def test_volume_get_metadata_none(self):
diff --git a/tempest/services/volume/xml/volumes_client.py b/tempest/services/volume/xml/volumes_client.py
index 936e036..49cbe28 100644
--- a/tempest/services/volume/xml/volumes_client.py
+++ b/tempest/services/volume/xml/volumes_client.py
@@ -60,6 +60,21 @@
"""Return the element 'attachment' from input volumes."""
return volume['attachments']['attachment']
+ def _check_if_bootable(self, volume):
+ """
+ Check if the volume is bootable, also change the value
+ of 'bootable' from string to boolean.
+ """
+ if volume['bootable'] == 'True':
+ volume['bootable'] = True
+ elif volume['bootable'] == 'False':
+ volume['bootable'] = False
+ else:
+ raise ValueError(
+ 'bootable flag is supposed to be either True or False,'
+ 'it is %s' % volume['bootable'])
+ return volume
+
def list_volumes(self, params=None):
"""List all the volumes created."""
url = 'volumes'
@@ -72,6 +87,8 @@
volumes = []
if body is not None:
volumes += [self._parse_volume(vol) for vol in list(body)]
+ for v in volumes:
+ v = self._check_if_bootable(v)
return resp, volumes
def list_volumes_with_detail(self, params=None):
@@ -86,14 +103,17 @@
volumes = []
if body is not None:
volumes += [self._parse_volume(vol) for vol in list(body)]
+ for v in volumes:
+ v = self._check_if_bootable(v)
return resp, volumes
def get_volume(self, volume_id):
"""Returns the details of a single volume."""
url = "volumes/%s" % str(volume_id)
resp, body = self.get(url, self.headers)
- body = etree.fromstring(body)
- return resp, self._parse_volume(body)
+ body = self._parse_volume(etree.fromstring(body))
+ body = self._check_if_bootable(body)
+ return resp, body
def create_volume(self, size, **kwargs):
"""Creates a new Volume.