Add os-extend_volume_completion volume action.

Change-Id: Ifdeab1a8cd634bbe63c25fae17448c0789b297c9
This commit is contained in:
Konrad Gube 2023-02-13 13:43:16 +01:00
parent 9f8a5c767e
commit dd8ba12681
5 changed files with 31 additions and 1 deletions

View File

@ -26,7 +26,7 @@ LOG = logging.getLogger(__name__)
# key is unsupported version, value is appropriate supported alternative
REPLACEMENT_VERSIONS = {"1": "3", "2": "3"}
MAX_VERSION = "3.70"
MAX_VERSION = "3.71"
MIN_VERSION = "3.0"
_SUBSTITUTIONS = {}

View File

@ -455,6 +455,8 @@ class FakeHTTPClient(fakes_base.FakeHTTPClient):
assert action in body
elif action == 'os-reimage':
assert 'image_id' in body[action]
elif action == 'os-extend_volume_completion':
assert 'error' in body[action]
else:
raise AssertionError("Unexpected action: %s" % action)
return (resp, {}, {})

View File

@ -552,6 +552,8 @@ class FakeHTTPClient(base_client.HTTPClient):
assert 'snapshot_id' in body[action]
elif action == 'os-reimage':
assert 'image_id' in body[action]
elif action == 'os-extend_volume_completion':
assert 'error' in body[action]
else:
raise AssertionError("Unexpected action: %s" % action)
return (resp, {}, _body)

View File

@ -213,3 +213,13 @@ class VolumesTest(utils.TestCase):
'reimage_reserved':
reimage_reserved}})
self._assert_request_id(vol)
@ddt.data(False, True)
def test_complete_volume_extend(self, error):
cs = fakes.FakeClient(api_versions.APIVersion('3.71'))
v = cs.volumes.get('1234')
self._assert_request_id(v)
vol = cs.volumes.extend_volume_completion(v, error)
cs.assert_called('POST', '/volumes/1234/action',
{'os-extend_volume_completion': {'error': error}})
self._assert_request_id(vol)

View File

@ -71,6 +71,10 @@ class Volume(volumes_base.Volume):
"""Rebuilds the volume with the new specified image"""
self.manager.reimage(self, image_id, reimage_reserved)
def extend_volume_completion(self, volume, error=False):
"""Complete extending an attached volume"""
self.manager.extend_volume_completion(self, volume, error)
class VolumeManager(volumes_base.VolumeManager):
resource_class = Volume
@ -304,3 +308,15 @@ class VolumeManager(volumes_base.VolumeManager):
volume,
{'image_id': image_id,
'reimage_reserved': reimage_reserved})
@api_versions.wraps('3.71')
def extend_volume_completion(self, volume, error=False):
"""Complete extending an attached volume.
:param volume: The UUID of the extended volume
:param error: Used to indicate if an error has occured that requires
Cinder to roll back the extend operation.
"""
return self._action('os-extend_volume_completion',
volume,
{'error': error})