
We will add these further up the stack in ``layer-openstack``, addition counterpart: I12f45236632b608e07fdd35d31b90b84ca92eb1f Make some adjustments so the build job used solemnly for gate testing can pass again. Needed-By: I8a72acd451dd21e1b042b7f71f6d98e164737ac1 Depends-On: I12f45236632b608e07fdd35d31b90b84ca92eb1f Closes-Bug: #1840899 Change-Id: I007275c041ca5465664a6b5d441e56c0316c405d
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
import charms.reactive as reactive
|
|
|
|
import charms_openstack.charm as charm
|
|
|
|
|
|
@reactive.when('amqp.connected',
|
|
'charms.openstack.do-default-amqp.connected')
|
|
def default_amqp_connection(amqp):
|
|
"""Handle the default amqp connection.
|
|
|
|
This requires that the charm implements get_amqp_credentials() to
|
|
provide a tuple of the (user, vhost) for the amqp server
|
|
"""
|
|
with charm.provide_charm_instance() as instance:
|
|
user, vhost = instance.get_amqp_credentials()
|
|
amqp.request_access(username=user, vhost=vhost)
|
|
instance.assess_status()
|
|
|
|
|
|
@reactive.when('shared-db.connected',
|
|
'charms.openstack.do-default-shared-db.connected')
|
|
def default_setup_database(database):
|
|
"""Handle the default database connection setup
|
|
|
|
This requires that the charm implements get_database_setup() to provide
|
|
a list of dictionaries;
|
|
[{'database': ..., 'username': ..., 'hostname': ..., 'prefix': ...}]
|
|
|
|
The prefix can be missing: it defaults to None.
|
|
"""
|
|
with charm.provide_charm_instance() as instance:
|
|
for db in instance.get_database_setup():
|
|
database.configure(**db)
|
|
instance.assess_status()
|
|
|
|
|
|
@reactive.when('identity-service.connected',
|
|
'charms.openstack.do-default-identity-service.connected')
|
|
def default_setup_endpoint_connection(keystone):
|
|
"""When the keystone interface connects, register this unit into the
|
|
catalog. This is the default handler, and calls on the charm class to
|
|
provide the endpoint information. If multiple endpoints are needed,
|
|
then a custom endpoint handler will be needed.
|
|
"""
|
|
with charm.provide_charm_instance() as instance:
|
|
keystone.register_endpoints(instance.service_type,
|
|
instance.region,
|
|
instance.public_url,
|
|
instance.internal_url,
|
|
instance.admin_url)
|
|
instance.assess_status()
|