From 3ec28c3309d28d99a10ab1e1b55fd360fd2a97b5 Mon Sep 17 00:00:00 2001 From: Peter Hamilton Date: Fri, 28 Feb 2014 15:30:54 -0500 Subject: [PATCH] Fix type-delete to allow deletion by name and ID This change addresses bug #1286314, fixing type deletion to allow deletion by either volume type name or ID. The former implementation only accepted the volume type ID. Help documentation is also updated to reflect this change. Change-Id: I0fc66b54a7bcfa4e00a4d136ac513fa40e628dd2 Closes-Bug: #1286314 DocImpact --- cinderclient/v1/shell.py | 5 +++-- cinderclient/v1/volume_types.py | 2 +- cinderclient/v2/shell.py | 5 +++-- cinderclient/v2/volume_types.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cinderclient/v1/shell.py b/cinderclient/v1/shell.py index 140d59c79..f85a4c295 100644 --- a/cinderclient/v1/shell.py +++ b/cinderclient/v1/shell.py @@ -579,11 +579,12 @@ def do_type_create(cs, args): @utils.arg('id', metavar='', - help="Unique ID of the volume type to delete") + help="Name or ID of the volume type to delete") @utils.service_type('volume') def do_type_delete(cs, args): """Delete a specific volume type.""" - cs.volume_types.delete(args.id) + volume_type = _find_volume_type(cs, args.id) + cs.volume_types.delete(volume_type) @utils.arg('vtype', diff --git a/cinderclient/v1/volume_types.py b/cinderclient/v1/volume_types.py index e8b2c3984..abfa43ede 100644 --- a/cinderclient/v1/volume_types.py +++ b/cinderclient/v1/volume_types.py @@ -101,7 +101,7 @@ class VolumeTypeManager(base.ManagerWithFind): """ Delete a specific volume_type. - :param volume_type: The ID of the :class:`VolumeType` to get. + :param volume_type: The name or ID of the :class:`VolumeType` to get. """ self._delete("/types/%s" % base.getid(volume_type)) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 129fc8220..2e48339cd 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -637,11 +637,12 @@ def do_type_create(cs, args): @utils.arg('id', metavar='', - help="Unique ID of the volume type to delete") + help="Name or ID of the volume type to delete") @utils.service_type('volumev2') def do_type_delete(cs, args): """Delete a specific volume type.""" - cs.volume_types.delete(args.id) + volume_type = _find_volume_type(cs, args.id) + cs.volume_types.delete(volume_type) @utils.arg('vtype', diff --git a/cinderclient/v2/volume_types.py b/cinderclient/v2/volume_types.py index 3d7630242..26b396f1d 100644 --- a/cinderclient/v2/volume_types.py +++ b/cinderclient/v2/volume_types.py @@ -88,7 +88,7 @@ class VolumeTypeManager(base.ManagerWithFind): def delete(self, volume_type): """Delete a specific volume_type. - :param volume_type: The ID of the :class:`VolumeType` to get. + :param volume_type: The name or ID of the :class:`VolumeType` to get. """ self._delete("/types/%s" % base.getid(volume_type))