Merge "Fix module-list"
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Having the CLI command display non-redundant information
|
||||||
|
for module-list when invoked with admin privileges now
|
||||||
|
works with both keystone V2 and V3. Bug 1622019
|
@@ -246,6 +246,17 @@ def find_resource(manager, name_or_id):
|
|||||||
raise exceptions.CommandError(msg)
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
def is_admin(cs):
|
||||||
|
is_admin = False
|
||||||
|
try:
|
||||||
|
is_admin = 'admin' in cs.client.auth.auth_ref.role_names
|
||||||
|
except Exception:
|
||||||
|
print("Warning: Could not determine current role. Assuming non-admin")
|
||||||
|
pass
|
||||||
|
|
||||||
|
return is_admin
|
||||||
|
|
||||||
|
|
||||||
class HookableMixin(object):
|
class HookableMixin(object):
|
||||||
"""Mixin so classes can register and run hooks."""
|
"""Mixin so classes can register and run hooks."""
|
||||||
_hooks_map = {}
|
_hooks_map = {}
|
||||||
|
@@ -1748,19 +1748,7 @@ def do_module_list(cs, args):
|
|||||||
'datastore_version', 'auto_apply',
|
'datastore_version', 'auto_apply',
|
||||||
'priority_apply', 'apply_order', 'is_admin',
|
'priority_apply', 'apply_order', 'is_admin',
|
||||||
'tenant', 'visible']
|
'tenant', 'visible']
|
||||||
is_admin = False
|
if not utils.is_admin(cs):
|
||||||
try:
|
|
||||||
try:
|
|
||||||
roles = cs.client.auth.auth_ref['user']['roles']
|
|
||||||
except TypeError:
|
|
||||||
roles = cs.client.auth.auth_ref._data['access']['user']['roles']
|
|
||||||
role_names = [role['name'] for role in roles]
|
|
||||||
is_admin = 'admin' in role_names
|
|
||||||
except TypeError:
|
|
||||||
pass
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
if not is_admin:
|
|
||||||
field_list = field_list[:-2]
|
field_list = field_list[:-2]
|
||||||
utils.print_list(
|
utils.print_list(
|
||||||
module_list, field_list,
|
module_list, field_list,
|
||||||
|
Reference in New Issue
Block a user