Merge "Add ability to call force_delete from cinderclient"

This commit is contained in:
Jenkins 2013-01-24 07:14:27 +00:00 committed by Gerrit Code Review
commit 55ae2c1cd5
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))