summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJeff Bradberry <jeff.bradberry@gmail.com>2024-05-01 22:39:00 +0200
committerJeff Bradberry <jeff.bradberry@gmail.com>2024-06-10 22:36:22 +0200
commita8c07b06d86099a5a3825ce4d33630954af32e2a (patch)
tree535bb34a03c1938984bb1bd8ac04cbb0e624761d /tools
parentSet up Seth's bad role scenario (diff)
downloadawx-a8c07b06d86099a5a3825ce4d33630954af32e2a.tar.xz
awx-a8c07b06d86099a5a3825ce4d33630954af32e2a.zip
Set up an enhanced version of Seth's bad role scenario
Diffstat (limited to 'tools')
-rw-r--r--tools/scripts/ig-hotfix/test2.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/scripts/ig-hotfix/test2.py b/tools/scripts/ig-hotfix/test2.py
new file mode 100644
index 0000000000..66ec04d78a
--- /dev/null
+++ b/tools/scripts/ig-hotfix/test2.py
@@ -0,0 +1,20 @@
+from django.db import connection
+from awx.main.models import InstanceGroup
+
+InstanceGroup.objects.filter(name__in=('green', 'yellow', 'red')).delete()
+
+green = InstanceGroup.objects.create(name='green')
+red = InstanceGroup.objects.create(name='red')
+yellow = InstanceGroup.objects.create(name='yellow')
+
+for ig in InstanceGroup.objects.all():
+ print((ig.id, ig.name, ig.use_role_id))
+
+with connection.cursor() as cursor:
+ cursor.execute(f"UPDATE main_rbac_roles SET object_id = NULL WHERE id = {red.use_role_id}")
+ cursor.execute("UPDATE main_instancegroup SET use_role_id = NULL WHERE name = 'red'")
+ cursor.execute(f"UPDATE main_instancegroup SET use_role_id = {green.use_role_id} WHERE name = 'yellow'")
+
+print("=====================================")
+for ig in InstanceGroup.objects.all():
+ print((ig.id, ig.name, ig.use_role_id))