Merge "Make Volume/VolumeCollection operations blocking"
This commit is contained in:
commit
57ef5b3217
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Make POST and DELETE operations in Volume and VolumeCollection blocking.
|
|
@ -96,7 +96,8 @@ class Volume(base.ResourceBase):
|
|||
parameter='value', value=value, valid_values=valid_values)
|
||||
value = store_maps.VOLUME_INIT_TYPE_MAP_REV[value]
|
||||
target_uri = self._get_initialize_action_element().target_uri
|
||||
self._conn.post(target_uri, data={'InitializeType': value})
|
||||
self._conn.post(target_uri, data={'InitializeType': value},
|
||||
blocking=True)
|
||||
|
||||
def delete_volume(self, payload=None):
|
||||
"""Delete the volume.
|
||||
|
@ -105,7 +106,7 @@ class Volume(base.ResourceBase):
|
|||
:raises: ConnectionError
|
||||
:raises: HTTPError
|
||||
"""
|
||||
self._conn.delete(self._path, data=payload)
|
||||
self._conn.delete(self._path, data=payload, blocking=True)
|
||||
|
||||
|
||||
class VolumeCollection(base.ResourceCollectionBase):
|
||||
|
@ -147,15 +148,11 @@ class VolumeCollection(base.ResourceCollectionBase):
|
|||
:param payload: The payload representing the new volume to create.
|
||||
:raises: ConnectionError
|
||||
:raises: HTTPError
|
||||
:returns: Newly created Volume resource or None if no Location header
|
||||
"""
|
||||
r = self._conn.post(self._path, data=payload)
|
||||
r = self._conn.post(self._path, data=payload, blocking=True)
|
||||
location = r.headers.get('Location')
|
||||
new_volume = None
|
||||
if r.status_code == 201:
|
||||
if location:
|
||||
self.refresh()
|
||||
new_volume = self.get_member(location)
|
||||
elif r.status_code == 202:
|
||||
# TODO(billdodd): TaskMonitor support to be added in subsequent PR
|
||||
pass
|
||||
return new_volume
|
||||
return self.get_member(location)
|
||||
|
|
|
@ -59,7 +59,7 @@ class VolumeTestCase(base.TestCase):
|
|||
'Volumes/1/Actions/Volume.Initialize'
|
||||
self.stor_volume.initialize_volume('fast')
|
||||
self.stor_volume._conn.post.assert_called_once_with(
|
||||
target_uri, data={'InitializeType': 'Fast'})
|
||||
target_uri, data={'InitializeType': 'Fast'}, blocking=True)
|
||||
|
||||
def test_initialize_volume_bad_value(self):
|
||||
self.assertRaisesRegex(
|
||||
|
@ -70,13 +70,13 @@ class VolumeTestCase(base.TestCase):
|
|||
def test_delete_volume(self):
|
||||
self.stor_volume.delete_volume()
|
||||
self.stor_volume._conn.delete.assert_called_once_with(
|
||||
self.stor_volume._path, data=None)
|
||||
self.stor_volume._path, data=None, blocking=True)
|
||||
|
||||
def test_delete_volume_with_payload(self):
|
||||
payload = {'@Redfish.OperationApplyTime': 'OnReset'}
|
||||
self.stor_volume.delete_volume(payload=payload)
|
||||
self.stor_volume._conn.delete.assert_called_once_with(
|
||||
self.stor_volume._path, data=payload)
|
||||
self.stor_volume._path, data=payload, blocking=True)
|
||||
|
||||
|
||||
class VolumeCollectionTestCase(base.TestCase):
|
||||
|
@ -190,7 +190,7 @@ class VolumeCollectionTestCase(base.TestCase):
|
|||
new_vol = self.stor_vol_col.create_volume(payload)
|
||||
self.stor_vol_col._conn.post.assert_called_once_with(
|
||||
'/redfish/v1/Systems/437XR1138R2/Storage/1/Volumes',
|
||||
data=payload)
|
||||
data=payload, blocking=True)
|
||||
self.stor_vol_col.refresh.assert_called_once()
|
||||
self.assertIsNotNone(new_vol)
|
||||
self.assertEqual('4', new_vol.identity)
|
||||
|
|
Loading…
Reference in New Issue