Add HA support via openstack-api layer
This commit is contained in:
parent
cc4e04e0eb
commit
a33a95676e
|
@ -2,3 +2,5 @@ build
|
|||
layers
|
||||
.tox
|
||||
interfaces
|
||||
.testrepository
|
||||
*__pycache__*
|
||||
|
|
|
@ -10,9 +10,24 @@ AODH_DIR = '/etc/aodh'
|
|||
AODH_CONF = os.path.join(AODH_DIR, 'aodh.conf')
|
||||
|
||||
|
||||
class AodhCharm(charms_openstack.charm.OpenStackCharm):
|
||||
class AodhAdapters(charms_openstack.adapters.OpenStackRelationAdapters):
|
||||
"""
|
||||
Adapters class for the Aodh charm.
|
||||
"""
|
||||
def __init__(self, relations):
|
||||
print(relations)
|
||||
super(AodhAdapters, self).__init__(
|
||||
relations,
|
||||
options_instance=charms_openstack.adapters.APIConfigurationAdapter(
|
||||
port_map=AodhCharm.api_ports))
|
||||
|
||||
service_name = 'aodh'
|
||||
|
||||
class AodhCharm(charms_openstack.charm.HAOpenStackCharm):
|
||||
|
||||
# Internal name of charm + keystone endpoint
|
||||
service_name = name = 'aodh'
|
||||
|
||||
# First release supported
|
||||
release = 'mitaka'
|
||||
|
||||
# Packages the service needs installed
|
||||
|
@ -46,6 +61,9 @@ class AodhCharm(charms_openstack.charm.OpenStackCharm):
|
|||
AODH_CONF: services,
|
||||
}
|
||||
|
||||
# Resource when in HA mode
|
||||
ha_resources = ['vips', 'haproxy']
|
||||
|
||||
# Aodh requires a message queue, database and keystone to work,
|
||||
# so these are the 'required' relationships for the service to
|
||||
# have an 'active' workload status. 'required_relations' is used in
|
||||
|
@ -53,6 +71,10 @@ class AodhCharm(charms_openstack.charm.OpenStackCharm):
|
|||
# workload status of the charm is.
|
||||
required_relations = ['amqp', 'shared-db', 'identity-service']
|
||||
|
||||
# Set the adapters class to on specific to Aodh
|
||||
# NOTE: review this seems odd as not doing anything off piste here
|
||||
adapters_class = AodhAdapters
|
||||
|
||||
def __init__(self, release=None, **kwargs):
|
||||
"""Custom initialiser for class
|
||||
If no release is passed, then the charm determines the release from the
|
||||
|
@ -115,3 +137,9 @@ def assess_status():
|
|||
status on the unit.
|
||||
"""
|
||||
AodhCharm.singleton.assess_status()
|
||||
|
||||
|
||||
def configure_ha_resources(hacluster):
|
||||
"""Use the singleton from the AodhCharm to run configure_ha_resources
|
||||
"""
|
||||
AodhCharm.singleton.configure_ha_resources(hacluster)
|
||||
|
|
|
@ -6,6 +6,13 @@ import charmhelpers.core.hookenv as hookenv
|
|||
import charm.openstack.aodh as aodh
|
||||
|
||||
|
||||
MINIMAL_INTERFACES = [
|
||||
'shared-db.available',
|
||||
'identity-service.available',
|
||||
'amqp.available',
|
||||
]
|
||||
|
||||
|
||||
# use a synthetic state to ensure that it get it to be installed independent of
|
||||
# the install hook.
|
||||
@reactive.when_not('charm.installed')
|
||||
|
@ -39,15 +46,24 @@ def setup_endpoint(keystone):
|
|||
aodh.assess_status()
|
||||
|
||||
|
||||
@reactive.when('shared-db.available')
|
||||
@reactive.when('identity-service.available')
|
||||
@reactive.when('amqp.available')
|
||||
def render_stuff(*args):
|
||||
def render(*args):
|
||||
aodh.render_configs(args)
|
||||
reactive.set_state('config.complete')
|
||||
aodh.assess_status()
|
||||
|
||||
|
||||
@reactive.when_not('cluster.available')
|
||||
@reactive.when(*MINIMAL_INTERFACES)
|
||||
def render_unclustered(*args):
|
||||
render(*args)
|
||||
|
||||
|
||||
@reactive.when('cluster.available')
|
||||
@reactive.when(*MINIMAL_INTERFACES)
|
||||
def render_clustered(*args):
|
||||
render(*args)
|
||||
|
||||
|
||||
@reactive.when('config.complete')
|
||||
@reactive.when_not('db.synced')
|
||||
def run_db_migration():
|
||||
|
@ -55,3 +71,13 @@ def run_db_migration():
|
|||
aodh.restart_all()
|
||||
reactive.set_state('db.synced')
|
||||
aodh.assess_status()
|
||||
|
||||
|
||||
@reactive.when('ha.connected')
|
||||
def cluster_connected(hacluster):
|
||||
aodh.configure_ha_resources(hacluster)
|
||||
|
||||
|
||||
@reactive.hook('upgrade-charm')
|
||||
def upgrade_charm():
|
||||
aodh.install()
|
|
@ -1,13 +1,15 @@
|
|||
[DEFAULT]
|
||||
debug = {{ options.debug }}
|
||||
|
||||
[api]
|
||||
port = {{ options.service_listen_info.aodh_api.port }}
|
||||
|
||||
[database]
|
||||
{% if mongodb %}
|
||||
connection = mongodb://{{ mongodb.hostname }}:{{ mongodb.port }}/aodh
|
||||
{% endif -%}
|
||||
{% if shared_db.uri %}
|
||||
{% if shared_db.uri -%}
|
||||
connection = {{ shared_db.uri }}
|
||||
{% endif -%}
|
||||
{% elif mongodb -%}
|
||||
connection = mongodb://{{ mongodb.hostname }}:{{ mongodb.port }}/aodh
|
||||
{%- endif %}
|
||||
|
||||
[keystone_authtoken]
|
||||
{% if identity_service.auth_host -%}
|
||||
|
@ -18,7 +20,7 @@ auth_url = {{ identity_service.auth_protocol }}://{{ identity_service.auth_host
|
|||
project_name = {{ identity_service.service_tenant }}
|
||||
username = {{ identity_service.service_username }}
|
||||
password = {{ identity_service.service_password }}
|
||||
{% endif -%}
|
||||
{%- endif %}
|
||||
|
||||
[service_credentials]
|
||||
{% if identity_service.auth_host -%}
|
||||
|
@ -28,6 +30,6 @@ auth_url = {{ identity_service.auth_protocol }}://{{ identity_service.auth_host
|
|||
project_name = {{ identity_service.service_tenant }}
|
||||
username = {{ identity_service.service_username }}
|
||||
password = {{ identity_service.service_password }}
|
||||
{% endif -%}
|
||||
{%- endif %}
|
||||
|
||||
{% include "parts/section-rabbitmq-oslo" %}
|
||||
|
|
Loading…
Reference in New Issue