Merge lp:~bac/charms/trusty/openstack-dashboard/apache-slugs into lp:~yellow/charms/trusty/openstack-dashboard/dashboard-plugin
- Trusty Tahr (14.04)
- apache-slugs
- Merge into dashboard-plugin
Proposed by
Brad Crittenden
Status: | Merged |
---|---|
Merged at revision: | 86 |
Proposed branch: | lp:~bac/charms/trusty/openstack-dashboard/apache-slugs |
Merge into: | lp:~yellow/charms/trusty/openstack-dashboard/dashboard-plugin |
Diff against target: |
777 lines (+356/-24) 23 files modified
Makefile (+1/-2) actions.yaml (+2/-0) actions/openstack_upgrade.py (+34/-0) config.yaml (+31/-2) hooks/charmhelpers/contrib/openstack/utils.py (+48/-0) hooks/horizon_contexts.py (+68/-2) hooks/horizon_hooks.py (+11/-4) hooks/horizon_utils.py (+8/-7) hooks/install (+20/-0) metadata.yaml (+1/-0) templates/default (+2/-0) templates/default-ssl (+2/-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 (+8/-0) templates/juno/local_settings.py (+8/-0) tests/00-setup (+1/-0) tests/tests.yaml (+1/-1) unit_tests/test_actions_openstack_upgrade.py (+53/-0) unit_tests/test_horizon_contexts.py (+39/-3) unit_tests/test_horizon_hooks.py (+10/-3) |
To merge this branch: | bzr merge lp:~bac/charms/trusty/openstack-dashboard/apache-slugs |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jay R. Wren (community) | Approve | ||
j.c.sackett (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
Allow the ability to add controls to the end http and https configurations. Useful for things like rewrite stanzas.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Brad Crittenden (bac) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
j.c.sackett (jcsackett) wrote : | # |
LGTM, thanks Brad.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Makefile' | |||
2 | --- Makefile 2015-08-22 04:13:34 +0000 | |||
3 | +++ Makefile 2015-10-14 14:39:53 +0000 | |||
4 | @@ -9,11 +9,10 @@ | |||
5 | 9 | test: | 9 | test: |
6 | 10 | @# Bundletester expects unit tests here. | 10 | @# Bundletester expects unit tests here. |
7 | 11 | @echo Starting tests... | 11 | @echo Starting tests... |
9 | 12 | @$(PYTHON) /usr/bin/nosetests --nologcapture --with-coverage unit_tests | 12 | @$(PYTHON) /usr/bin/nosetests -v --nologcapture --with-coverage unit_tests |
10 | 13 | 13 | ||
11 | 14 | functional_test: | 14 | functional_test: |
12 | 15 | @echo Starting Amulet tests... | 15 | @echo Starting Amulet tests... |
13 | 16 | # https://bugs.launchpad.net/amulet/+bug/1320357 | ||
14 | 17 | @juju test -v -p AMULET_HTTP_PROXY,AMULET_OS_VIP --timeout 2700 | 16 | @juju test -v -p AMULET_HTTP_PROXY,AMULET_OS_VIP --timeout 2700 |
15 | 18 | 17 | ||
16 | 19 | bin/charm_helpers_sync.py: | 18 | bin/charm_helpers_sync.py: |
17 | 20 | 19 | ||
18 | === modified file 'actions.yaml' | |||
19 | --- actions.yaml 2015-04-07 13:58:41 +0000 | |||
20 | +++ actions.yaml 2015-10-14 14:39:53 +0000 | |||
21 | @@ -1,2 +1,4 @@ | |||
22 | 1 | git-reinstall: | 1 | git-reinstall: |
23 | 2 | description: Reinstall openstack-dashboard from the openstack-origin-git repositories. | 2 | description: Reinstall openstack-dashboard from the openstack-origin-git repositories. |
24 | 3 | openstack-upgrade: | ||
25 | 4 | description: Perform openstack upgrades. Config option action-managed-upgrade must be set to True. | ||
26 | 3 | 5 | ||
27 | === added symlink 'actions/openstack-upgrade' | |||
28 | === target is u'openstack_upgrade.py' | |||
29 | === added file 'actions/openstack_upgrade.py' | |||
30 | --- actions/openstack_upgrade.py 1970-01-01 00:00:00 +0000 | |||
31 | +++ actions/openstack_upgrade.py 2015-10-14 14:39:53 +0000 | |||
32 | @@ -0,0 +1,34 @@ | |||
33 | 1 | #!/usr/bin/python | ||
34 | 2 | import sys | ||
35 | 3 | |||
36 | 4 | sys.path.append('hooks/') | ||
37 | 5 | |||
38 | 6 | from charmhelpers.contrib.openstack.utils import ( | ||
39 | 7 | do_action_openstack_upgrade, | ||
40 | 8 | ) | ||
41 | 9 | |||
42 | 10 | from horizon_utils import ( | ||
43 | 11 | do_openstack_upgrade, | ||
44 | 12 | ) | ||
45 | 13 | |||
46 | 14 | from horizon_hooks import ( | ||
47 | 15 | config_changed, | ||
48 | 16 | CONFIGS, | ||
49 | 17 | ) | ||
50 | 18 | |||
51 | 19 | |||
52 | 20 | def openstack_upgrade(): | ||
53 | 21 | """Upgrade packages to config-set Openstack version. | ||
54 | 22 | |||
55 | 23 | If the charm was installed from source we cannot upgrade it. | ||
56 | 24 | For backwards compatibility a config flag must be set for this | ||
57 | 25 | code to run, otherwise a full service level upgrade will fire | ||
58 | 26 | on config-changed.""" | ||
59 | 27 | |||
60 | 28 | if do_action_openstack_upgrade('openstack-dashboard', | ||
61 | 29 | do_openstack_upgrade, | ||
62 | 30 | CONFIGS): | ||
63 | 31 | config_changed() | ||
64 | 32 | |||
65 | 33 | if __name__ == '__main__': | ||
66 | 34 | openstack_upgrade() | ||
67 | 0 | 35 | ||
68 | === modified file 'config.yaml' | |||
69 | --- config.yaml 2015-07-10 14:18:48 +0000 | |||
70 | +++ config.yaml 2015-10-14 14:39:53 +0000 | |||
71 | @@ -153,6 +153,14 @@ | |||
72 | 153 | In order for this charm to function correctly, the privacy extension | 153 | In order for this charm to function correctly, the privacy extension |
73 | 154 | must be disabled and a non-temporary address must be | 154 | must be disabled and a non-temporary address must be |
74 | 155 | configured/available on your network interface. | 155 | configured/available on your network interface. |
75 | 156 | endpoint-type: | ||
76 | 157 | type: string | ||
77 | 158 | default: | ||
78 | 159 | description: | | ||
79 | 160 | Specifies the endpoint types to use for endpoints in the Keystone | ||
80 | 161 | service catalog. Valid values are 'publicURL', 'internalURL', | ||
81 | 162 | and 'adminURL'. Both the primary and secondary endpoint types can | ||
82 | 163 | be specified by providing multiple comma delimited values. | ||
83 | 156 | nagios_context: | 164 | nagios_context: |
84 | 157 | default: "juju" | 165 | default: "juju" |
85 | 158 | type: string | 166 | type: string |
86 | @@ -163,7 +171,7 @@ | |||
87 | 163 | . | 171 | . |
88 | 164 | juju-postgresql-0 | 172 | juju-postgresql-0 |
89 | 165 | . | 173 | . |
91 | 166 | If you're running multiple environments with the same services in them | 174 | If you are running multiple environments with the same services in them |
92 | 167 | this allows you to differentiate between them. | 175 | this allows you to differentiate between them. |
93 | 168 | nagios_check_http_params: | 176 | nagios_check_http_params: |
94 | 169 | default: "-H localhost -I 127.0.0.1 -u '/' -e 200,301,302" | 177 | default: "-H localhost -I 127.0.0.1 -u '/' -e 200,301,302" |
95 | @@ -175,4 +183,25 @@ | |||
96 | 175 | description: | | 183 | description: | |
97 | 176 | A comma-separated list of nagios servicegroups. If left empty, the | 184 | A comma-separated list of nagios servicegroups. If left empty, the |
98 | 177 | nagios_context will be used as the servicegroup. | 185 | nagios_context will be used as the servicegroup. |
100 | 178 | 186 | action-managed-upgrade: | |
101 | 187 | type: boolean | ||
102 | 188 | default: False | ||
103 | 189 | description: | | ||
104 | 190 | If True enables openstack upgrades for this charm via juju actions. | ||
105 | 191 | You will still need to set openstack-origin to the new repository but | ||
106 | 192 | instead of an upgrade running automatically across all units, it will | ||
107 | 193 | wait for you to execute the openstack-upgrade action for this charm on | ||
108 | 194 | each unit. If False it will revert to existing behavior of upgrading | ||
109 | 195 | all units on config change. | ||
110 | 196 | apache_http_addendum: | ||
111 | 197 | type: string | ||
112 | 198 | default: '' | ||
113 | 199 | description: | | ||
114 | 200 | Extra stanzas to be inserted into the HTTP virtual host configuration. | ||
115 | 201 | May be used to specify rewrite rules, for example. | ||
116 | 202 | apache_https_addendum: | ||
117 | 203 | type: string | ||
118 | 204 | default: '' | ||
119 | 205 | description: | | ||
120 | 206 | Extra stanzas to be inserted into the HTTPS virtual host configuration. | ||
121 | 207 | May be used to specify rewrite rules, for example. | ||
122 | 179 | 208 | ||
123 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' | |||
124 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-09-04 13:59:26 +0000 | |||
125 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-10-14 14:39:53 +0000 | |||
126 | @@ -25,6 +25,7 @@ | |||
127 | 25 | import re | 25 | import re |
128 | 26 | 26 | ||
129 | 27 | import six | 27 | import six |
130 | 28 | import traceback | ||
131 | 28 | import yaml | 29 | import yaml |
132 | 29 | 30 | ||
133 | 30 | from charmhelpers.contrib.network import ip | 31 | from charmhelpers.contrib.network import ip |
134 | @@ -34,6 +35,8 @@ | |||
135 | 34 | ) | 35 | ) |
136 | 35 | 36 | ||
137 | 36 | from charmhelpers.core.hookenv import ( | 37 | from charmhelpers.core.hookenv import ( |
138 | 38 | action_fail, | ||
139 | 39 | action_set, | ||
140 | 37 | config, | 40 | config, |
141 | 38 | log as juju_log, | 41 | log as juju_log, |
142 | 39 | charm_dir, | 42 | charm_dir, |
143 | @@ -114,6 +117,7 @@ | |||
144 | 114 | ('2.2.1', 'kilo'), | 117 | ('2.2.1', 'kilo'), |
145 | 115 | ('2.2.2', 'kilo'), | 118 | ('2.2.2', 'kilo'), |
146 | 116 | ('2.3.0', 'liberty'), | 119 | ('2.3.0', 'liberty'), |
147 | 120 | ('2.4.0', 'liberty'), | ||
148 | 117 | ]) | 121 | ]) |
149 | 118 | 122 | ||
150 | 119 | # >= Liberty version->codename mapping | 123 | # >= Liberty version->codename mapping |
151 | @@ -748,3 +752,47 @@ | |||
152 | 748 | return projects[key] | 752 | return projects[key] |
153 | 749 | 753 | ||
154 | 750 | return None | 754 | return None |
155 | 755 | |||
156 | 756 | |||
157 | 757 | def do_action_openstack_upgrade(package, upgrade_callback, configs): | ||
158 | 758 | """Perform action-managed OpenStack upgrade. | ||
159 | 759 | |||
160 | 760 | Upgrades packages to the configured openstack-origin version and sets | ||
161 | 761 | the corresponding action status as a result. | ||
162 | 762 | |||
163 | 763 | If the charm was installed from source we cannot upgrade it. | ||
164 | 764 | For backwards compatibility a config flag (action-managed-upgrade) must | ||
165 | 765 | be set for this code to run, otherwise a full service level upgrade will | ||
166 | 766 | fire on config-changed. | ||
167 | 767 | |||
168 | 768 | @param package: package name for determining if upgrade available | ||
169 | 769 | @param upgrade_callback: function callback to charm's upgrade function | ||
170 | 770 | @param configs: templating object derived from OSConfigRenderer class | ||
171 | 771 | |||
172 | 772 | @return: True if upgrade successful; False if upgrade failed or skipped | ||
173 | 773 | """ | ||
174 | 774 | ret = False | ||
175 | 775 | |||
176 | 776 | if git_install_requested(): | ||
177 | 777 | action_set({'outcome': 'installed from source, skipped upgrade.'}) | ||
178 | 778 | else: | ||
179 | 779 | if openstack_upgrade_available(package): | ||
180 | 780 | if config('action-managed-upgrade'): | ||
181 | 781 | juju_log('Upgrading OpenStack release') | ||
182 | 782 | |||
183 | 783 | try: | ||
184 | 784 | upgrade_callback(configs=configs) | ||
185 | 785 | action_set({'outcome': 'success, upgrade completed.'}) | ||
186 | 786 | ret = True | ||
187 | 787 | except: | ||
188 | 788 | action_set({'outcome': 'upgrade failed, see traceback.'}) | ||
189 | 789 | action_set({'traceback': traceback.format_exc()}) | ||
190 | 790 | action_fail('do_openstack_upgrade resulted in an ' | ||
191 | 791 | 'unexpected error') | ||
192 | 792 | else: | ||
193 | 793 | action_set({'outcome': 'action-managed-upgrade config is ' | ||
194 | 794 | 'False, skipped upgrade.'}) | ||
195 | 795 | else: | ||
196 | 796 | action_set({'outcome': 'no upgrade available.'}) | ||
197 | 797 | |||
198 | 798 | return ret | ||
199 | 751 | 799 | ||
200 | === added symlink 'hooks/dashboard-plugin-relation-changed' | |||
201 | === target is u'horizon_hooks.py' | |||
202 | === added symlink 'hooks/dashboard-plugin-relation-joined' | |||
203 | === target is u'horizon_hooks.py' | |||
204 | === removed symlink 'hooks/dashboard-plugin-relation-joined' | |||
205 | === target was u'horizon_hooks.py' | |||
206 | === modified file 'hooks/horizon_contexts.py' | |||
207 | --- hooks/horizon_contexts.py 2015-04-09 14:56:00 +0000 | |||
208 | +++ hooks/horizon_contexts.py 2015-10-14 14:39:53 +0000 | |||
209 | @@ -6,7 +6,8 @@ | |||
210 | 6 | relation_get, | 6 | relation_get, |
211 | 7 | local_unit, | 7 | local_unit, |
212 | 8 | unit_get, | 8 | unit_get, |
214 | 9 | log | 9 | log, |
215 | 10 | ERROR, | ||
216 | 10 | ) | 11 | ) |
217 | 11 | from charmhelpers.contrib.openstack.context import ( | 12 | from charmhelpers.contrib.openstack.context import ( |
218 | 12 | OSContextGenerator, | 13 | OSContextGenerator, |
219 | @@ -28,6 +29,12 @@ | |||
220 | 28 | from base64 import b64decode | 29 | from base64 import b64decode |
221 | 29 | import os | 30 | import os |
222 | 30 | 31 | ||
223 | 32 | VALID_ENDPOINT_TYPES = { | ||
224 | 33 | 'PUBLICURL': 'publicURL', | ||
225 | 34 | 'INTERNALURL': 'internalURL', | ||
226 | 35 | 'ADMINURL': 'adminURL', | ||
227 | 36 | } | ||
228 | 37 | |||
229 | 31 | 38 | ||
230 | 32 | class HorizonHAProxyContext(HAProxyContext): | 39 | class HorizonHAProxyContext(HAProxyContext): |
231 | 33 | def __call__(self): | 40 | def __call__(self): |
232 | @@ -69,6 +76,22 @@ | |||
233 | 69 | class IdentityServiceContext(OSContextGenerator): | 76 | class IdentityServiceContext(OSContextGenerator): |
234 | 70 | interfaces = ['identity-service'] | 77 | interfaces = ['identity-service'] |
235 | 71 | 78 | ||
236 | 79 | def normalize(self, endpoint_type): | ||
237 | 80 | """Normalizes the endpoint type values. | ||
238 | 81 | |||
239 | 82 | :param endpoint_type (string): the endpoint type to normalize. | ||
240 | 83 | :raises: Exception if the endpoint type is not valid. | ||
241 | 84 | :return (string): the normalized form of the endpoint type. | ||
242 | 85 | """ | ||
243 | 86 | normalized_form = VALID_ENDPOINT_TYPES.get(endpoint_type.upper(), None) | ||
244 | 87 | if not normalized_form: | ||
245 | 88 | msg = ('Endpoint type specified %s is not a valid' | ||
246 | 89 | ' endpoint type' % endpoint_type) | ||
247 | 90 | log(msg, ERROR) | ||
248 | 91 | raise Exception(msg) | ||
249 | 92 | |||
250 | 93 | return normalized_form | ||
251 | 94 | |||
252 | 72 | def __call__(self): | 95 | def __call__(self): |
253 | 73 | log('Generating template context for identity-service') | 96 | log('Generating template context for identity-service') |
254 | 74 | ctxt = {} | 97 | ctxt = {} |
255 | @@ -106,6 +129,21 @@ | |||
256 | 106 | avail_regions = map(lambda r: {'endpoint': r[0], 'title': r[1]}, | 129 | avail_regions = map(lambda r: {'endpoint': r[0], 'title': r[1]}, |
257 | 107 | regions) | 130 | regions) |
258 | 108 | ctxt['regions'] = sorted(avail_regions) | 131 | ctxt['regions'] = sorted(avail_regions) |
259 | 132 | |||
260 | 133 | # Allow the endpoint types to be specified via a config parameter. | ||
261 | 134 | # The config parameter accepts either: | ||
262 | 135 | # 1. a single endpoint type to be specified, in which case the | ||
263 | 136 | # primary endpoint is configured | ||
264 | 137 | # 2. a list of endpoint types, in which case the primary endpoint | ||
265 | 138 | # is taken as the first entry and the secondary endpoint is | ||
266 | 139 | # taken as the second entry. All subsequent entries are ignored. | ||
267 | 140 | ep_types = config('endpoint-type') | ||
268 | 141 | if ep_types: | ||
269 | 142 | ep_types = [self.normalize(e) for e in ep_types.split(',')] | ||
270 | 143 | ctxt['primary_endpoint'] = ep_types[0] | ||
271 | 144 | if len(ep_types) > 1: | ||
272 | 145 | ctxt['secondary_endpoint'] = ep_types[1] | ||
273 | 146 | |||
274 | 109 | return ctxt | 147 | return ctxt |
275 | 110 | 148 | ||
276 | 111 | 149 | ||
277 | @@ -134,7 +172,8 @@ | |||
278 | 134 | ''' Grab cert and key from configuraton for SSL config ''' | 172 | ''' Grab cert and key from configuraton for SSL config ''' |
279 | 135 | ctxt = { | 173 | ctxt = { |
280 | 136 | 'http_port': 70, | 174 | 'http_port': 70, |
282 | 137 | 'https_port': 433 | 175 | 'https_port': 433, |
283 | 176 | 'apache_http_addendum': config("apache_http_addendum"), | ||
284 | 138 | } | 177 | } |
285 | 139 | return ctxt | 178 | return ctxt |
286 | 140 | 179 | ||
287 | @@ -162,6 +201,8 @@ | |||
288 | 162 | ctxt = { | 201 | ctxt = { |
289 | 163 | 'ssl_configured': False, | 202 | 'ssl_configured': False, |
290 | 164 | } | 203 | } |
291 | 204 | ctxt['apache_https_addendum'] = config("apache_https_addendum") | ||
292 | 205 | |||
293 | 165 | return ctxt | 206 | return ctxt |
294 | 166 | 207 | ||
295 | 167 | 208 | ||
296 | @@ -172,3 +213,28 @@ | |||
297 | 172 | 'disable_router': False if config('profile') in ['cisco'] else True | 213 | 'disable_router': False if config('profile') in ['cisco'] else True |
298 | 173 | } | 214 | } |
299 | 174 | return ctxt | 215 | return ctxt |
300 | 216 | |||
301 | 217 | |||
302 | 218 | class LocalSettingsContext(OSContextGenerator): | ||
303 | 219 | def __call__(self): | ||
304 | 220 | ''' Additional config stanzas to be appended to local_settings.py ''' | ||
305 | 221 | |||
306 | 222 | relations = [] | ||
307 | 223 | |||
308 | 224 | for rid in relation_ids("plugin"): | ||
309 | 225 | try: | ||
310 | 226 | unit = related_units(rid)[0] | ||
311 | 227 | except IndexError: | ||
312 | 228 | pass | ||
313 | 229 | else: | ||
314 | 230 | rdata = relation_get(unit=unit, rid=rid) | ||
315 | 231 | if set(('local-settings', 'priority')) <= set(rdata.keys()): | ||
316 | 232 | relations.append((unit, rdata)) | ||
317 | 233 | |||
318 | 234 | ctxt = { | ||
319 | 235 | 'settings': [ | ||
320 | 236 | '# {0}\n{1}'.format(u, rd['local-settings']) | ||
321 | 237 | for u, rd in sorted(relations, | ||
322 | 238 | key=lambda r: r[1]['priority'])] | ||
323 | 239 | } | ||
324 | 240 | return ctxt | ||
325 | 175 | 241 | ||
326 | === modified file 'hooks/horizon_hooks.py' | |||
327 | --- hooks/horizon_hooks.py 2015-09-03 19:18:51 +0000 | |||
328 | +++ hooks/horizon_hooks.py 2015-10-14 14:39:53 +0000 | |||
329 | @@ -58,7 +58,7 @@ | |||
330 | 58 | CONFIGS = register_configs() | 58 | CONFIGS = register_configs() |
331 | 59 | 59 | ||
332 | 60 | 60 | ||
334 | 61 | @hooks.hook('install') | 61 | @hooks.hook('install.real') |
335 | 62 | def install(): | 62 | def install(): |
336 | 63 | execd_preinstall() | 63 | execd_preinstall() |
337 | 64 | configure_installation_source(config('openstack-origin')) | 64 | configure_installation_source(config('openstack-origin')) |
338 | @@ -106,7 +106,7 @@ | |||
339 | 106 | if git_install_requested(): | 106 | if git_install_requested(): |
340 | 107 | if config_value_changed('openstack-origin-git'): | 107 | if config_value_changed('openstack-origin-git'): |
341 | 108 | git_install(config('openstack-origin-git')) | 108 | git_install(config('openstack-origin-git')) |
343 | 109 | else: | 109 | elif not config('action-managed-upgrade'): |
344 | 110 | if openstack_upgrade_available('openstack-dashboard'): | 110 | if openstack_upgrade_available('openstack-dashboard'): |
345 | 111 | do_openstack_upgrade(configs=CONFIGS) | 111 | do_openstack_upgrade(configs=CONFIGS) |
346 | 112 | 112 | ||
347 | @@ -247,16 +247,23 @@ | |||
348 | 247 | 247 | ||
349 | 248 | 248 | ||
350 | 249 | @hooks.hook('dashboard-plugin-relation-joined') | 249 | @hooks.hook('dashboard-plugin-relation-joined') |
352 | 250 | def update_dashboard_plugin(rel_id=None): | 250 | def plugin_relation_joined(rel_id=None): |
353 | 251 | if git_install_requested(): | 251 | if git_install_requested(): |
354 | 252 | bin_path = git_pip_venv_dir(config('openstack-origin-git')) | 252 | bin_path = git_pip_venv_dir(config('openstack-origin-git')) |
355 | 253 | else: | 253 | else: |
356 | 254 | bin_path = '/usr/bin' | 254 | bin_path = '/usr/bin' |
358 | 255 | relation_set(relation_id=rel_id, | 255 | relation_set(release=os_release("openstack-dashboard"), |
359 | 256 | relation_id=rel_id, | ||
360 | 256 | bin_path=bin_path, | 257 | bin_path=bin_path, |
361 | 257 | openstack_dir=INSTALL_DIR) | 258 | openstack_dir=INSTALL_DIR) |
362 | 258 | 259 | ||
363 | 259 | 260 | ||
364 | 261 | @hooks.hook('dashboard-plugin-relation-changed') | ||
365 | 262 | @restart_on_change(restart_map()) | ||
366 | 263 | def update_plugin_config(): | ||
367 | 264 | CONFIGS.write(LOCAL_SETTINGS) | ||
368 | 265 | |||
369 | 266 | |||
370 | 260 | def main(): | 267 | def main(): |
371 | 261 | try: | 268 | try: |
372 | 262 | hooks.execute(sys.argv) | 269 | hooks.execute(sys.argv) |
373 | 263 | 270 | ||
374 | === modified file 'hooks/horizon_utils.py' | |||
375 | --- hooks/horizon_utils.py 2015-09-03 19:18:51 +0000 | |||
376 | +++ hooks/horizon_utils.py 2015-10-14 14:39:53 +0000 | |||
377 | @@ -101,7 +101,8 @@ | |||
378 | 101 | (LOCAL_SETTINGS, { | 101 | (LOCAL_SETTINGS, { |
379 | 102 | 'hook_contexts': [horizon_contexts.HorizonContext(), | 102 | 'hook_contexts': [horizon_contexts.HorizonContext(), |
380 | 103 | horizon_contexts.IdentityServiceContext(), | 103 | horizon_contexts.IdentityServiceContext(), |
382 | 104 | context.SyslogContext()], | 104 | context.SyslogContext(), |
383 | 105 | horizon_contexts.LocalSettingsContext()], | ||
384 | 105 | 'services': ['apache2'] | 106 | 'services': ['apache2'] |
385 | 106 | }), | 107 | }), |
386 | 107 | (APACHE_CONF, { | 108 | (APACHE_CONF, { |
387 | @@ -262,12 +263,12 @@ | |||
388 | 262 | raise Exception("IPv6 is not supported in the charms for Ubuntu " | 263 | raise Exception("IPv6 is not supported in the charms for Ubuntu " |
389 | 263 | "versions less than Trusty 14.04") | 264 | "versions less than Trusty 14.04") |
390 | 264 | 265 | ||
397 | 265 | # NOTE(xianghui): Need to install haproxy(1.5.3) from trusty-backports | 266 | # Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to |
398 | 266 | # to support ipv6 address, so check is required to make sure not | 267 | # use trusty-backports otherwise we can use the UCA. |
399 | 267 | # breaking other versions, IPv6 only support for >= Trusty | 268 | os_pkg = 'openstack-dashboard' |
400 | 268 | if ubuntu_rel == 'trusty': | 269 | if ubuntu_rel == 'trusty' and os_release(os_pkg) < 'liberty': |
401 | 269 | add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports' | 270 | add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports ' |
402 | 270 | ' main') | 271 | 'main') |
403 | 271 | apt_update() | 272 | apt_update() |
404 | 272 | apt_install('haproxy/trusty-backports', fatal=True) | 273 | apt_install('haproxy/trusty-backports', fatal=True) |
405 | 273 | 274 | ||
406 | 274 | 275 | ||
407 | === modified symlink 'hooks/install' (properties changed: -x to +x) | |||
408 | === target was u'horizon_hooks.py' | |||
409 | --- hooks/install 1970-01-01 00:00:00 +0000 | |||
410 | +++ hooks/install 2015-10-14 14:39:53 +0000 | |||
411 | @@ -0,0 +1,20 @@ | |||
412 | 1 | #!/bin/bash | ||
413 | 2 | # Wrapper to deal with newer Ubuntu versions that don't have py2 installed | ||
414 | 3 | # by default. | ||
415 | 4 | |||
416 | 5 | declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml') | ||
417 | 6 | |||
418 | 7 | check_and_install() { | ||
419 | 8 | pkg="${1}-${2}" | ||
420 | 9 | if ! dpkg -s ${pkg} 2>&1 > /dev/null; then | ||
421 | 10 | apt-get -y install ${pkg} | ||
422 | 11 | fi | ||
423 | 12 | } | ||
424 | 13 | |||
425 | 14 | PYTHON="python" | ||
426 | 15 | |||
427 | 16 | for dep in ${DEPS[@]}; do | ||
428 | 17 | check_and_install ${PYTHON} ${dep} | ||
429 | 18 | done | ||
430 | 19 | |||
431 | 20 | exec ./hooks/install.real | ||
432 | 0 | 21 | ||
433 | === added symlink 'hooks/install.real' | |||
434 | === target is u'horizon_hooks.py' | |||
435 | === modified file 'metadata.yaml' | |||
436 | --- metadata.yaml 2015-09-10 20:38:16 +0000 | |||
437 | +++ metadata.yaml 2015-10-14 14:39:53 +0000 | |||
438 | @@ -15,6 +15,7 @@ | |||
439 | 15 | interface: http | 15 | interface: http |
440 | 16 | dashboard-plugin: | 16 | dashboard-plugin: |
441 | 17 | interface: dashboard-plugin | 17 | interface: dashboard-plugin |
442 | 18 | scope: container | ||
443 | 18 | requires: | 19 | requires: |
444 | 19 | identity-service: | 20 | identity-service: |
445 | 20 | interface: keystone | 21 | interface: keystone |
446 | 21 | 22 | ||
447 | === modified file 'templates/default' | |||
448 | --- templates/default 2013-07-15 16:25:46 +0000 | |||
449 | +++ templates/default 2015-10-14 14:39:53 +0000 | |||
450 | @@ -29,4 +29,6 @@ | |||
451 | 29 | 29 | ||
452 | 30 | CustomLog ${APACHE_LOG_DIR}/access.log combined | 30 | CustomLog ${APACHE_LOG_DIR}/access.log combined |
453 | 31 | 31 | ||
454 | 32 | {{ apache_http_addendum }} | ||
455 | 33 | |||
456 | 32 | </VirtualHost> | 34 | </VirtualHost> |
457 | 33 | 35 | ||
458 | === modified file 'templates/default-ssl' | |||
459 | --- templates/default-ssl 2013-07-15 16:25:46 +0000 | |||
460 | +++ templates/default-ssl 2015-10-14 14:39:53 +0000 | |||
461 | @@ -46,5 +46,7 @@ | |||
462 | 46 | downgrade-1.0 force-response-1.0 | 46 | downgrade-1.0 force-response-1.0 |
463 | 47 | BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown | 47 | BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown |
464 | 48 | 48 | ||
465 | 49 | {{ apache_https_addendum }} | ||
466 | 50 | |||
467 | 49 | </VirtualHost> | 51 | </VirtualHost> |
468 | 50 | </IfModule> | 52 | </IfModule> |
469 | 51 | 53 | ||
470 | === modified file 'templates/essex/local_settings.py' | |||
471 | --- templates/essex/local_settings.py 2014-02-27 10:07:57 +0000 | |||
472 | +++ templates/essex/local_settings.py 2015-10-14 14:39:53 +0000 | |||
473 | @@ -118,3 +118,5 @@ | |||
474 | 118 | } | 118 | } |
475 | 119 | } | 119 | } |
476 | 120 | } | 120 | } |
477 | 121 | |||
478 | 122 | {{ settings|join('\n\n') }} | ||
479 | 121 | 123 | ||
480 | === modified file 'templates/folsom/local_settings.py' | |||
481 | --- templates/folsom/local_settings.py 2014-05-28 16:05:37 +0000 | |||
482 | +++ templates/folsom/local_settings.py 2015-10-14 14:39:53 +0000 | |||
483 | @@ -167,3 +167,5 @@ | |||
484 | 167 | # offline compression by default. To enable online compression, install | 167 | # offline compression by default. To enable online compression, install |
485 | 168 | # the node-less package and enable the following option. | 168 | # the node-less package and enable the following option. |
486 | 169 | COMPRESS_OFFLINE = {{ compress_offline }} | 169 | COMPRESS_OFFLINE = {{ compress_offline }} |
487 | 170 | |||
488 | 171 | {{ settings|join('\n\n') }} | ||
489 | 170 | \ No newline at end of file | 172 | \ No newline at end of file |
490 | 171 | 173 | ||
491 | === modified file 'templates/grizzly/local_settings.py' | |||
492 | --- templates/grizzly/local_settings.py 2014-05-28 16:05:37 +0000 | |||
493 | +++ templates/grizzly/local_settings.py 2015-10-14 14:39:53 +0000 | |||
494 | @@ -263,3 +263,5 @@ | |||
495 | 263 | } | 263 | } |
496 | 264 | } | 264 | } |
497 | 265 | } | 265 | } |
498 | 266 | |||
499 | 267 | {{ settings|join('\n\n') }} | ||
500 | 266 | 268 | ||
501 | === modified file 'templates/havana/local_settings.py' | |||
502 | --- templates/havana/local_settings.py 2014-07-22 07:18:55 +0000 | |||
503 | +++ templates/havana/local_settings.py 2015-10-14 14:39:53 +0000 | |||
504 | @@ -483,3 +483,5 @@ | |||
505 | 483 | # installations should have this set accordingly. For more information | 483 | # installations should have this set accordingly. For more information |
506 | 484 | # see https://docs.djangoproject.com/en/dev/ref/settings/. | 484 | # see https://docs.djangoproject.com/en/dev/ref/settings/. |
507 | 485 | ALLOWED_HOSTS = '*' | 485 | ALLOWED_HOSTS = '*' |
508 | 486 | |||
509 | 487 | {{ settings|join('\n\n') }} | ||
510 | 486 | \ No newline at end of file | 488 | \ No newline at end of file |
511 | 487 | 489 | ||
512 | === modified file 'templates/icehouse/local_settings.py' | |||
513 | --- templates/icehouse/local_settings.py 2014-12-01 23:45:41 +0000 | |||
514 | +++ templates/icehouse/local_settings.py 2015-10-14 14:39:53 +0000 | |||
515 | @@ -212,6 +212,9 @@ | |||
516 | 212 | # in the Keystone service catalog. Use this setting when Horizon is running | 212 | # in the Keystone service catalog. Use this setting when Horizon is running |
517 | 213 | # external to the OpenStack environment. The default is 'publicURL'. | 213 | # external to the OpenStack environment. The default is 'publicURL'. |
518 | 214 | #OPENSTACK_ENDPOINT_TYPE = "publicURL" | 214 | #OPENSTACK_ENDPOINT_TYPE = "publicURL" |
519 | 215 | {% if primary_endpoint -%} | ||
520 | 216 | OPENSTACK_ENDPOINT_TYPE = {{ primary_endpoint }} | ||
521 | 217 | {% endif -%} | ||
522 | 215 | 218 | ||
523 | 216 | # SECONDARY_ENDPOINT_TYPE specifies the fallback endpoint type to use in the | 219 | # SECONDARY_ENDPOINT_TYPE specifies the fallback endpoint type to use in the |
524 | 217 | # case that OPENSTACK_ENDPOINT_TYPE is not present in the endpoints | 220 | # case that OPENSTACK_ENDPOINT_TYPE is not present in the endpoints |
525 | @@ -219,6 +222,9 @@ | |||
526 | 219 | # external to the OpenStack environment. The default is None. This | 222 | # external to the OpenStack environment. The default is None. This |
527 | 220 | # value should differ from OPENSTACK_ENDPOINT_TYPE if used. | 223 | # value should differ from OPENSTACK_ENDPOINT_TYPE if used. |
528 | 221 | #SECONDARY_ENDPOINT_TYPE = "publicURL" | 224 | #SECONDARY_ENDPOINT_TYPE = "publicURL" |
529 | 225 | {% if secondary_endpoint -%} | ||
530 | 226 | SECONDARY_ENDPOINT_TYPE = {{ secondary_endpoint }} | ||
531 | 227 | {% endif -%} | ||
532 | 222 | 228 | ||
533 | 223 | # The number of objects (Swift containers/objects or images) to display | 229 | # The number of objects (Swift containers/objects or images) to display |
534 | 224 | # on a single page before providing a paging element (a "more" link) | 230 | # on a single page before providing a paging element (a "more" link) |
535 | @@ -514,3 +520,5 @@ | |||
536 | 514 | # installations should have this set accordingly. For more information | 520 | # installations should have this set accordingly. For more information |
537 | 515 | # see https://docs.djangoproject.com/en/dev/ref/settings/. | 521 | # see https://docs.djangoproject.com/en/dev/ref/settings/. |
538 | 516 | ALLOWED_HOSTS = '*' | 522 | ALLOWED_HOSTS = '*' |
539 | 523 | |||
540 | 524 | {{ settings|join('\n\n') }} | ||
541 | 517 | \ No newline at end of file | 525 | \ No newline at end of file |
542 | 518 | 526 | ||
543 | === modified file 'templates/juno/local_settings.py' | |||
544 | --- templates/juno/local_settings.py 2014-12-01 23:45:41 +0000 | |||
545 | +++ templates/juno/local_settings.py 2015-10-14 14:39:53 +0000 | |||
546 | @@ -250,6 +250,9 @@ | |||
547 | 250 | # in the Keystone service catalog. Use this setting when Horizon is running | 250 | # in the Keystone service catalog. Use this setting when Horizon is running |
548 | 251 | # external to the OpenStack environment. The default is 'publicURL'. | 251 | # external to the OpenStack environment. The default is 'publicURL'. |
549 | 252 | #OPENSTACK_ENDPOINT_TYPE = "publicURL" | 252 | #OPENSTACK_ENDPOINT_TYPE = "publicURL" |
550 | 253 | {% if primary_endpoint -%} | ||
551 | 254 | OPENSTACK_ENDPOINT_TYPE = {{ primary_endpoint }} | ||
552 | 255 | {% endif -%} | ||
553 | 253 | 256 | ||
554 | 254 | # SECONDARY_ENDPOINT_TYPE specifies the fallback endpoint type to use in the | 257 | # SECONDARY_ENDPOINT_TYPE specifies the fallback endpoint type to use in the |
555 | 255 | # case that OPENSTACK_ENDPOINT_TYPE is not present in the endpoints | 258 | # case that OPENSTACK_ENDPOINT_TYPE is not present in the endpoints |
556 | @@ -257,6 +260,9 @@ | |||
557 | 257 | # external to the OpenStack environment. The default is None. This | 260 | # external to the OpenStack environment. The default is None. This |
558 | 258 | # value should differ from OPENSTACK_ENDPOINT_TYPE if used. | 261 | # value should differ from OPENSTACK_ENDPOINT_TYPE if used. |
559 | 259 | #SECONDARY_ENDPOINT_TYPE = "publicURL" | 262 | #SECONDARY_ENDPOINT_TYPE = "publicURL" |
560 | 263 | {% if secondary_endpoint -%} | ||
561 | 264 | SECONDARY_ENDPOINT_TYPE = {{ secondary_endpoint }} | ||
562 | 265 | {% endif -%} | ||
563 | 260 | 266 | ||
564 | 261 | # The number of objects (Swift containers/objects or images) to display | 267 | # The number of objects (Swift containers/objects or images) to display |
565 | 262 | # on a single page before providing a paging element (a "more" link) | 268 | # on a single page before providing a paging element (a "more" link) |
566 | @@ -619,3 +625,5 @@ | |||
567 | 619 | # installations should have this set accordingly. For more information | 625 | # installations should have this set accordingly. For more information |
568 | 620 | # see https://docs.djangoproject.com/en/dev/ref/settings/. | 626 | # see https://docs.djangoproject.com/en/dev/ref/settings/. |
569 | 621 | ALLOWED_HOSTS = '*' | 627 | ALLOWED_HOSTS = '*' |
570 | 628 | |||
571 | 629 | {{ settings|join('\n\n') }} | ||
572 | 622 | \ No newline at end of file | 630 | \ No newline at end of file |
573 | 623 | 631 | ||
574 | === modified file 'tests/00-setup' | |||
575 | --- tests/00-setup 2015-08-21 18:42:43 +0000 | |||
576 | +++ tests/00-setup 2015-10-14 14:39:53 +0000 | |||
577 | @@ -5,6 +5,7 @@ | |||
578 | 5 | sudo add-apt-repository --yes ppa:juju/stable | 5 | sudo add-apt-repository --yes ppa:juju/stable |
579 | 6 | sudo apt-get update --yes | 6 | sudo apt-get update --yes |
580 | 7 | sudo apt-get install --yes amulet \ | 7 | sudo apt-get install --yes amulet \ |
581 | 8 | distro-info-data \ | ||
582 | 8 | python-cinderclient \ | 9 | python-cinderclient \ |
583 | 9 | python-distro-info \ | 10 | python-distro-info \ |
584 | 10 | python-glanceclient \ | 11 | python-glanceclient \ |
585 | 11 | 12 | ||
586 | === modified file 'tests/tests.yaml' | |||
587 | --- tests/tests.yaml 2015-08-21 18:42:43 +0000 | |||
588 | +++ tests/tests.yaml 2015-10-14 14:39:53 +0000 | |||
589 | @@ -8,7 +8,7 @@ | |||
590 | 8 | - ppa:juju/stable | 8 | - ppa:juju/stable |
591 | 9 | packages: | 9 | packages: |
592 | 10 | - amulet | 10 | - amulet |
594 | 11 | - python-amulet | 11 | - distro-info-data |
595 | 12 | - python-cinderclient | 12 | - python-cinderclient |
596 | 13 | - python-distro-info | 13 | - python-distro-info |
597 | 14 | - python-glanceclient | 14 | - python-glanceclient |
598 | 15 | 15 | ||
599 | === added file 'unit_tests/test_actions_openstack_upgrade.py' | |||
600 | --- unit_tests/test_actions_openstack_upgrade.py 1970-01-01 00:00:00 +0000 | |||
601 | +++ unit_tests/test_actions_openstack_upgrade.py 2015-10-14 14:39:53 +0000 | |||
602 | @@ -0,0 +1,53 @@ | |||
603 | 1 | from mock import patch | ||
604 | 2 | import os | ||
605 | 3 | |||
606 | 4 | os.environ['JUJU_UNIT_NAME'] = 'openstack-dashboard' | ||
607 | 5 | |||
608 | 6 | with patch('horizon_utils.register_configs') as register_configs: | ||
609 | 7 | import openstack_upgrade | ||
610 | 8 | |||
611 | 9 | from test_utils import ( | ||
612 | 10 | CharmTestCase | ||
613 | 11 | ) | ||
614 | 12 | |||
615 | 13 | TO_PATCH = [ | ||
616 | 14 | 'do_openstack_upgrade', | ||
617 | 15 | 'config_changed', | ||
618 | 16 | ] | ||
619 | 17 | |||
620 | 18 | |||
621 | 19 | class TestHorizonUpgradeActions(CharmTestCase): | ||
622 | 20 | |||
623 | 21 | def setUp(self): | ||
624 | 22 | super(TestHorizonUpgradeActions, self).setUp(openstack_upgrade, | ||
625 | 23 | TO_PATCH) | ||
626 | 24 | |||
627 | 25 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
628 | 26 | @patch('charmhelpers.contrib.openstack.utils.action_set') | ||
629 | 27 | @patch('charmhelpers.contrib.openstack.utils.git_install_requested') | ||
630 | 28 | @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') | ||
631 | 29 | def test_openstack_upgrade_true(self, upgrade_avail, git_requested, | ||
632 | 30 | action_set, config): | ||
633 | 31 | git_requested.return_value = False | ||
634 | 32 | upgrade_avail.return_value = True | ||
635 | 33 | config.return_value = True | ||
636 | 34 | |||
637 | 35 | openstack_upgrade.openstack_upgrade() | ||
638 | 36 | |||
639 | 37 | self.assertTrue(self.do_openstack_upgrade.called) | ||
640 | 38 | self.assertTrue(self.config_changed.called) | ||
641 | 39 | |||
642 | 40 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
643 | 41 | @patch('charmhelpers.contrib.openstack.utils.action_set') | ||
644 | 42 | @patch('charmhelpers.contrib.openstack.utils.git_install_requested') | ||
645 | 43 | @patch('charmhelpers.contrib.openstack.utils.openstack_upgrade_available') | ||
646 | 44 | def test_openstack_upgrade_false(self, upgrade_avail, git_requested, | ||
647 | 45 | action_set, config): | ||
648 | 46 | git_requested.return_value = False | ||
649 | 47 | upgrade_avail.return_value = True | ||
650 | 48 | config.return_value = False | ||
651 | 49 | |||
652 | 50 | openstack_upgrade.openstack_upgrade() | ||
653 | 51 | |||
654 | 52 | self.assertFalse(self.do_openstack_upgrade.called) | ||
655 | 53 | self.assertFalse(self.config_changed.called) | ||
656 | 0 | 54 | ||
657 | === modified file 'unit_tests/test_horizon_contexts.py' | |||
658 | --- unit_tests/test_horizon_contexts.py 2015-04-09 14:34:44 +0000 | |||
659 | +++ unit_tests/test_horizon_contexts.py 2015-10-14 14:39:53 +0000 | |||
660 | @@ -47,19 +47,23 @@ | |||
661 | 47 | self.pwgen.return_value = "secret" | 47 | self.pwgen.return_value = "secret" |
662 | 48 | 48 | ||
663 | 49 | def test_Apachecontext(self): | 49 | def test_Apachecontext(self): |
664 | 50 | self.test_config.set('apache_http_addendum', 'RewriteEngine on') | ||
665 | 50 | self.assertEquals(horizon_contexts.ApacheContext()(), | 51 | self.assertEquals(horizon_contexts.ApacheContext()(), |
667 | 51 | {'http_port': 70, 'https_port': 433}) | 52 | {'http_port': 70, 'https_port': 433, |
668 | 53 | 'apache_http_addendum': 'RewriteEngine on'}) | ||
669 | 52 | 54 | ||
670 | 53 | @patch.object(horizon_contexts, 'get_ca_cert', lambda: None) | 55 | @patch.object(horizon_contexts, 'get_ca_cert', lambda: None) |
671 | 54 | @patch('os.chmod') | 56 | @patch('os.chmod') |
672 | 55 | def test_ApacheSSLContext_enabled(self, _chmod): | 57 | def test_ApacheSSLContext_enabled(self, _chmod): |
673 | 56 | self.get_cert.return_value = ('cert', 'key') | 58 | self.get_cert.return_value = ('cert', 'key') |
674 | 57 | self.b64decode.side_effect = ['cert', 'key'] | 59 | self.b64decode.side_effect = ['cert', 'key'] |
675 | 60 | self.test_config.set('apache_https_addendum', 'RewriteEngine off') | ||
676 | 58 | with patch_open() as (_open, _file): | 61 | with patch_open() as (_open, _file): |
677 | 59 | self.assertEquals(horizon_contexts.ApacheSSLContext()(), | 62 | self.assertEquals(horizon_contexts.ApacheSSLContext()(), |
678 | 60 | {'ssl_configured': True, | 63 | {'ssl_configured': True, |
679 | 61 | 'ssl_cert': '/etc/ssl/certs/dashboard.cert', | 64 | 'ssl_cert': '/etc/ssl/certs/dashboard.cert', |
681 | 62 | 'ssl_key': '/etc/ssl/private/dashboard.key'}) | 65 | 'ssl_key': '/etc/ssl/private/dashboard.key', |
682 | 66 | 'apache_https_addendum': 'RewriteEngine off'}) | ||
683 | 63 | _open.assert_has_calls([ | 67 | _open.assert_has_calls([ |
684 | 64 | call('/etc/ssl/certs/dashboard.cert', 'w'), | 68 | call('/etc/ssl/certs/dashboard.cert', 'w'), |
685 | 65 | call('/etc/ssl/private/dashboard.key', 'w') | 69 | call('/etc/ssl/private/dashboard.key', 'w') |
686 | @@ -75,7 +79,8 @@ | |||
687 | 75 | def test_ApacheSSLContext_disabled(self): | 79 | def test_ApacheSSLContext_disabled(self): |
688 | 76 | self.get_cert.return_value = (None, None) | 80 | self.get_cert.return_value = (None, None) |
689 | 77 | self.assertEquals(horizon_contexts.ApacheSSLContext()(), | 81 | self.assertEquals(horizon_contexts.ApacheSSLContext()(), |
691 | 78 | {'ssl_configured': False}) | 82 | {'ssl_configured': False, |
692 | 83 | 'apache_https_addendum': ''}) | ||
693 | 79 | 84 | ||
694 | 80 | def test_HorizonContext_defaults(self): | 85 | def test_HorizonContext_defaults(self): |
695 | 81 | self.assertEquals(horizon_contexts.HorizonContext()(), | 86 | self.assertEquals(horizon_contexts.HorizonContext()(), |
696 | @@ -212,6 +217,22 @@ | |||
697 | 212 | {'endpoint': 'http://foo:5000/v2.0', | 217 | {'endpoint': 'http://foo:5000/v2.0', |
698 | 213 | 'title': 'regionTwo'}]}) | 218 | 'title': 'regionTwo'}]}) |
699 | 214 | 219 | ||
700 | 220 | def test_IdentityServiceContext_endpoint_type(self): | ||
701 | 221 | self.test_config.set('endpoint-type', 'internalURL') | ||
702 | 222 | self.assertEqual(horizon_contexts.IdentityServiceContext()(), | ||
703 | 223 | {'primary_endpoint': 'internalURL'}) | ||
704 | 224 | |||
705 | 225 | def test_IdentityServiceContext_multi_endpoint_types(self): | ||
706 | 226 | self.test_config.set('endpoint-type', 'internalURL,publicURL') | ||
707 | 227 | self.assertEqual(horizon_contexts.IdentityServiceContext()(), | ||
708 | 228 | {'primary_endpoint': 'internalURL', | ||
709 | 229 | 'secondary_endpoint': 'publicURL'}) | ||
710 | 230 | |||
711 | 231 | def test_IdentityServiceContext_invalid_endpoint_type(self): | ||
712 | 232 | self.test_config.set('endpoint-type', 'this_is_bad') | ||
713 | 233 | with self.assertRaises(Exception): | ||
714 | 234 | horizon_contexts.IdentityServiceContext()() | ||
715 | 235 | |||
716 | 215 | def test_HorizonHAProxyContext_no_cluster(self): | 236 | def test_HorizonHAProxyContext_no_cluster(self): |
717 | 216 | self.relation_ids.return_value = [] | 237 | self.relation_ids.return_value = [] |
718 | 217 | self.local_unit.return_value = 'openstack-dashboard/0' | 238 | self.local_unit.return_value = 'openstack-dashboard/0' |
719 | @@ -251,3 +272,18 @@ | |||
720 | 251 | self.test_config.set('profile', None) | 272 | self.test_config.set('profile', None) |
721 | 252 | self.assertEquals(horizon_contexts.RouterSettingContext()(), | 273 | self.assertEquals(horizon_contexts.RouterSettingContext()(), |
722 | 253 | {'disable_router': True, }) | 274 | {'disable_router': True, }) |
723 | 275 | |||
724 | 276 | def test_LocalSettingsContext(self): | ||
725 | 277 | self.relation_ids.return_value = ['plugin:0', 'plugin-too:0'] | ||
726 | 278 | self.related_units.side_effect = [['horizon-plugin/0'], | ||
727 | 279 | ['horizon-plugin-too/0']] | ||
728 | 280 | self.relation_get.side_effect = [{'priority': 99, | ||
729 | 281 | 'local-settings': 'FOO = True'}, | ||
730 | 282 | {'priority': 60, | ||
731 | 283 | 'local-settings': 'BAR = False'}] | ||
732 | 284 | |||
733 | 285 | self.assertEquals(horizon_contexts.LocalSettingsContext()(), | ||
734 | 286 | {'settings': ['# horizon-plugin-too/0\n' | ||
735 | 287 | 'BAR = False', | ||
736 | 288 | '# horizon-plugin/0\n' | ||
737 | 289 | 'FOO = True']}) | ||
738 | 254 | 290 | ||
739 | === modified file 'unit_tests/test_horizon_hooks.py' | |||
740 | --- unit_tests/test_horizon_hooks.py 2015-09-04 15:16:58 +0000 | |||
741 | +++ unit_tests/test_horizon_hooks.py 2015-10-14 14:39:53 +0000 | |||
742 | @@ -308,25 +308,32 @@ | |||
743 | 308 | self._call_hook('website-relation-joined') | 308 | self._call_hook('website-relation-joined') |
744 | 309 | self.relation_set.assert_called_with(port=70, hostname='192.168.1.1') | 309 | self.relation_set.assert_called_with(port=70, hostname='192.168.1.1') |
745 | 310 | 310 | ||
746 | 311 | @patch.object(hooks, 'os_release') | ||
747 | 311 | @patch.object(hooks, 'git_install_requested') | 312 | @patch.object(hooks, 'git_install_requested') |
749 | 312 | def test_dashboard_config_joined_not_git(self, _git_requested): | 313 | def test_dashboard_config_joined_not_git( |
750 | 314 | self, _git_requested, _os_release): | ||
751 | 313 | _git_requested.return_value = False | 315 | _git_requested.return_value = False |
752 | 316 | _os_release.return_value = 'vivid' | ||
753 | 314 | self._call_hook('dashboard-plugin-relation-joined') | 317 | self._call_hook('dashboard-plugin-relation-joined') |
754 | 315 | self.relation_set.assert_called_with( | 318 | self.relation_set.assert_called_with( |
755 | 319 | release='vivid', | ||
756 | 316 | bin_path='/usr/bin', | 320 | bin_path='/usr/bin', |
757 | 317 | openstack_dir='/usr/share/openstack-dashboard', | 321 | openstack_dir='/usr/share/openstack-dashboard', |
758 | 318 | relation_id=None | 322 | relation_id=None |
759 | 319 | ) | 323 | ) |
760 | 320 | 324 | ||
761 | 325 | @patch.object(hooks, 'os_release') | ||
762 | 321 | @patch.object(hooks, 'git_pip_venv_dir') | 326 | @patch.object(hooks, 'git_pip_venv_dir') |
763 | 322 | @patch.object(hooks, 'git_install_requested') | 327 | @patch.object(hooks, 'git_install_requested') |
766 | 323 | def test_dashboard_config_joined_git(self, _git_requested, | 328 | def test_dashboard_config_joined_git( |
767 | 324 | _git_pip_venv_dir): | 329 | self, _git_requested, _git_pip_venv_dir, _os_release): |
768 | 325 | expected_bin_path = '/mnt/fuji/venv' | 330 | expected_bin_path = '/mnt/fuji/venv' |
769 | 326 | _git_requested.return_value = True | 331 | _git_requested.return_value = True |
770 | 327 | _git_pip_venv_dir.return_value = expected_bin_path | 332 | _git_pip_venv_dir.return_value = expected_bin_path |
771 | 333 | _os_release.return_value = 'wily' | ||
772 | 328 | self._call_hook('dashboard-plugin-relation-joined') | 334 | self._call_hook('dashboard-plugin-relation-joined') |
773 | 329 | self.relation_set.assert_called_with( | 335 | self.relation_set.assert_called_with( |
774 | 336 | release='wily', | ||
775 | 330 | bin_path=expected_bin_path, | 337 | bin_path=expected_bin_path, |
776 | 331 | openstack_dir='/usr/share/openstack-dashboard', | 338 | openstack_dir='/usr/share/openstack-dashboard', |
777 | 332 | relation_id=None | 339 | relation_id=None |
This branch was started based on the 'next' version of the openstack- dashboard, so it brings our up-to-date with the latest.