diff options
author | Jeff Bradberry <jeff.bradberry@gmail.com> | 2024-05-08 16:39:26 +0200 |
---|---|---|
committer | Jeff Bradberry <jeff.bradberry@gmail.com> | 2024-06-10 22:36:22 +0200 |
commit | 6a317cca1b222b287bab6f9a1471964f471e5c60 (patch) | |
tree | 3359c9fa76c995d52d211c9bf54f3fc88c3cb0eb /tools | |
parent | Attempt to correct any crosslinked parents (diff) | |
download | awx-6a317cca1b222b287bab6f9a1471964f471e5c60.tar.xz awx-6a317cca1b222b287bab6f9a1471964f471e5c60.zip |
Remove the role_chain.py module
it wound up being unworkable, and I think ultimately we only need to
check the immediate parentage of each role.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/scripts/ig-hotfix/role_chain.py | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/tools/scripts/ig-hotfix/role_chain.py b/tools/scripts/ig-hotfix/role_chain.py deleted file mode 100644 index 01171ca534..0000000000 --- a/tools/scripts/ig-hotfix/role_chain.py +++ /dev/null @@ -1,54 +0,0 @@ -from collections import defaultdict -import os -import sys - -from django.contrib.contenttypes.models import ContentType - -from awx.main.fields import ImplicitRoleField -from awx.main.models.rbac import Role - - -role_id = int(os.environ.get('role')) -role = Role.objects.get(id=role_id) - -all_roles = {role,} -graph = defaultdict(set) - - -# Role parents -new_parents = {role,} -while new_parents: - old_parents = new_parents - new_parents = set() - for r in old_parents: - new_parents |= (set(r.parents.all()) - all_roles) - for p in r.parents.all(): - graph[p.id].add(r.id) - all_roles |= new_parents - -# Role children -new_children = {role,} -while new_children: - old_children = new_children - new_children = set() - for r in old_children: - new_children |= (set(r.children.all()) - all_roles) - for c in r.children.all(): - graph[r.id].add(c.id) - all_roles |= new_children - - -print("digraph G {") - -for r in sorted(all_roles, key=lambda x: x.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"]') - -print() -for p_id, children in sorted(graph.items()): - for c_id in children: - print(f" {p_id} -> {c_id}") - -print("}") |