diff options
| author | wuyuting <wytdahu@gmail.com> | 2016-06-05 22:55:43 -0400 |
|---|---|---|
| committer | Rui Chen <chenrui.momo@gmail.com> | 2016-07-27 11:30:52 +0800 |
| commit | 954c28dfa21be76b0522af051d71fb9470877a1a (patch) | |
| tree | e39e3e3eeb5722a85259a72566987a8b876a10ed /openstackclient/volume | |
| parent | 7a667d700f97dda386c3db3bffc8138182fbeccb (diff) | |
| download | python-openstackclient-954c28dfa21be76b0522af051d71fb9470877a1a.tar.gz | |
Add support for deleting volumes with associated snapshots
OSC doesn't support deleting volumes with associated snapshots.
This patch provides support for deleting volumes with associated
snapshots by adding an optional argument.
Change-Id: I7e74f251574993ff13a38e508fd2f9debeda8d0a
Closes-Bug: #1589332
Co-Authored-By: Rui Chen <chenrui.momo@gmail.com>
Diffstat (limited to 'openstackclient/volume')
| -rw-r--r-- | openstackclient/volume/v2/volume.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/openstackclient/volume/v2/volume.py b/openstackclient/volume/v2/volume.py index 85f267ef..6f055922 100644 --- a/openstackclient/volume/v2/volume.py +++ b/openstackclient/volume/v2/volume.py @@ -166,13 +166,19 @@ class DeleteVolume(command.Command): nargs="+", help=_("Volume(s) to delete (name or ID)") ) - parser.add_argument( + group = parser.add_mutually_exclusive_group() + group.add_argument( "--force", action="store_true", - default=False, help=_("Attempt forced removal of volume(s), regardless of state " "(defaults to False)") ) + group.add_argument( + "--purge", + action="store_true", + help=_("Remove any snapshots along with volume(s) " + "(defaults to False)") + ) return parser def take_action(self, parsed_args): @@ -186,12 +192,13 @@ class DeleteVolume(command.Command): if parsed_args.force: volume_client.volumes.force_delete(volume_obj.id) else: - volume_client.volumes.delete(volume_obj.id) + volume_client.volumes.delete(volume_obj.id, + cascade=parsed_args.purge) except Exception as e: result += 1 LOG.error(_("Failed to delete volume with " - "name or ID '%(volume)s': %(e)s") - % {'volume': i, 'e': e}) + "name or ID '%(volume)s': %(e)s"), + {'volume': i, 'e': e}) if result > 0: total = len(parsed_args.volumes) |
