Ensure access-network address provided if required

When the shared-db relation is joined and the db application
has provided an access-network, ensure that the local address
we provide is within the access network cidr.

Closes-Bug: 1659805

Change-Id: Ib953b7586a13a05264d9edbfc39c877ae9ca5c70
This commit is contained in:
Liam Young 2017-09-11 10:47:39 +00:00 committed by James Page
parent 208b5ace07
commit acd7130048
1 changed files with 10 additions and 5 deletions

View File

@ -17,6 +17,7 @@ import subprocess
import charm.openstack.designate as designate
import charms.reactive as reactive
import charmhelpers.core.hookenv as hookenv
import charmhelpers.contrib.network.ip as ip
from charms_openstack.charm import provide_charm_instance
from charms_openstack.charm.utils import is_data_changed
@ -85,11 +86,15 @@ def setup_amqp_req(amqp):
@reactive.when_not('shared-db.setup')
def setup_database(database):
"""Send request designate accounts and dbs"""
database.configure('designate', 'designate',
prefix='designate')
database.configure('dpm', 'dpm',
prefix='dpm')
reactive.set_state('shared-db.setup')
hostname = None
if database.access_network():
hostname = ip.get_address_in_network(database.access_network())
database.configure('designate', 'designate', prefix='designate',
hostname=hostname)
database.configure('dpm', 'dpm', prefix='dpm',
hostname=hostname)
if database.base_data_complete():
reactive.set_state('shared-db.setup')
@reactive.when('identity-service.connected')