From 53c5feaf6b4db22130e78ed948b372bbd1a9f0eb Mon Sep 17 00:00:00 2001 From: Jeff Bradberry Date: Wed, 1 May 2024 16:27:00 -0400 Subject: [PATCH] Set up Seth's bad role scenario --- tools/scripts/ig-hotfix/test.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tools/scripts/ig-hotfix/test.py diff --git a/tools/scripts/ig-hotfix/test.py b/tools/scripts/ig-hotfix/test.py new file mode 100644 index 0000000000..c4791314e6 --- /dev/null +++ b/tools/scripts/ig-hotfix/test.py @@ -0,0 +1,19 @@ +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("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))