From 2d6dff1a3bec96b7cad4d6b4be2c14db274748e9 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Mon, 12 Dec 2016 10:54:00 -0500 Subject: [PATCH] Better error handling on deprovision_node management command --- awx/main/management/commands/deprovision_node.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/awx/main/management/commands/deprovision_node.py b/awx/main/management/commands/deprovision_node.py index 52b9e4f115..251816703e 100644 --- a/awx/main/management/commands/deprovision_node.py +++ b/awx/main/management/commands/deprovision_node.py @@ -1,7 +1,7 @@ # Copyright (c) 2016 Ansible, Inc. # All Rights Reserved -from django.core.management.base import BaseCommand +from django.core.management.base import BaseCommand, CommandError from optparse import make_option from awx.main.models import Instance @@ -16,8 +16,9 @@ class Command(BaseCommand): help='Hostname used during provisioning'), ) - def handle(self, **options): - # Get the instance. + def handle(self, *args, **options): + if not options.get('name'): + raise CommandError("--name is a required argument") instance = Instance.objects.filter(hostname=options.get('name')) if instance.exists(): instance.delete()