Add ability to call force_delete from cinderclient

We have an admin extension to do this however we never
exposed it via the cinderclient.

This change simply enables access to force-delete for admins.

Change-Id: Ia066d7dd06ccdb9b3a9221cf33086437624e65d8
This commit is contained in:
john-griffith 2013-01-18 16:55:01 -07:00
parent 8d2e463ac4
commit 07ff48f1de
2 changed files with 19 additions and 0 deletions

View File

@ -253,6 +253,14 @@ def do_delete(cs, args):
volume.delete()
@utils.arg('volume', metavar='<volume>', 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='<volume>', help='ID of the volume to rename.')
@utils.arg('display_name', nargs='?', metavar='<display-name>',
help='New display-name for the volume.')

View File

@ -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))