Update peers with API addresses

Create a default_update_peers which all API charms can use to publish
their admin, internal and public addresses to their peers.

Change-Id: Iacfdc2a0247f35d0bddfef47c9dd5d4cf66cd309
Closes-Bug: #1858132
Depends-On: I1977e2c9625952eb22a63be0da0d6979c9f23072
This commit is contained in:
David Ames 2020-03-25 10:28:59 -07:00
parent 51753bb79f
commit 9d208bbe54
1 changed files with 13 additions and 0 deletions

View File

@ -49,3 +49,16 @@ def default_setup_endpoint_connection(keystone):
instance.internal_url,
instance.admin_url)
instance.assess_status()
@reactive.when('cluster.available')
def default_update_peers(cluster):
"""Inform peers about this unit's API addresses.
Set public-address, internal-address and admin-address on the
(openstack-ha) peer relation.
"""
with charm.provide_charm_instance() as instance:
# This function ONLY updates the peers if the data has changed. Thus
# it's okay to call it on every hook invocation.
instance.update_peers(cluster)