Add filtering by user for 'openstack server list'
Add a new option to search by user when listing servers, include support for domain scoped users, also update docs Co-Authored-By: Steve Martinelli <stevemar@ca.ibm.com> Closes-Bug: #1483974 Change-Id: Ifdade6dc9ca8400fbd85f6b55793ab15ed17b97d
This commit is contained in:
parent
66010b41f1
commit
10db0df857
@ -237,6 +237,15 @@ List servers
|
||||
Domain the project belongs to (name or ID).
|
||||
This can be used in case collisions between project names exist.
|
||||
|
||||
.. option:: --user <user>
|
||||
|
||||
Search by user (admin only) (name or ID)
|
||||
|
||||
.. option:: --user-domain <user-domain>
|
||||
|
||||
Domain the user belongs to (name or ID).
|
||||
This can be used in case collisions between user names exist.
|
||||
|
||||
.. option:: --long
|
||||
|
||||
List additional fields in output
|
||||
|
@ -699,6 +699,12 @@ class ListServer(lister.Lister):
|
||||
metavar='<project>',
|
||||
help="Search by project (admin only) (name or ID)")
|
||||
identity_common.add_project_domain_option_to_parser(parser)
|
||||
parser.add_argument(
|
||||
'--user',
|
||||
metavar='<user>',
|
||||
help=_('Search by user (admin only) (name or ID)'),
|
||||
)
|
||||
identity_common.add_user_domain_option_to_parser(parser)
|
||||
parser.add_argument(
|
||||
'--long',
|
||||
action='store_true',
|
||||
@ -710,10 +716,10 @@ class ListServer(lister.Lister):
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug('take_action(%s)', parsed_args)
|
||||
compute_client = self.app.client_manager.compute
|
||||
identity_client = self.app.client_manager.identity
|
||||
|
||||
project_id = None
|
||||
if parsed_args.project:
|
||||
identity_client = self.app.client_manager.identity
|
||||
project_id = identity_common.find_project(
|
||||
identity_client,
|
||||
parsed_args.project,
|
||||
@ -721,6 +727,14 @@ class ListServer(lister.Lister):
|
||||
).id
|
||||
parsed_args.all_projects = True
|
||||
|
||||
user_id = None
|
||||
if parsed_args.user:
|
||||
user_id = identity_common.find_project(
|
||||
identity_client,
|
||||
parsed_args.user,
|
||||
parsed_args.user_domain,
|
||||
).id
|
||||
|
||||
search_opts = {
|
||||
'reservation_id': parsed_args.reservation_id,
|
||||
'ip': parsed_args.ip,
|
||||
@ -733,6 +747,7 @@ class ListServer(lister.Lister):
|
||||
'host': parsed_args.host,
|
||||
'tenant_id': project_id,
|
||||
'all_tenants': parsed_args.all_projects,
|
||||
'user_id': user_id,
|
||||
}
|
||||
self.log.debug('search options: %s', search_opts)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user