mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
Make the role_chain.py script emit a Graphviz file
of the Role relationships.
This commit is contained in:
parent
85fc81aab1
commit
1f154742df
@ -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("}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user