mirror of
https://github.com/ansible/awx.git
synced 2026-01-21 06:28:01 -03:30
Exit logic fixes for instance group tools
This commit is contained in:
parent
47f4e5358b
commit
2c2e0d20a7
@ -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")
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user