Skip to content

Commit f320e59

Browse files
kk7dsrajathere
authored andcommitted
Add volume-rebuild support to cinder module
Related to blueprint volume-backed-server-build Co-Authored-By: Rajat Dhasmana <[email protected]> Change-Id: I2fcf73e0e6f7fba47bd70fded241f2101eae6f10
1 parent 6085783 commit f320e59

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

nova/tests/unit/volume/test_cinder.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,17 @@ def test_get_volume_encryption_metadata(self, mock_cinderclient):
10461046
mock_volumes.get_encryption_metadata.assert_called_once_with(
10471047
{'encryption_key_id': 'fake_key'})
10481048

1049+
@mock.patch('nova.volume.cinder.cinderclient')
1050+
def test_volume_reimage(self, mock_cinderclient):
1051+
mock_reimage = mock.MagicMock()
1052+
mock_volumes = mock.MagicMock(reimage=mock_reimage)
1053+
mock_cinderclient.return_value = mock.MagicMock(volumes=mock_volumes)
1054+
self.api.reimage_volume(
1055+
self.ctx, uuids.volume_id, uuids.image_id,
1056+
reimage_reserved=True)
1057+
mock_cinderclient.assert_called_once_with(self.ctx, '3.68')
1058+
mock_reimage.assert_called_with(uuids.volume_id, uuids.image_id, True)
1059+
10491060
def test_translate_cinder_exception_no_error(self):
10501061
my_func = mock.Mock()
10511062
my_func.__name__ = 'my_func'

nova/volume/cinder.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,3 +924,9 @@ def attachment_complete(self, context, attachment_id):
924924
{'id': attachment_id,
925925
'msg': str(ex),
926926
'code': getattr(ex, 'code', None)})
927+
928+
@translate_volume_exception
929+
def reimage_volume(self, context, volume_id, image_id,
930+
reimage_reserved=False):
931+
cinderclient(context, '3.68').volumes.reimage(
932+
volume_id, image_id, reimage_reserved)

0 commit comments

Comments
 (0)