add multi-delete support for identity
This is part2. Add support for these objects: identity.project(v2.0) identity.role(v2.0) identity.user(v2.0) identity.project(v3) identity.role(v3) identity.user(v3) identity.group(v3) Closes-Bug: #1400597 Change-Id: I270434d657cf4ddc23c3aba2c704d6ef184b0dbc
This commit is contained in:
parent
3541b0a695
commit
d8f1cbd984
doc/source/command-objects
openstackclient
identity
tests/identity
@ -47,16 +47,16 @@ Create new project
|
||||
|
||||
New project name
|
||||
|
||||
project delete
|
||||
--------------
|
||||
project(s) delete
|
||||
-----------------
|
||||
|
||||
Delete an existing project
|
||||
Delete project(s)
|
||||
|
||||
.. program:: project delete
|
||||
.. program:: project(s) delete
|
||||
.. code:: bash
|
||||
|
||||
os project delete
|
||||
<project>
|
||||
<project> [<project> ...]
|
||||
|
||||
.. option:: --domain <domain>
|
||||
|
||||
|
@ -56,16 +56,16 @@ Create new role
|
||||
|
||||
New role name
|
||||
|
||||
role delete
|
||||
-----------
|
||||
role(s) delete
|
||||
--------------
|
||||
|
||||
Delete an existing role
|
||||
Delete role(s)
|
||||
|
||||
.. program:: role delete
|
||||
.. program:: role(s) delete
|
||||
.. code:: bash
|
||||
|
||||
os role delete
|
||||
<role>
|
||||
<role> [<role> ...]
|
||||
|
||||
.. option:: <role>
|
||||
|
||||
|
@ -69,16 +69,16 @@ Create new user
|
||||
|
||||
New user name
|
||||
|
||||
user delete
|
||||
-----------
|
||||
user(s) delete
|
||||
--------------
|
||||
|
||||
Delete user
|
||||
Delete user(s)
|
||||
|
||||
.. program:: user delete
|
||||
.. program:: user(s) delete
|
||||
.. code:: bash
|
||||
|
||||
os user delete
|
||||
<user>
|
||||
<user> [<user> ...]
|
||||
|
||||
.. option:: --domain <domain>
|
||||
|
||||
|
@ -104,16 +104,17 @@ class CreateProject(show.ShowOne):
|
||||
|
||||
|
||||
class DeleteProject(command.Command):
|
||||
"""Delete an existing project"""
|
||||
"""Delete project(s)"""
|
||||
|
||||
log = logging.getLogger(__name__ + '.DeleteProject')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteProject, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'project',
|
||||
'projects',
|
||||
metavar='<project>',
|
||||
help=_('Project to delete (name or ID)'),
|
||||
nargs="+",
|
||||
help=_('Project(s) to delete (name or ID)'),
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -121,12 +122,12 @@ class DeleteProject(command.Command):
|
||||
self.log.debug('take_action(%s)', parsed_args)
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
project = utils.find_resource(
|
||||
identity_client.tenants,
|
||||
parsed_args.project,
|
||||
)
|
||||
|
||||
identity_client.tenants.delete(project.id)
|
||||
for project in parsed_args.projects:
|
||||
project_obj = utils.find_resource(
|
||||
identity_client.tenants,
|
||||
project,
|
||||
)
|
||||
identity_client.tenants.delete(project_obj.id)
|
||||
return
|
||||
|
||||
|
||||
|
@ -114,16 +114,17 @@ class CreateRole(show.ShowOne):
|
||||
|
||||
|
||||
class DeleteRole(command.Command):
|
||||
"""Delete an existing role"""
|
||||
"""Delete role(s)"""
|
||||
|
||||
log = logging.getLogger(__name__ + '.DeleteRole')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteRole, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'role',
|
||||
'roles',
|
||||
metavar='<role>',
|
||||
help=_('Role to delete (name or ID)'),
|
||||
nargs="+",
|
||||
help=_('Role(s) to delete (name or ID)'),
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -131,12 +132,12 @@ class DeleteRole(command.Command):
|
||||
self.log.debug('take_action(%s)', parsed_args)
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
role = utils.find_resource(
|
||||
identity_client.roles,
|
||||
parsed_args.role,
|
||||
)
|
||||
|
||||
identity_client.roles.delete(role.id)
|
||||
for role in parsed_args.roles:
|
||||
role_obj = utils.find_resource(
|
||||
identity_client.roles,
|
||||
role,
|
||||
)
|
||||
identity_client.roles.delete(role_obj.id)
|
||||
return
|
||||
|
||||
|
||||
|
@ -128,16 +128,17 @@ class CreateUser(show.ShowOne):
|
||||
|
||||
|
||||
class DeleteUser(command.Command):
|
||||
"""Delete user"""
|
||||
"""Delete user(s)"""
|
||||
|
||||
log = logging.getLogger(__name__ + '.DeleteUser')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteUser, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'user',
|
||||
'users',
|
||||
metavar='<user>',
|
||||
help=_('User to delete (name or ID)'),
|
||||
nargs="+",
|
||||
help=_('User(s) to delete (name or ID)'),
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -145,12 +146,12 @@ class DeleteUser(command.Command):
|
||||
self.log.debug('take_action(%s)', parsed_args)
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
user = utils.find_resource(
|
||||
identity_client.users,
|
||||
parsed_args.user,
|
||||
)
|
||||
|
||||
identity_client.users.delete(user.id)
|
||||
for user in parsed_args.users:
|
||||
user_obj = utils.find_resource(
|
||||
identity_client.users,
|
||||
user,
|
||||
)
|
||||
identity_client.users.delete(user_obj.id)
|
||||
return
|
||||
|
||||
|
||||
|
@ -159,16 +159,17 @@ class CreateGroup(show.ShowOne):
|
||||
|
||||
|
||||
class DeleteGroup(command.Command):
|
||||
"""Delete group command"""
|
||||
"""Delete group(s)"""
|
||||
|
||||
log = logging.getLogger(__name__ + '.DeleteGroup')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteGroup, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'group',
|
||||
'groups',
|
||||
metavar='<group>',
|
||||
help='Name or ID of group to delete')
|
||||
nargs="+",
|
||||
help='Group(s) to delete (name or ID)')
|
||||
parser.add_argument(
|
||||
'--domain',
|
||||
metavar='<domain>',
|
||||
@ -180,16 +181,18 @@ class DeleteGroup(command.Command):
|
||||
self.log.debug('take_action(%s)', parsed_args)
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
domain = None
|
||||
if parsed_args.domain:
|
||||
domain = common.find_domain(identity_client, parsed_args.domain)
|
||||
group = utils.find_resource(identity_client.groups,
|
||||
parsed_args.group,
|
||||
domain_id=domain.id)
|
||||
else:
|
||||
group = utils.find_resource(identity_client.groups,
|
||||
parsed_args.group)
|
||||
|
||||
identity_client.groups.delete(group.id)
|
||||
for group in parsed_args.groups:
|
||||
if domain is not None:
|
||||
group_obj = utils.find_resource(identity_client.groups,
|
||||
group,
|
||||
domain_id=domain.id)
|
||||
else:
|
||||
group_obj = utils.find_resource(identity_client.groups,
|
||||
group)
|
||||
identity_client.groups.delete(group_obj.id)
|
||||
return
|
||||
|
||||
|
||||
|
@ -117,16 +117,17 @@ class CreateProject(show.ShowOne):
|
||||
|
||||
|
||||
class DeleteProject(command.Command):
|
||||
"""Delete an existing project"""
|
||||
"""Delete project(s)"""
|
||||
|
||||
log = logging.getLogger(__name__ + '.DeleteProject')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteProject, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'project',
|
||||
'projects',
|
||||
metavar='<project>',
|
||||
help='Project to delete (name or ID)',
|
||||
nargs="+",
|
||||
help='Project(s) to delete (name or ID)',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--domain',
|
||||
@ -139,16 +140,18 @@ class DeleteProject(command.Command):
|
||||
self.log.debug('take_action(%s)', parsed_args)
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
domain = None
|
||||
if parsed_args.domain:
|
||||
domain = common.find_domain(identity_client, parsed_args.domain)
|
||||
project = utils.find_resource(identity_client.projects,
|
||||
parsed_args.project,
|
||||
domain_id=domain.id)
|
||||
else:
|
||||
project = utils.find_resource(identity_client.projects,
|
||||
parsed_args.project)
|
||||
|
||||
identity_client.projects.delete(project.id)
|
||||
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)
|
||||
return
|
||||
|
||||
|
||||
|
@ -177,16 +177,17 @@ class CreateRole(show.ShowOne):
|
||||
|
||||
|
||||
class DeleteRole(command.Command):
|
||||
"""Delete an existing role"""
|
||||
"""Delete role(s)"""
|
||||
|
||||
log = logging.getLogger(__name__ + '.DeleteRole')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteRole, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'role',
|
||||
'roles',
|
||||
metavar='<role>',
|
||||
help='Role to delete (name or ID)',
|
||||
nargs="+",
|
||||
help='Role(s) to delete (name or ID)',
|
||||
)
|
||||
return parser
|
||||
|
||||
@ -194,12 +195,12 @@ class DeleteRole(command.Command):
|
||||
self.log.debug('take_action(%s)', parsed_args)
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
role = utils.find_resource(
|
||||
identity_client.roles,
|
||||
parsed_args.role,
|
||||
)
|
||||
|
||||
identity_client.roles.delete(role.id)
|
||||
for role in parsed_args.roles:
|
||||
role_obj = utils.find_resource(
|
||||
identity_client.roles,
|
||||
role,
|
||||
)
|
||||
identity_client.roles.delete(role_obj.id)
|
||||
return
|
||||
|
||||
|
||||
|
@ -137,16 +137,17 @@ class CreateUser(show.ShowOne):
|
||||
|
||||
|
||||
class DeleteUser(command.Command):
|
||||
"""Delete user"""
|
||||
"""Delete user(s)"""
|
||||
|
||||
log = logging.getLogger(__name__ + '.DeleteUser')
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(DeleteUser, self).get_parser(prog_name)
|
||||
parser.add_argument(
|
||||
'user',
|
||||
'users',
|
||||
metavar='<user>',
|
||||
help='User to delete (name or ID)',
|
||||
nargs="+",
|
||||
help='User(s) to delete (name or ID)',
|
||||
)
|
||||
parser.add_argument(
|
||||
'--domain',
|
||||
@ -159,16 +160,18 @@ class DeleteUser(command.Command):
|
||||
self.log.debug('take_action(%s)', parsed_args)
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
domain = None
|
||||
if parsed_args.domain:
|
||||
domain = common.find_domain(identity_client, parsed_args.domain)
|
||||
user = utils.find_resource(identity_client.users,
|
||||
parsed_args.user,
|
||||
domain_id=domain.id)
|
||||
else:
|
||||
user = utils.find_resource(identity_client.users,
|
||||
parsed_args.user)
|
||||
|
||||
identity_client.users.delete(user.id)
|
||||
for user in parsed_args.users:
|
||||
if domain is not None:
|
||||
user_obj = utils.find_resource(identity_client.users,
|
||||
user,
|
||||
domain_id=domain.id)
|
||||
else:
|
||||
user_obj = utils.find_resource(identity_client.users,
|
||||
user)
|
||||
identity_client.users.delete(user_obj.id)
|
||||
return
|
||||
|
||||
|
||||
|
@ -326,7 +326,7 @@ class TestProjectDelete(TestProject):
|
||||
identity_fakes.project_id,
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.project_id),
|
||||
('projects', [identity_fakes.project_id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
|
@ -234,7 +234,7 @@ class TestRoleDelete(TestRole):
|
||||
identity_fakes.role_name,
|
||||
]
|
||||
verifylist = [
|
||||
('role', identity_fakes.role_name),
|
||||
('roles', [identity_fakes.role_name]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
|
@ -443,7 +443,7 @@ class TestUserDelete(TestUser):
|
||||
identity_fakes.user_id,
|
||||
]
|
||||
verifylist = [
|
||||
('user', identity_fakes.user_id),
|
||||
('users', [identity_fakes.user_id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
|
@ -353,7 +353,7 @@ class TestProjectDelete(TestProject):
|
||||
identity_fakes.project_id,
|
||||
]
|
||||
verifylist = [
|
||||
('project', identity_fakes.project_id),
|
||||
('projects', [identity_fakes.project_id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
|
@ -271,7 +271,7 @@ class TestRoleDelete(TestRole):
|
||||
identity_fakes.role_name,
|
||||
]
|
||||
verifylist = [
|
||||
('role', identity_fakes.role_name),
|
||||
('roles', [identity_fakes.role_name]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
|
@ -461,7 +461,7 @@ class TestUserDelete(TestUser):
|
||||
identity_fakes.user_id,
|
||||
]
|
||||
verifylist = [
|
||||
('user', identity_fakes.user_id),
|
||||
('users', [identity_fakes.user_id]),
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user