mirror of
https://github.com/ansible/awx.git
synced 2026-02-28 08:18:43 -03:30
Better error handling on deprovision_node management command
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (c) 2016 Ansible, Inc.
|
# Copyright (c) 2016 Ansible, Inc.
|
||||||
# All Rights Reserved
|
# All Rights Reserved
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
from awx.main.models import Instance
|
from awx.main.models import Instance
|
||||||
|
|
||||||
@@ -16,8 +16,9 @@ class Command(BaseCommand):
|
|||||||
help='Hostname used during provisioning'),
|
help='Hostname used during provisioning'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, *args, **options):
|
||||||
# Get the instance.
|
if not options.get('name'):
|
||||||
|
raise CommandError("--name is a required argument")
|
||||||
instance = Instance.objects.filter(hostname=options.get('name'))
|
instance = Instance.objects.filter(hostname=options.get('name'))
|
||||||
if instance.exists():
|
if instance.exists():
|
||||||
instance.delete()
|
instance.delete()
|
||||||
|
|||||||
Reference in New Issue
Block a user