summaryrefslogtreecommitdiff
path: root/openstackclient/identity/v3/federation_protocol.py
diff options
context:
space:
mode:
authorHuanxuan Ao <huanxuan.ao@easystack.cn>2016-07-12 12:44:55 +0800
committerHuanxuan Ao <huanxuan.ao@easystack.cn>2016-07-19 09:49:36 +0800
commit60639d76a742852e18f9e2889c480be95596c268 (patch)
treecad7069ec7b4175f9ceea7e14113b9477698f1e8 /openstackclient/identity/v3/federation_protocol.py
parent55c1c575d63f4e9e6fc3f4dbb6c572e841b513d9 (diff)
downloadpython-openstackclient-60639d76a742852e18f9e2889c480be95596c268.tar.gz
Support bulk deletion for delete commands in identityv3
Support bulk deletion for delete commands in the list below identity/v3/consumer identity/v3/credential identity/v3/domain identity/v3/ec2creds identity/v3/endpoint identity/v3/federation_protocol identity/v3/identity_provider identity/v3/mapping identity/v3/policy identity/v3/region identity/v3/service_provider identity/v3/service The unit test in identityv3 need to be refactored, so I add some functional tests instead. I will add all unit tests at one time after the refactor completed. Change-Id: I82367570f59817b47c87b6c7bfeae95ccfe5c50e Closes-Bug: #1592906
Diffstat (limited to 'openstackclient/identity/v3/federation_protocol.py')
-rw-r--r--openstackclient/identity/v3/federation_protocol.py24
1 files changed, 20 insertions, 4 deletions
diff --git a/openstackclient/identity/v3/federation_protocol.py b/openstackclient/identity/v3/federation_protocol.py
index 0369bc3d..3fde9027 100644
--- a/openstackclient/identity/v3/federation_protocol.py
+++ b/openstackclient/identity/v3/federation_protocol.py
@@ -17,6 +17,7 @@
import logging
from osc_lib.command import command
+from osc_lib import exceptions
from osc_lib import utils
import six
@@ -71,14 +72,15 @@ class CreateProtocol(command.ShowOne):
class DeleteProtocol(command.Command):
- """Delete federation protocol"""
+ """Delete federation protocol(s)"""
def get_parser(self, prog_name):
parser = super(DeleteProtocol, self).get_parser(prog_name)
parser.add_argument(
'federation_protocol',
metavar='<federation-protocol>',
- help=_('Federation protocol to delete (name or ID)'),
+ nargs='+',
+ help=_('Federation protocol(s) to delete (name or ID)'),
)
parser.add_argument(
'--identity-provider',
@@ -92,8 +94,22 @@ class DeleteProtocol(command.Command):
def take_action(self, parsed_args):
identity_client = self.app.client_manager.identity
- identity_client.federation.protocols.delete(
- parsed_args.identity_provider, parsed_args.federation_protocol)
+ result = 0
+ for i in parsed_args.federation_protocol:
+ try:
+ identity_client.federation.protocols.delete(
+ parsed_args.identity_provider, i)
+ except Exception as e:
+ result += 1
+ LOG.error(_("Failed to delete federation protocol "
+ "with name or ID '%(protocol)s': %(e)s")
+ % {'protocol': i, 'e': e})
+
+ if result > 0:
+ total = len(parsed_args.federation_protocol)
+ msg = (_("%(result)s of %(total)s federation protocols failed"
+ " to delete.") % {'result': result, 'total': total})
+ raise exceptions.CommandError(msg)
class ListProtocols(command.Lister):