Merge lp:~saviq/charms/trusty/openstack-dashboard/simplify-settings into lp:~openstack-charmers-archive/charms/trusty/openstack-dashboard/next

Proposed by Michał Sawicz
Status: Merged
Merged at revision: 85
Proposed branch: lp:~saviq/charms/trusty/openstack-dashboard/simplify-settings
Merge into: lp:~openstack-charmers-archive/charms/trusty/openstack-dashboard/next
Diff against target: 173 lines (+68/-1)
11 files modified
hooks/horizon_contexts.py (+25/-0)
hooks/horizon_hooks.py (+11/-0)
hooks/horizon_utils.py (+2/-1)
metadata.yaml (+3/-0)
templates/essex/local_settings.py (+2/-0)
templates/folsom/local_settings.py (+2/-0)
templates/grizzly/local_settings.py (+2/-0)
templates/havana/local_settings.py (+2/-0)
templates/icehouse/local_settings.py (+2/-0)
templates/juno/local_settings.py (+2/-0)
unit_tests/test_horizon_contexts.py (+15/-0)
To merge this branch: bzr merge lp:~saviq/charms/trusty/openstack-dashboard/simplify-settings
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+269342@code.launchpad.net

Commit message

Add support for plugins to inject settings into local_settings.py

Description of the change

To post a comment you must log in.
82. By Michał Sawicz

Undo test changes

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #8821 openstack-dashboard-next for saviq mp269342
    LINT FAIL: lint-test failed

LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.

Full lint test output: http://paste.ubuntu.com/12205247/
Build: http://10.245.162.77:8080/job/charm_lint_check/8821/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #8150 openstack-dashboard-next for saviq mp269342
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/8150/

83. By Michał Sawicz

Drop empty line

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #6055 openstack-dashboard-next for saviq mp269342
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12205449/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6055/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #8823 openstack-dashboard-next for saviq mp269342
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/8823/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #8151 openstack-dashboard-next for saviq mp269342
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/8151/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #6057 openstack-dashboard-next for saviq mp269342
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12205820/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6057/

84. By Michał Sawicz

Merge next

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #8826 openstack-dashboard-next for saviq mp269342
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/8826/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #8154 openstack-dashboard-next for saviq mp269342
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/8154/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #6060 openstack-dashboard-next for saviq mp269342
    AMULET FAIL: amulet-test failed

AMULET Results (max last 2 lines):
make: *** [test] Error 1
ERROR:root:Make target returned non-zero.

Full amulet test output: http://paste.ubuntu.com/12206789/
Build: http://10.245.162.77:8080/job/charm_amulet_test/6060/

Revision history for this message
Liam Young (gnuoy) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/horizon_contexts.py'
2--- hooks/horizon_contexts.py 2015-04-09 14:56:00 +0000
3+++ hooks/horizon_contexts.py 2015-08-27 15:02:42 +0000
4@@ -172,3 +172,28 @@
5 'disable_router': False if config('profile') in ['cisco'] else True
6 }
7 return ctxt
8+
9+
10+class LocalSettingsContext(OSContextGenerator):
11+ def __call__(self):
12+ ''' Additional config stanzas to be appended to local_settings.py '''
13+
14+ relations = []
15+
16+ for rid in relation_ids("plugin"):
17+ try:
18+ unit = related_units(rid)[0]
19+ except IndexError:
20+ pass
21+ else:
22+ rdata = relation_get(unit=unit, rid=rid)
23+ if set(('local-settings', 'priority')) <= set(rdata.keys()):
24+ relations.append((unit, rdata))
25+
26+ ctxt = {
27+ 'settings': [
28+ '# {0}\n{1}'.format(u, rd['local-settings'])
29+ for u, rd in sorted(relations,
30+ key=lambda r: r[1]['priority'])]
31+ }
32+ return ctxt
33
34=== modified file 'hooks/horizon_hooks.py'
35--- hooks/horizon_hooks.py 2015-05-07 14:33:05 +0000
36+++ hooks/horizon_hooks.py 2015-08-27 15:02:42 +0000
37@@ -244,6 +244,17 @@
38 nrpe_setup.write()
39
40
41+@hooks.hook('plugin-relation-joined')
42+def plugin_relation_joined():
43+ relation_set(release=os_release("openstack-dashboard"))
44+
45+
46+@hooks.hook('plugin-relation-changed')
47+@restart_on_change(restart_map())
48+def update_plugin_config():
49+ CONFIGS.write(LOCAL_SETTINGS)
50+
51+
52 def main():
53 try:
54 hooks.execute(sys.argv)
55
56=== modified file 'hooks/horizon_utils.py'
57--- hooks/horizon_utils.py 2015-07-15 18:46:45 +0000
58+++ hooks/horizon_utils.py 2015-08-27 15:02:42 +0000
59@@ -100,7 +100,8 @@
60 (LOCAL_SETTINGS, {
61 'hook_contexts': [horizon_contexts.HorizonContext(),
62 horizon_contexts.IdentityServiceContext(),
63- context.SyslogContext()],
64+ context.SyslogContext(),
65+ horizon_contexts.LocalSettingsContext()],
66 'services': ['apache2']
67 }),
68 (APACHE_CONF, {
69
70=== added symlink 'hooks/plugin-relation-changed'
71=== target is u'horizon_hooks.py'
72=== added symlink 'hooks/plugin-relation-joined'
73=== target is u'horizon_hooks.py'
74=== modified file 'metadata.yaml'
75--- metadata.yaml 2014-10-30 03:30:36 +0000
76+++ metadata.yaml 2015-08-27 15:02:42 +0000
77@@ -17,6 +17,9 @@
78 ha:
79 interface: hacluster
80 scope: container
81+ plugin:
82+ interface: horizon-plugin
83+ scope: container
84 peers:
85 cluster:
86 interface: openstack-dashboard-ha
87
88=== modified file 'templates/essex/local_settings.py'
89--- templates/essex/local_settings.py 2014-02-27 10:07:57 +0000
90+++ templates/essex/local_settings.py 2015-08-27 15:02:42 +0000
91@@ -118,3 +118,5 @@
92 }
93 }
94 }
95+
96+{{ settings|join('\n\n') }}
97
98=== modified file 'templates/folsom/local_settings.py'
99--- templates/folsom/local_settings.py 2014-05-28 16:05:37 +0000
100+++ templates/folsom/local_settings.py 2015-08-27 15:02:42 +0000
101@@ -167,3 +167,5 @@
102 # offline compression by default. To enable online compression, install
103 # the node-less package and enable the following option.
104 COMPRESS_OFFLINE = {{ compress_offline }}
105+
106+{{ settings|join('\n\n') }}
107\ No newline at end of file
108
109=== modified file 'templates/grizzly/local_settings.py'
110--- templates/grizzly/local_settings.py 2014-05-28 16:05:37 +0000
111+++ templates/grizzly/local_settings.py 2015-08-27 15:02:42 +0000
112@@ -263,3 +263,5 @@
113 }
114 }
115 }
116+
117+{{ settings|join('\n\n') }}
118
119=== modified file 'templates/havana/local_settings.py'
120--- templates/havana/local_settings.py 2014-07-22 07:18:55 +0000
121+++ templates/havana/local_settings.py 2015-08-27 15:02:42 +0000
122@@ -483,3 +483,5 @@
123 # installations should have this set accordingly. For more information
124 # see https://docs.djangoproject.com/en/dev/ref/settings/.
125 ALLOWED_HOSTS = '*'
126+
127+{{ settings|join('\n\n') }}
128\ No newline at end of file
129
130=== modified file 'templates/icehouse/local_settings.py'
131--- templates/icehouse/local_settings.py 2014-12-01 23:45:41 +0000
132+++ templates/icehouse/local_settings.py 2015-08-27 15:02:42 +0000
133@@ -514,3 +514,5 @@
134 # installations should have this set accordingly. For more information
135 # see https://docs.djangoproject.com/en/dev/ref/settings/.
136 ALLOWED_HOSTS = '*'
137+
138+{{ settings|join('\n\n') }}
139\ No newline at end of file
140
141=== modified file 'templates/juno/local_settings.py'
142--- templates/juno/local_settings.py 2014-12-01 23:45:41 +0000
143+++ templates/juno/local_settings.py 2015-08-27 15:02:42 +0000
144@@ -619,3 +619,5 @@
145 # installations should have this set accordingly. For more information
146 # see https://docs.djangoproject.com/en/dev/ref/settings/.
147 ALLOWED_HOSTS = '*'
148+
149+{{ settings|join('\n\n') }}
150\ No newline at end of file
151
152=== modified file 'unit_tests/test_horizon_contexts.py'
153--- unit_tests/test_horizon_contexts.py 2015-04-09 14:34:44 +0000
154+++ unit_tests/test_horizon_contexts.py 2015-08-27 15:02:42 +0000
155@@ -251,3 +251,18 @@
156 self.test_config.set('profile', None)
157 self.assertEquals(horizon_contexts.RouterSettingContext()(),
158 {'disable_router': True, })
159+
160+ def test_LocalSettingsContext(self):
161+ self.relation_ids.return_value = ['plugin:0', 'plugin-too:0']
162+ self.related_units.side_effect = [['horizon-plugin/0'],
163+ ['horizon-plugin-too/0']]
164+ self.relation_get.side_effect = [{'priority': 99,
165+ 'local-settings': 'FOO = True'},
166+ {'priority': 60,
167+ 'local-settings': 'BAR = False'}]
168+
169+ self.assertEquals(horizon_contexts.LocalSettingsContext()(),
170+ {'settings': ['# horizon-plugin-too/0\n'
171+ 'BAR = False',
172+ '# horizon-plugin/0\n'
173+ 'FOO = True']})

Subscribers

People subscribed via source and target branches