summaryrefslogtreecommitdiff
path: root/openstackclient/identity/v3/mapping.py
diff options
context:
space:
mode:
Diffstat (limited to 'openstackclient/identity/v3/mapping.py')
-rw-r--r--openstackclient/identity/v3/mapping.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/openstackclient/identity/v3/mapping.py b/openstackclient/identity/v3/mapping.py
index 69c141b1..09181a0b 100644
--- a/openstackclient/identity/v3/mapping.py
+++ b/openstackclient/identity/v3/mapping.py
@@ -111,21 +111,35 @@ class CreateMapping(command.ShowOne, _RulesReader):
class DeleteMapping(command.Command):
- """Delete mapping"""
+ """Delete mapping(s)"""
def get_parser(self, prog_name):
parser = super(DeleteMapping, self).get_parser(prog_name)
parser.add_argument(
'mapping',
metavar='<mapping>',
- help=_('Mapping to delete'),
+ nargs='+',
+ help=_('Mapping(s) to delete'),
)
return parser
def take_action(self, parsed_args):
identity_client = self.app.client_manager.identity
-
- identity_client.federation.mappings.delete(parsed_args.mapping)
+ result = 0
+ for i in parsed_args.mapping:
+ try:
+ identity_client.federation.mappings.delete(i)
+ except Exception as e:
+ result += 1
+ LOG.error(_("Failed to delete mapping with name or "
+ "ID '%(mapping)s': %(e)s")
+ % {'mapping': i, 'e': e})
+
+ if result > 0:
+ total = len(parsed_args.mapping)
+ msg = (_("%(result)s of %(total)s mappings failed "
+ "to delete.") % {'result': result, 'total': total})
+ raise exceptions.CommandError(msg)
class ListMapping(command.Lister):