mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
Make the role_chain.py script emit a Graphviz file
of the Role relationships.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import os
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from django.contrib.contenttypes.models import ContentType
|
from django.contrib.contenttypes.models import ContentType
|
||||||
@@ -8,7 +7,16 @@ from awx.main.fields import ImplicitRoleField
|
|||||||
from awx.main.models.rbac import Role
|
from awx.main.models.rbac import Role
|
||||||
|
|
||||||
|
|
||||||
r_id = int(os.environ.get('role'))
|
print("digraph G {")
|
||||||
r = Role.objects.get(id=r_id)
|
|
||||||
|
|
||||||
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("}")
|
||||||
|
|||||||
Reference in New Issue
Block a user