mirror of
https://github.com/ansible/awx.git
synced 2026-05-10 02:47:36 -02:30
Exit logic fixes for instance group tools
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# Copyright (c) 2017 Ansible Tower by Red Hat
|
# Copyright (c) 2017 Ansible Tower by Red Hat
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
import sys
|
||||||
|
|
||||||
from awx.main.models import Instance, InstanceGroup
|
from awx.main.models import Instance, InstanceGroup
|
||||||
|
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
@@ -19,10 +21,12 @@ class Command(BaseCommand):
|
|||||||
ig = InstanceGroup.objects.filter(name=options.get('queuename'))
|
ig = InstanceGroup.objects.filter(name=options.get('queuename'))
|
||||||
if not ig.exists():
|
if not ig.exists():
|
||||||
print("Queue doesn't exist")
|
print("Queue doesn't exist")
|
||||||
|
sys.exit(1)
|
||||||
ig = ig.first()
|
ig = ig.first()
|
||||||
i = Instance.objects.filter(name=options.get("hostname"))
|
i = Instance.objects.filter(name=options.get("hostname"))
|
||||||
if not i.exists():
|
if not i.exists():
|
||||||
print("Host doesn't exist")
|
print("Host doesn't exist")
|
||||||
|
sys.exit(1)
|
||||||
i = i.first()
|
i = i.first()
|
||||||
ig.instances.remove(i)
|
ig.instances.remove(i)
|
||||||
print("Instance removed from instance group")
|
print("Instance removed from instance group")
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Command(BaseCommand):
|
|||||||
make_option('--queuename', dest='queuename', type='string',
|
make_option('--queuename', dest='queuename', type='string',
|
||||||
help='Queue to create/update'),
|
help='Queue to create/update'),
|
||||||
make_option('--hostnames', dest='hostnames', type='string',
|
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):
|
def handle(self, **options):
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
# Copyright (c) 2017 Ansible Tower by Red Hat
|
# Copyright (c) 2017 Ansible Tower by Red Hat
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
import sys
|
||||||
|
|
||||||
from awx.main.models import InstanceGroup
|
from awx.main.models import InstanceGroup
|
||||||
|
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
@@ -17,7 +19,7 @@ class Command(BaseCommand):
|
|||||||
ig = InstanceGroup.objects.filter(name=options.get('queuename'))
|
ig = InstanceGroup.objects.filter(name=options.get('queuename'))
|
||||||
if not ig.exists():
|
if not ig.exists():
|
||||||
print("Instance group doesn't exist")
|
print("Instance group doesn't exist")
|
||||||
return
|
sys.exit(1)
|
||||||
ig = ig.first()
|
ig = ig.first()
|
||||||
ig.delete()
|
ig.delete()
|
||||||
print("Instance Group Removed")
|
print("Instance Group Removed")
|
||||||
|
|||||||
Reference in New Issue
Block a user