summaryrefslogtreecommitdiff
path: root/cinderclient/v3/volumes.py
diff options
context:
space:
mode:
authorwhoami-rajat <rajatdhasmana@gmail.com>2018-10-01 12:55:43 +0530
committerwhoami-rajat <rajatdhasmana@gmail.com>2022-02-24 23:13:19 +0530
commit12075cb71067563f60de929e61f79eae33b2c2ec (patch)
tree665a82bcf7e08994cbb96bdf2b0cc042d5034a4e /cinderclient/v3/volumes.py
parentaf3bc66a5fe2a1ab37d537b6cfe1f5dfb5659002 (diff)
downloadpython-cinderclient-12075cb71067563f60de929e61f79eae33b2c2ec.tar.gz
Add volume reimage command
A new reimage API will be introduced on cinder API side with change in depends on. This patch provides the CLI support for the same by adding a reimage command. Implements: blueprint add-volume-re-image-api Change-Id: I37c254d4caf2f416e456ff6a78b5a4df4e08a176
Diffstat (limited to 'cinderclient/v3/volumes.py')
-rw-r--r--cinderclient/v3/volumes.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/cinderclient/v3/volumes.py b/cinderclient/v3/volumes.py
index 42527f7..0479dc3 100644
--- a/cinderclient/v3/volumes.py
+++ b/cinderclient/v3/volumes.py
@@ -67,6 +67,10 @@ class Volume(volumes_base.Volume):
metadata=metadata, bootable=bootable,
cluster=cluster)
+ def reimage(self, image_id, reimage_reserved=False):
+ """Rebuilds the volume with the new specified image"""
+ self.manager.reimage(self, image_id, reimage_reserved)
+
class VolumeManager(volumes_base.VolumeManager):
resource_class = Volume
@@ -282,3 +286,21 @@ class VolumeManager(volumes_base.VolumeManager):
search_opts=options)
return self._get(url, None)
+
+ @api_versions.wraps('3.68')
+ def reimage(self, volume, image_id, reimage_reserved=False):
+ """Reimage a volume
+
+ .. warning:: This is a destructive action and the contents of the
+ volume will be lost.
+
+ :param volume: Volume to reimage.
+ :param reimage_reserved: Boolean to enable or disable reimage
+ of a volume that is in 'reserved' state otherwise only
+ volumes in 'available' status may be re-imaged.
+ :param image_id: The image id.
+ """
+ return self._action('os-reimage',
+ volume,
+ {'image_id': image_id,
+ 'reimage_reserved': reimage_reserved})