mirror of
https://github.com/ansible/awx.git
synced 2026-07-29 08:59:55 -02:30
Adds remove_receptor_address to delete a receptor address from the database Also, enforce that only 1 canonical address can be added to an instance via the add_receptor_address command. Signed-off-by: Seth Foster <fosterbseth@gmail.com>
27 lines
783 B
Python
27 lines
783 B
Python
# Copyright (c) 2015 Ansible, Inc.
|
|
# All Rights Reserved
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from awx.main.models import ReceptorAddress
|
|
|
|
|
|
class Command(BaseCommand):
|
|
"""
|
|
Internal controller command.
|
|
Delete a receptor address.
|
|
"""
|
|
|
|
help = "Add receptor address to an instance."
|
|
|
|
def add_arguments(self, parser):
|
|
parser.add_argument('--address', dest='address', type=str, help="Receptor address to remove")
|
|
|
|
def handle(self, **options):
|
|
deleted = ReceptorAddress.objects.filter(address=options['address']).delete()
|
|
if deleted[0]:
|
|
print(f"Successfully removed {options['address']}")
|
|
print("(changed: True)")
|
|
else:
|
|
print(f"Did not remove {options['address']}, not found")
|