From aeee6db868d0f76998b8fbdfea93e7598e1604ef Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Thu, 9 Feb 2017 13:36:41 -0500 Subject: [PATCH] Trigger rabbitmq cluster node removal from deprovisioning --- awx/main/management/commands/deprovision_node.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/awx/main/management/commands/deprovision_node.py b/awx/main/management/commands/deprovision_node.py index 251816703e..8412b5bd86 100644 --- a/awx/main/management/commands/deprovision_node.py +++ b/awx/main/management/commands/deprovision_node.py @@ -1,6 +1,7 @@ # Copyright (c) 2016 Ansible, Inc. # All Rights Reserved +import subprocess from django.core.management.base import BaseCommand, CommandError from optparse import make_option from awx.main.models import Instance @@ -22,7 +23,11 @@ class Command(BaseCommand): instance = Instance.objects.filter(hostname=options.get('name')) if instance.exists(): instance.delete() - print('Successfully removed') + result = subprocess.Popen("rabbitmqctl forget_cluster_node rabbitmq@{}".format(options.get('name')), shell=True).wait() + if result != 0: + print("Node deprovisioning may have failed when attempting to remove the RabbitMQ instance from the cluster") + else: + print('Successfully deprovisioned {}'.format(options.get('name'))) else: print('No instance found matching name {}'.format(options.get('name')))