forked from ansible/awx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add management command to remove address
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 <[email protected]>
- Loading branch information
1 parent
9c06370
commit 4c5ac1d
Showing
2 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 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") |