diff options
| author | sunyajing <yajing.sun@easystack.cn> | 2016-06-23 12:55:54 +0800 |
|---|---|---|
| committer | Steve Martinelli <s.martinelli@gmail.com> | 2016-06-23 23:57:49 -0400 |
| commit | 6df09fd377f872388d4f855b001a6578ae6fba46 (patch) | |
| tree | df8bba22d73bf72444a184433fb41c084e26bd0a /openstackclient/identity/v2_0/endpoint.py | |
| parent | 5b144334bf526c8d368e592019fbb80c072911dc (diff) | |
| download | python-openstackclient-6df09fd377f872388d4f855b001a6578ae6fba46.tar.gz | |
Support multi-delete for commands in identity V2
Commands are "ec2 credentials delete", "service delete", "endpoint delete".
Also update their unit tests and functional tests.
Partial-Bug: #1592906
Change-Id: I1a0b7160b803a523646d09d030e6f112c81c4c24
Diffstat (limited to 'openstackclient/identity/v2_0/endpoint.py')
| -rw-r--r-- | openstackclient/identity/v2_0/endpoint.py | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/openstackclient/identity/v2_0/endpoint.py b/openstackclient/identity/v2_0/endpoint.py index ee2bab6f..5a3b3186 100644 --- a/openstackclient/identity/v2_0/endpoint.py +++ b/openstackclient/identity/v2_0/endpoint.py @@ -15,7 +15,10 @@ """Endpoint action implementations""" +import logging + from osc_lib.command import command +from osc_lib import exceptions from osc_lib import utils import six @@ -23,6 +26,9 @@ from openstackclient.i18n import _ from openstackclient.identity import common +LOG = logging.getLogger(__name__) + + class CreateEndpoint(command.ShowOne): """Create new endpoint""" @@ -74,20 +80,36 @@ class CreateEndpoint(command.ShowOne): class DeleteEndpoint(command.Command): - """Delete endpoint""" + """Delete endpoint(s)""" def get_parser(self, prog_name): parser = super(DeleteEndpoint, self).get_parser(prog_name) parser.add_argument( - 'endpoint', + 'endpoints', metavar='<endpoint-id>', - help=_('Endpoint to delete (ID only)'), + nargs='+', + help=_('Endpoint(s) to delete (ID only)'), ) return parser def take_action(self, parsed_args): identity_client = self.app.client_manager.identity - identity_client.endpoints.delete(parsed_args.endpoint) + + result = 0 + for endpoint in parsed_args.endpoints: + try: + identity_client.endpoints.delete(endpoint) + except Exception as e: + result += 1 + LOG.error(_("Failed to delete endpoint with " + "ID '%(endpoint)s': %(e)s") + % {'endpoint': endpoint, 'e': e}) + + if result > 0: + total = len(parsed_args.endpoints) + msg = (_("%(result)s of %(total)s endpoints failed " + "to delete.") % {'result': result, 'total': total}) + raise exceptions.CommandError(msg) class ListEndpoint(command.Lister): |
