Merge "Add filtering by user for 'openstack server list'"
This commit is contained in:
commit
fa4b11a86f
@ -237,6 +237,15 @@ List servers
|
|||||||
Domain the project belongs to (name or ID).
|
Domain the project belongs to (name or ID).
|
||||||
This can be used in case collisions between project names exist.
|
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
|
.. option:: --long
|
||||||
|
|
||||||
List additional fields in output
|
List additional fields in output
|
||||||
|
@ -705,6 +705,12 @@ class ListServer(lister.Lister):
|
|||||||
metavar='<project>',
|
metavar='<project>',
|
||||||
help="Search by project (admin only) (name or ID)")
|
help="Search by project (admin only) (name or ID)")
|
||||||
identity_common.add_project_domain_option_to_parser(parser)
|
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(
|
parser.add_argument(
|
||||||
'--long',
|
'--long',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
@ -716,10 +722,10 @@ class ListServer(lister.Lister):
|
|||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
self.log.debug('take_action(%s)', parsed_args)
|
self.log.debug('take_action(%s)', parsed_args)
|
||||||
compute_client = self.app.client_manager.compute
|
compute_client = self.app.client_manager.compute
|
||||||
|
identity_client = self.app.client_manager.identity
|
||||||
|
|
||||||
project_id = None
|
project_id = None
|
||||||
if parsed_args.project:
|
if parsed_args.project:
|
||||||
identity_client = self.app.client_manager.identity
|
|
||||||
project_id = identity_common.find_project(
|
project_id = identity_common.find_project(
|
||||||
identity_client,
|
identity_client,
|
||||||
parsed_args.project,
|
parsed_args.project,
|
||||||
@ -727,6 +733,14 @@ class ListServer(lister.Lister):
|
|||||||
).id
|
).id
|
||||||
parsed_args.all_projects = True
|
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 = {
|
search_opts = {
|
||||||
'reservation_id': parsed_args.reservation_id,
|
'reservation_id': parsed_args.reservation_id,
|
||||||
'ip': parsed_args.ip,
|
'ip': parsed_args.ip,
|
||||||
@ -739,6 +753,7 @@ class ListServer(lister.Lister):
|
|||||||
'host': parsed_args.host,
|
'host': parsed_args.host,
|
||||||
'tenant_id': project_id,
|
'tenant_id': project_id,
|
||||||
'all_tenants': parsed_args.all_projects,
|
'all_tenants': parsed_args.all_projects,
|
||||||
|
'user_id': user_id,
|
||||||
}
|
}
|
||||||
self.log.debug('search options: %s', search_opts)
|
self.log.debug('search options: %s', search_opts)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user