diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index 651235370..2bb2d4b1b 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -253,6 +253,14 @@ def do_delete(cs, args): volume.delete() +@utils.arg('volume', metavar='', help='ID of the volume to delete.') +@utils.service_type('volume') +def do_force_delete(cs, args): + """Attempt forced removal of a volume, regardless of it's state.""" + volume = _find_volume(cs, args.volume) + volume.force_delete() + + @utils.arg('volume', metavar='', help='ID of the volume to rename.') @utils.arg('display_name', nargs='?', metavar='', help='New display-name for the volume.') diff --git a/cinderclient/v1/volumes.py b/cinderclient/v1/volumes.py index 930435494..078cd6faa 100644 --- a/cinderclient/v1/volumes.py +++ b/cinderclient/v1/volumes.py @@ -112,6 +112,14 @@ class Volume(base.Resource): self.manager.upload_to_image(self, force, image_name, container_format, disk_format) + def force_delete(self): + """ + Delete the specififed volume ignoring it's current state. + + :param volume: The UUID of the volume to force-delete. + """ + self.manager.force_delete(self) + class VolumeManager(base.ManagerWithFind): """ @@ -338,3 +346,6 @@ class VolumeManager(base.ManagerWithFind): 'image_name': image_name, 'container_format': container_format, 'disk_format': disk_format}) + + def force_delete(self, volume): + return self._action('os-force_delete', base.getid(volume))