mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
register_peers will now raise errors if you attempt to reverse or loop
This commit is contained in:
parent
5ffe91f069
commit
9c9c1b4d3b
@ -35,6 +35,18 @@ class Command(BaseCommand):
|
||||
if options['exact'] and options['disconnect']:
|
||||
raise CommandError("The option --disconnect may not be used with --exact.")
|
||||
|
||||
# No 1-cycles
|
||||
for collection in ('peers', 'disconnect', 'exact'):
|
||||
if options['source'] in options[collection]:
|
||||
raise CommandError(f"Source node {options['source']} may not also be in --{collection}.")
|
||||
|
||||
# No 2-cycles
|
||||
if options['peers'] or options['exact']:
|
||||
peers = set(options['peers'] or options['exact'])
|
||||
incoming = set(InstanceLink.objects.filter(target=nodes[options['source']]).values_list('source__hostname', flat=True))
|
||||
if peers & incoming:
|
||||
raise CommandError(f"Source node {options['source']} cannot link to nodes already peering to it: {peers & incoming}.")
|
||||
|
||||
if options['peers']:
|
||||
missing_peers = set(options['peers']) - set(nodes)
|
||||
if missing_peers:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user