Merge "Add the ability to list projects based on a user"
This commit is contained in:
commit
cc54f989ec
@ -79,6 +79,7 @@ List projects
|
|||||||
|
|
||||||
os project list
|
os project list
|
||||||
[--domain <domain>]
|
[--domain <domain>]
|
||||||
|
[--user <user>]
|
||||||
[--long]
|
[--long]
|
||||||
|
|
||||||
.. option:: --domain <domain>
|
.. option:: --domain <domain>
|
||||||
@ -87,6 +88,12 @@ List projects
|
|||||||
|
|
||||||
.. versionadded:: 3
|
.. versionadded:: 3
|
||||||
|
|
||||||
|
.. option:: --user <user>
|
||||||
|
|
||||||
|
Filter projects by :option:`\<user\> <--user>` (name or ID)
|
||||||
|
|
||||||
|
.. versionadded:: 3
|
||||||
|
|
||||||
.. option:: --long
|
.. option:: --long
|
||||||
|
|
||||||
List additional fields in output
|
List additional fields in output
|
||||||
|
@ -162,6 +162,11 @@ class ListProject(lister.Lister):
|
|||||||
metavar='<domain>',
|
metavar='<domain>',
|
||||||
help='Filter projects by <domain> (name or ID)',
|
help='Filter projects by <domain> (name or ID)',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--user',
|
||||||
|
metavar='<user>',
|
||||||
|
help='Filter projects by <user> (name or ID)',
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--long',
|
'--long',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
@ -178,9 +183,24 @@ class ListProject(lister.Lister):
|
|||||||
else:
|
else:
|
||||||
columns = ('ID', 'Name')
|
columns = ('ID', 'Name')
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
|
||||||
|
domain_id = None
|
||||||
if parsed_args.domain:
|
if parsed_args.domain:
|
||||||
kwargs['domain'] = common.find_domain(identity_client,
|
domain_id = common.find_domain(identity_client,
|
||||||
parsed_args.domain).id
|
parsed_args.domain).id
|
||||||
|
kwargs['domain'] = domain_id
|
||||||
|
|
||||||
|
if parsed_args.user:
|
||||||
|
if parsed_args.domain:
|
||||||
|
user_id = utils.find_resource(identity_client.users,
|
||||||
|
parsed_args.user,
|
||||||
|
domain_id=domain_id).id
|
||||||
|
else:
|
||||||
|
user_id = utils.find_resource(identity_client.users,
|
||||||
|
parsed_args.user).id
|
||||||
|
|
||||||
|
kwargs['user'] = user_id
|
||||||
|
|
||||||
data = identity_client.projects.list(**kwargs)
|
data = identity_client.projects.list(**kwargs)
|
||||||
return (columns,
|
return (columns,
|
||||||
(utils.get_item_properties(
|
(utils.get_item_properties(
|
||||||
|
Loading…
Reference in New Issue
Block a user