Register_peers support for receptor_addresses

register_peers has inputs:

source: source instance
peers: list of instances the source should peer to

InstanceLink "target" is now expected to be a ReceptorAddress

For each peer, we can just use the first receptor address. If
multiple receptor addresses exist, throw a command error.

Currently this command is only used on VM-deployments, where
there is only a single receptor address per instance, so this
should work fine.

Other changes:
drop listener_port field from Instance. Listener port is now just
"port" on ReceptorAddress

Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
Seth Foster
2023-11-02 14:08:13 -04:00
committed by Seth Foster
parent bca68bcdf1
commit 3a17c45b64
7 changed files with 48 additions and 39 deletions

View File

@@ -161,9 +161,6 @@ class InstanceManager(models.Manager):
if instance.node_type != node_type:
instance.node_type = node_type
update_fields.append('node_type')
if instance.listener_port != listener_port:
instance.listener_port = listener_port
update_fields.append('listener_port')
if update_fields:
instance.save(update_fields=update_fields)
return (True, instance)
@@ -183,10 +180,13 @@ class InstanceManager(models.Manager):
instance = self.create(
hostname=hostname,
ip_address=ip_address,
listener_port=listener_port,
node_type=node_type,
peers_from_control_nodes=peers_from_control_nodes,
**create_defaults,
**uuid_option
)
from awx.main.management.commands.add_receptor_address import add_address
if listener_port:
add_address(address=hostname, hostname=hostname, port=listener_port, protocol='tcp')
return (True, instance)