Add facilities for subordinate charms to affect dashboard settings

This commit is contained in:
Michał Sawicz 2015-05-28 11:45:22 +02:00
parent 8da609078c
commit 4e2835cc9f
12 changed files with 49 additions and 1 deletions

View File

@ -172,3 +172,22 @@ class RouterSettingContext(OSContextGenerator):
'disable_router': False if config('profile') in ['cisco'] else True
}
return ctxt
class LocalSettingsContext(OSContextGenerator):
def __call__(self):
''' Additional config stanzas to be appended to local_settings.py '''
settings = []
for rid in relation_ids("settings"):
for unit in related_units(rid):
rdata = relation_get(unit=unit, rid=rid)
if 'setting' in rdata:
settings.append('# {0}/{1}\n{2}'.format(
rid, unit, rdata['setting'])
)
ctxt = {
'settings': settings
}
return ctxt

View File

@ -244,6 +244,17 @@ def update_nrpe_config():
nrpe_setup.write()
@hooks.hook('settings-relation-joined')
def settings_relation_joined():
relation_set(release=os_release("openstack-dashboard"))
@hooks.hook('settings-relation-changed')
@restart_on_change(restart_map())
def update_plugin_config():
CONFIGS.write(LOCAL_SETTINGS)
def main():
try:
hooks.execute(sys.argv)

View File

@ -89,7 +89,8 @@ CONFIG_FILES = OrderedDict([
(LOCAL_SETTINGS, {
'hook_contexts': [horizon_contexts.HorizonContext(),
horizon_contexts.IdentityServiceContext(),
context.SyslogContext()],
context.SyslogContext(),
horizon_contexts.LocalSettingsContext()],
'services': ['apache2']
}),
(APACHE_CONF, {

View File

@ -0,0 +1 @@
horizon_hooks.py

View File

@ -0,0 +1 @@
horizon_hooks.py

View File

@ -17,6 +17,9 @@ requires:
ha:
interface: hacluster
scope: container
settings:
interface: openstack-dashboard-settings
scope: container
peers:
cluster:
interface: openstack-dashboard-ha

View File

@ -118,3 +118,5 @@ LOGGING = {
}
}
}
{{ settings|join('\n\n') }}

View File

@ -167,3 +167,5 @@ LOGIN_REDIRECT_URL='{{ webroot }}'
# offline compression by default. To enable online compression, install
# the node-less package and enable the following option.
COMPRESS_OFFLINE = {{ compress_offline }}
{{ settings|join('\n\n') }}

View File

@ -263,3 +263,5 @@ LOGGING = {
}
}
}
{{ settings|join('\n\n') }}

View File

@ -483,3 +483,5 @@ COMPRESS_OFFLINE = {{ compress_offline }}
# installations should have this set accordingly. For more information
# see https://docs.djangoproject.com/en/dev/ref/settings/.
ALLOWED_HOSTS = '*'
{{ settings|join('\n\n') }}

View File

@ -514,3 +514,5 @@ COMPRESS_OFFLINE = {{ compress_offline }}
# installations should have this set accordingly. For more information
# see https://docs.djangoproject.com/en/dev/ref/settings/.
ALLOWED_HOSTS = '*'
{{ settings|join('\n\n') }}

View File

@ -619,3 +619,5 @@ LOGIN_REDIRECT_URL='{{ webroot }}'
# installations should have this set accordingly. For more information
# see https://docs.djangoproject.com/en/dev/ref/settings/.
ALLOWED_HOSTS = '*'
{{ settings|join('\n\n') }}