From 2c2e0d20a7d265b4f8e818677bce3e819234684f Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Thu, 11 May 2017 13:56:30 -0400 Subject: [PATCH] Exit logic fixes for instance group tools --- awx/main/management/commands/instance_group_remove.py | 4 ++++ awx/main/management/commands/register_queue.py | 2 +- awx/main/management/commands/unregister_queue.py | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/awx/main/management/commands/instance_group_remove.py b/awx/main/management/commands/instance_group_remove.py index 22c6f2815a..ca87cb8101 100644 --- a/awx/main/management/commands/instance_group_remove.py +++ b/awx/main/management/commands/instance_group_remove.py @@ -1,5 +1,7 @@ # Copyright (c) 2017 Ansible Tower by Red Hat # All Rights Reserved. +import sys + from awx.main.models import Instance, InstanceGroup from optparse import make_option @@ -19,10 +21,12 @@ class Command(BaseCommand): ig = InstanceGroup.objects.filter(name=options.get('queuename')) if not ig.exists(): print("Queue doesn't exist") + sys.exit(1) ig = ig.first() i = Instance.objects.filter(name=options.get("hostname")) if not i.exists(): print("Host doesn't exist") + sys.exit(1) i = i.first() ig.instances.remove(i) print("Instance removed from instance group") diff --git a/awx/main/management/commands/register_queue.py b/awx/main/management/commands/register_queue.py index f4d8149dd6..37df320cd3 100644 --- a/awx/main/management/commands/register_queue.py +++ b/awx/main/management/commands/register_queue.py @@ -14,7 +14,7 @@ class Command(BaseCommand): make_option('--queuename', dest='queuename', type='string', help='Queue to create/update'), make_option('--hostnames', dest='hostnames', type='string', - help='List of hosts to add to the queue'), + help='Comma-Delimited Hosts to add to the Queue'), ) def handle(self, **options): diff --git a/awx/main/management/commands/unregister_queue.py b/awx/main/management/commands/unregister_queue.py index 75499d5f94..827cee3dd6 100644 --- a/awx/main/management/commands/unregister_queue.py +++ b/awx/main/management/commands/unregister_queue.py @@ -1,5 +1,7 @@ # Copyright (c) 2017 Ansible Tower by Red Hat # All Rights Reserved. +import sys + from awx.main.models import InstanceGroup from optparse import make_option @@ -17,7 +19,7 @@ class Command(BaseCommand): ig = InstanceGroup.objects.filter(name=options.get('queuename')) if not ig.exists(): print("Instance group doesn't exist") - return + sys.exit(1) ig = ig.first() ig.delete() print("Instance Group Removed")