From 3f724963c2673c3687489750214c448e604e7937 Mon Sep 17 00:00:00 2001 From: James Page Date: Mon, 3 Oct 2016 12:05:28 +0100 Subject: [PATCH] Updates for OpenStack Newton Aodh switched to using wsgi_script to generate the aodh-api binary; this resulted in a few packaging changes, including one which means the listen port for Aodh API is set via the systemd unit, rather than the aodh.conf configuration file. Add systemd override file handling for aodh-api, including a small workaround which ensures that the systemd daemon loads the override configuration file when it changes. This charm should switch to using Apache + mod_wsgi next cycle, at which point all of that can just be dropped. Change-Id: I196bc52f8399183cf1aea9271f946a08af145044 Closes-Bug: 1629796 --- src/lib/charm/openstack/aodh.py | 18 +++++++++++++++--- src/reactive/aodh_handlers.py | 6 ++++++ src/templates/override.conf | 2 ++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/templates/override.conf diff --git a/src/lib/charm/openstack/aodh.py b/src/lib/charm/openstack/aodh.py index 24782a2..4cbd8b1 100644 --- a/src/lib/charm/openstack/aodh.py +++ b/src/lib/charm/openstack/aodh.py @@ -13,8 +13,10 @@ # limitations under the License. import os +import subprocess import charmhelpers.contrib.openstack.utils as ch_utils +import charmhelpers.core.host as ch_host import charms_openstack.charm import charms_openstack.adapters @@ -22,6 +24,9 @@ import charms_openstack.ip as os_ip AODH_DIR = '/etc/aodh' AODH_CONF = os.path.join(AODH_DIR, 'aodh.conf') +AODH_API_SYSTEMD_CONF = ( + '/etc/systemd/system/aodh-api.service.d/override.conf' +) class AodhAdapters(charms_openstack.adapters.OpenStackAPIRelationAdapters): @@ -56,9 +61,6 @@ class AodhCharm(charms_openstack.charm.HAOpenStackCharm): services = ['aodh-api', 'aodh-evaluator', 'aodh-notifier', 'aodh-listener'] - # Standard interface adapters class to use. - adapters_class = charms_openstack.adapters.OpenStackRelationAdapters - # Ports that need exposing. default_service = 'aodh-api' api_ports = { @@ -76,6 +78,7 @@ class AodhCharm(charms_openstack.charm.HAOpenStackCharm): # file changes restart_map = { AODH_CONF: services, + AODH_API_SYSTEMD_CONF: 'aodh-api', } # Resource when in HA mode @@ -166,3 +169,12 @@ def configure_ssl(): """Use the singleton from the AodhCharm to run configure_ssl """ AodhCharm.singleton.configure_ssl() + + +# TODO: drop once charm switches to apache+mod_wsgi +def reload_and_restart(): + """Reload systemd and restart aodh-api when override file changes + """ + if ch_host.init_is_systemd(): + subprocess.check_call(['systemctl', 'daemon-reload']) + ch_host.service_restart('aodh-api') diff --git a/src/reactive/aodh_handlers.py b/src/reactive/aodh_handlers.py index 15efba2..79dd739 100644 --- a/src/reactive/aodh_handlers.py +++ b/src/reactive/aodh_handlers.py @@ -100,3 +100,9 @@ def cluster_connected(hacluster): @reactive.hook('upgrade-charm') def upgrade_charm(): aodh.install() + + +# TODO: drop once charm switches to apache+mod_wsgi +@reactive.when_file_changed(aodh.AODH_API_SYSTEMD_CONF) +def systemd_override_changed(): + aodh.reload_and_restart() diff --git a/src/templates/override.conf b/src/templates/override.conf new file mode 100644 index 0000000..8bbf147 --- /dev/null +++ b/src/templates/override.conf @@ -0,0 +1,2 @@ +[Service] +Environment=PORT={{ options.service_listen_info.aodh_api.port }}