diff options
| author | Jenkins <jenkins@review.openstack.org> | 2016-06-23 20:55:08 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2016-06-23 20:55:08 +0000 |
| commit | 28f261eeca421b199951b12aaa8bc922c5bd6b8b (patch) | |
| tree | d90e3c67b87edf7461b86af9c23d7dafd7990afb /openstackclient/volume/v2 | |
| parent | b7909252a586d84042bf2dfec82000b2ded6101e (diff) | |
| parent | 4e62e1e2e18cb93ba0f88bff8727182b1002de4b (diff) | |
| download | python-openstackclient-28f261eeca421b199951b12aaa8bc922c5bd6b8b.tar.gz | |
Merge "support multi-delete for volume-type"
Diffstat (limited to 'openstackclient/volume/v2')
| -rw-r--r-- | openstackclient/volume/v2/volume_type.py | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/openstackclient/volume/v2/volume_type.py b/openstackclient/volume/v2/volume_type.py index 5e9faa1d..87f4c547 100644 --- a/openstackclient/volume/v2/volume_type.py +++ b/openstackclient/volume/v2/volume_type.py @@ -92,22 +92,39 @@ class CreateVolumeType(command.ShowOne): class DeleteVolumeType(command.Command): - """Delete volume type""" + """Delete volume type(s)""" def get_parser(self, prog_name): parser = super(DeleteVolumeType, self).get_parser(prog_name) parser.add_argument( - "volume_type", + "volume_types", metavar="<volume-type>", - help=_("Volume type to delete (name or ID)") + nargs="+", + help=_("Volume type(s) to delete (name or ID)") ) return parser def take_action(self, parsed_args): volume_client = self.app.client_manager.volume - volume_type = utils.find_resource( - volume_client.volume_types, parsed_args.volume_type) - volume_client.volume_types.delete(volume_type.id) + result = 0 + + for volume_type in parsed_args.volume_types: + try: + vol_type = utils.find_resource(volume_client.volume_types, + volume_type) + + volume_client.volume_types.delete(vol_type) + except Exception as e: + result += 1 + LOG.error(_("Failed to delete volume type with " + "name or ID '%(volume_type)s': %(e)s") + % {'volume_type': volume_type, 'e': e}) + + if result > 0: + total = len(parsed_args.volume_types) + msg = (_("%(result)s of %(total)s volume types failed " + "to delete.") % {'result': result, 'total': total}) + raise exceptions.CommandError(msg) class ListVolumeType(command.Lister): |
