diff options
author | Jeff Bradberry <jeff.bradberry@gmail.com> | 2024-05-03 21:43:48 +0200 |
---|---|---|
committer | Jeff Bradberry <jeff.bradberry@gmail.com> | 2024-06-10 22:36:22 +0200 |
commit | 1f154742df2dc808222a3cadda3471a0beb43133 (patch) | |
tree | 225a7749a62a625e7d14e227bcf4dc416c559dd6 /tools | |
parent | Start a new script that can be used to examine a Role's ancestry (diff) | |
download | awx-1f154742df2dc808222a3cadda3471a0beb43133.tar.xz awx-1f154742df2dc808222a3cadda3471a0beb43133.zip |
Make the role_chain.py script emit a Graphviz file
of the Role relationships.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/scripts/ig-hotfix/role_chain.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/scripts/ig-hotfix/role_chain.py b/tools/scripts/ig-hotfix/role_chain.py index 4b8b7b6918..e64f47dfc6 100644 --- a/tools/scripts/ig-hotfix/role_chain.py +++ b/tools/scripts/ig-hotfix/role_chain.py @@ -1,5 +1,4 @@ from collections import defaultdict -import os import sys from django.contrib.contenttypes.models import ContentType @@ -8,7 +7,16 @@ from awx.main.fields import ImplicitRoleField from awx.main.models.rbac import Role -r_id = int(os.environ.get('role')) -r = Role.objects.get(id=r_id) +print("digraph G {") -print(r) +for r in Role.objects.order_by('id'): + if r.content_type is None: + print(f' {r.id} [shape=box,label="id={r.id}\lsingleton={r.singleton_name}\l"]') + else: + print(f' {r.id} [shape=box,label="id={r.id}\lct={r.content_type}\lobject_id={r.object_id}\lrole_field={r.role_field}\l"]') + +for r in Role.objects.order_by('id'): + for p in r.parents.all(): + print(f" {p.id} -> {r.id}") + +print("}") |