diff options
| author | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2016-12-30 13:22:07 +0800 |
|---|---|---|
| committer | Huanxuan Ao <huanxuan.ao@easystack.cn> | 2017-01-03 23:30:49 +0800 |
| commit | 96578cb8ab9a4b95144c33d0af38863fce8d8892 (patch) | |
| tree | 8fd9c537b48aae84b9b3eaac8aa17079adf251b0 /openstackclient/identity/v3/project.py | |
| parent | f020a9ffd6d5602d18c899e7707baaa620ffdd54 (diff) | |
| download | python-openstackclient-96578cb8ab9a4b95144c33d0af38863fce8d8892.tar.gz | |
Error handling for delete commands in identity
Add missing multi deletion error handling for
identity delete commands.
All delete commands in identity support
error handling now.
Change-Id: I05626dcb5e516a423d610906347b02236ba7eeaf
Diffstat (limited to 'openstackclient/identity/v3/project.py')
| -rw-r--r-- | openstackclient/identity/v3/project.py | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/openstackclient/identity/v3/project.py b/openstackclient/identity/v3/project.py index a6348659..12197cdd 100644 --- a/openstackclient/identity/v3/project.py +++ b/openstackclient/identity/v3/project.py @@ -20,6 +20,7 @@ import logging from keystoneauth1 import exceptions as ks_exc from osc_lib.cli import parseractions from osc_lib.command import command +from osc_lib import exceptions from osc_lib import utils import six @@ -148,15 +149,28 @@ class DeleteProject(command.Command): domain = None if parsed_args.domain: domain = common.find_domain(identity_client, parsed_args.domain) + errors = 0 for project in parsed_args.projects: - if domain is not None: - project_obj = utils.find_resource(identity_client.projects, - project, - domain_id=domain.id) - else: - project_obj = utils.find_resource(identity_client.projects, - project) - identity_client.projects.delete(project_obj.id) + try: + if domain is not None: + project_obj = utils.find_resource(identity_client.projects, + project, + domain_id=domain.id) + else: + project_obj = utils.find_resource(identity_client.projects, + project) + identity_client.projects.delete(project_obj.id) + except Exception as e: + errors += 1 + LOG.error(_("Failed to delete project with " + "name or ID '%(project)s': %(e)s"), + {'project': project, 'e': e}) + + if errors > 0: + total = len(parsed_args.projects) + msg = (_("%(errors)s of %(total)s projects failed " + "to delete.") % {'errors': errors, 'total': total}) + raise exceptions.CommandError(msg) class ListProject(command.Lister): |
