Merge lp:~corey.bryant/charms/trusty/cinder/git into lp:~openstack-charmers-archive/charms/trusty/cinder/next
- Trusty Tahr (14.04)
- git
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 86 |
Proposed branch: | lp:~corey.bryant/charms/trusty/cinder/git |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/cinder/next |
Diff against target: |
1450 lines (+899/-90) 30 files modified
Makefile (+6/-2) README.md (+91/-0) actions.yaml (+2/-0) actions/git_reinstall.py (+45/-0) charm-helpers-hooks.yaml (+1/-1) config.yaml (+16/-0) hooks/charmhelpers/contrib/openstack/utils.py (+4/-1) hooks/cinder_hooks.py (+18/-8) hooks/cinder_utils.py (+181/-4) templates/git/cinder_sudoers (+4/-0) templates/git/cinder_tgt.conf (+1/-0) templates/git/logging.conf (+76/-0) tests/00-setup (+3/-2) tests/11-basic-precise-folsom (+0/-11) tests/12-basic-precise-grizzly (+0/-11) tests/13-basic-precise-havana (+0/-11) tests/16-basic-trusty-icehouse-git (+9/-0) tests/16-basic-vivid-kilo (+0/-9) tests/17-basic-trusty-juno (+11/-0) tests/17-basic-trusty-kilo (+0/-11) tests/18-basic-trusty-juno-git (+12/-0) tests/19-basic-trusty-kilo (+11/-0) tests/20-basic-trusty-kilo-git (+12/-0) tests/21-basic-vivid-kilo (+9/-0) tests/22-basic-vivid-kilo-git (+9/-0) tests/basic_deployment.py (+27/-3) unit_tests/__init__.py (+2/-0) unit_tests/test_actions_git_reinstall.py (+110/-0) unit_tests/test_cinder_hooks.py (+74/-10) unit_tests/test_cinder_utils.py (+165/-6) |
To merge this branch: | bzr merge lp:~corey.bryant/charms/trusty/cinder/git |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenStack Charmers | Pending | ||
Review via email: mp+254951@code.launchpad.net |
Commit message
Description of the change
Corey Bryant (corey.bryant) wrote : | # |
- 92. By Corey Bryant
-
Move config_changed into try block
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3409 cinder-next for corey.bryant mp254951
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3197 cinder-next for corey.bryant mp254951
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3202 cinder-next for corey.bryant mp254951
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://
Build: http://
Corey Bryant (corey.bryant) wrote : | # |
The only amulet tests that are failing are kilo based tests.
Corey Bryant (corey.bryant) wrote : | # |
> The only amulet tests that are failing are kilo based tests.
And that is expected atm.
- 93. By Corey Bryant
-
Sync charm-helpers
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3451 cinder-next for corey.bryant mp254951
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3239 cinder-next for corey.bryant mp254951
UNIT OK: passed
Preview Diff
1 | === modified file 'Makefile' | |||
2 | --- Makefile 2015-02-19 11:51:46 +0000 | |||
3 | +++ Makefile 2015-04-16 14:41:14 +0000 | |||
4 | @@ -2,7 +2,7 @@ | |||
5 | 2 | PYTHON := /usr/bin/env python | 2 | PYTHON := /usr/bin/env python |
6 | 3 | 3 | ||
7 | 4 | lint: | 4 | lint: |
9 | 5 | @flake8 --exclude hooks/charmhelpers hooks unit_tests tests | 5 | @flake8 --exclude hooks/charmhelpers actions hooks unit_tests tests |
10 | 6 | @charm proof | 6 | @charm proof |
11 | 7 | 7 | ||
12 | 8 | unit_test: | 8 | unit_test: |
13 | @@ -14,7 +14,11 @@ | |||
14 | 14 | #NOTE(beisner): can remove -v after bug 1320357 is fixed | 14 | #NOTE(beisner): can remove -v after bug 1320357 is fixed |
15 | 15 | # https://bugs.launchpad.net/amulet/+bug/1320357 | 15 | # https://bugs.launchpad.net/amulet/+bug/1320357 |
16 | 16 | @juju test -v -p AMULET_HTTP_PROXY --timeout 900 \ | 16 | @juju test -v -p AMULET_HTTP_PROXY --timeout 900 \ |
18 | 17 | 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse | 17 | 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse \ |
19 | 18 | 16-basic-trusty-icehouse-git 17-basic-trusty-juno \ | ||
20 | 19 | 18-basic-trusty-juno-git 19-basic-trusty-kilo \ | ||
21 | 20 | 20-basic-trusty-kilo-git 21-basic-vivid-kilo \ | ||
22 | 21 | 22-basic-vivid-kilo-git | ||
23 | 18 | 22 | ||
24 | 19 | bin/charm_helpers_sync.py: | 23 | bin/charm_helpers_sync.py: |
25 | 20 | @mkdir -p bin | 24 | @mkdir -p bin |
26 | 21 | 25 | ||
27 | === modified file 'README.md' | |||
28 | --- README.md 2015-01-08 12:03:18 +0000 | |||
29 | +++ README.md 2015-04-16 14:41:14 +0000 | |||
30 | @@ -117,3 +117,94 @@ | |||
31 | 117 | 117 | ||
32 | 118 | enabled-services: Can be used to separate cinder services between service | 118 | enabled-services: Can be used to separate cinder services between service |
33 | 119 | service units (see previous section) | 119 | service units (see previous section) |
34 | 120 | |||
35 | 121 | Deploying from source | ||
36 | 122 | --------------------- | ||
37 | 123 | |||
38 | 124 | The minimum openstack-origin-git config required to deploy from source is: | ||
39 | 125 | |||
40 | 126 | openstack-origin-git: | ||
41 | 127 | "repositories: | ||
42 | 128 | - {name: requirements, | ||
43 | 129 | repository: 'git://git.openstack.org/openstack/requirements', | ||
44 | 130 | branch: stable/juno} | ||
45 | 131 | - {name: cinder, | ||
46 | 132 | repository: 'git://git.openstack.org/openstack/cinder', | ||
47 | 133 | branch: stable/juno}" | ||
48 | 134 | |||
49 | 135 | Note that there are only two 'name' values the charm knows about: 'requirements' | ||
50 | 136 | and 'cinder'. These repositories must correspond to these 'name' values. | ||
51 | 137 | Additionally, the requirements repository must be specified first and the | ||
52 | 138 | cinder repository must be specified last. All other repostories are installed | ||
53 | 139 | in the order in which they are specified. | ||
54 | 140 | |||
55 | 141 | The following is a full list of current tip repos (may not be up-to-date): | ||
56 | 142 | |||
57 | 143 | openstack-origin-git: | ||
58 | 144 | "repositories: | ||
59 | 145 | - {name: requirements, | ||
60 | 146 | repository: 'git://git.openstack.org/openstack/requirements', | ||
61 | 147 | branch: master} | ||
62 | 148 | - {name: oslo-concurrency, | ||
63 | 149 | repository: 'git://git.openstack.org/openstack/oslo.concurrency', | ||
64 | 150 | branch: master} | ||
65 | 151 | - {name: oslo-config, | ||
66 | 152 | repository: 'git://git.openstack.org/openstack/oslo.config', | ||
67 | 153 | branch: master} | ||
68 | 154 | - {name: oslo-context, | ||
69 | 155 | repository': 'git://git.openstack.org/openstack/oslo.context.git', | ||
70 | 156 | branch: master} | ||
71 | 157 | - {name: oslo-db, | ||
72 | 158 | repository: 'git://git.openstack.org/openstack/oslo.db', | ||
73 | 159 | branch: master} | ||
74 | 160 | - {name: oslo-i18n, | ||
75 | 161 | repository: 'git://git.openstack.org/openstack/oslo.i18n', | ||
76 | 162 | branch: master} | ||
77 | 163 | - {name: oslo-messaging, | ||
78 | 164 | repository: 'git://git.openstack.org/openstack/oslo.messaging.git', | ||
79 | 165 | branch: master} | ||
80 | 166 | - {name: oslo-serialization, | ||
81 | 167 | repository: 'git://git.openstack.org/openstack/oslo.serialization', | ||
82 | 168 | branch: master} | ||
83 | 169 | - {name: oslo-utils, | ||
84 | 170 | repository: 'git://git.openstack.org/openstack/oslo.utils', | ||
85 | 171 | branch: master} | ||
86 | 172 | - {name: oslo-rootwrap, | ||
87 | 173 | repository: 'git://git.openstack.org/openstack/oslo.rootwrap.git', | ||
88 | 174 | branch: master} | ||
89 | 175 | - {name: oslo-vmware, | ||
90 | 176 | repository: 'git://git.openstack.org/openstack/oslo.vmware.git', | ||
91 | 177 | branch: master} | ||
92 | 178 | - {name: osprofiler, | ||
93 | 179 | repository: 'git://git.openstack.org/stackforge/osprofiler.git', | ||
94 | 180 | branch: master} | ||
95 | 181 | - {name: pbr, | ||
96 | 182 | repository: 'git://git.openstack.org/openstack-dev/pbr', | ||
97 | 183 | branch: master} | ||
98 | 184 | - {name: python-barbicanclient, | ||
99 | 185 | repository: 'git://git.openstack.org/openstack/python-barbicanclient.git', | ||
100 | 186 | branch: master} | ||
101 | 187 | - {name: python-glanceclient, | ||
102 | 188 | repository: 'git://git.openstack.org/openstack/python-glanceclient.git', | ||
103 | 189 | branch: master} | ||
104 | 190 | - {name: python-novaclient, | ||
105 | 191 | repository: 'git://git.openstack.org/openstack/python-novaclient.git', | ||
106 | 192 | branch: master} | ||
107 | 193 | - {name: python-swiftclient: | ||
108 | 194 | repository: 'git://git.openstack.org/openstack/python-swiftclient.git', | ||
109 | 195 | branch: master} | ||
110 | 196 | - {name: sqlalchemy-migrate, | ||
111 | 197 | repository: 'git://git.openstack.org/stackforge/sqlalchemy-migrate', | ||
112 | 198 | branch: master} | ||
113 | 199 | - {name: stevedore, | ||
114 | 200 | repository: 'git://git.openstack.org/openstack/stevedore.git', | ||
115 | 201 | branch: master} | ||
116 | 202 | - {name: taskflow, | ||
117 | 203 | repository: 'git://git.openstack.org/openstack/taskflow.git', | ||
118 | 204 | branch: master} | ||
119 | 205 | - {name: keystonemiddleware, | ||
120 | 206 | repository: 'git://git.openstack.org/openstack/keystonemiddleware', | ||
121 | 207 | branch: master} | ||
122 | 208 | - {name: cinder, | ||
123 | 209 | repository: 'git://git.openstack.org/openstack/cinder', | ||
124 | 210 | branch: master}" | ||
125 | 120 | 211 | ||
126 | === added directory 'actions' | |||
127 | === added file 'actions.yaml' | |||
128 | --- actions.yaml 1970-01-01 00:00:00 +0000 | |||
129 | +++ actions.yaml 2015-04-16 14:41:14 +0000 | |||
130 | @@ -0,0 +1,2 @@ | |||
131 | 1 | git-reinstall: | ||
132 | 2 | description: Reinstall cinder from the openstack-origin-git repositories. | ||
133 | 0 | 3 | ||
134 | === added symlink 'actions/git-reinstall' | |||
135 | === target is u'git_reinstall.py' | |||
136 | === added file 'actions/git_reinstall.py' | |||
137 | --- actions/git_reinstall.py 1970-01-01 00:00:00 +0000 | |||
138 | +++ actions/git_reinstall.py 2015-04-16 14:41:14 +0000 | |||
139 | @@ -0,0 +1,45 @@ | |||
140 | 1 | #!/usr/bin/python | ||
141 | 2 | import sys | ||
142 | 3 | import traceback | ||
143 | 4 | |||
144 | 5 | sys.path.append('hooks/') | ||
145 | 6 | |||
146 | 7 | from charmhelpers.contrib.openstack.utils import ( | ||
147 | 8 | git_install_requested, | ||
148 | 9 | ) | ||
149 | 10 | |||
150 | 11 | from charmhelpers.core.hookenv import ( | ||
151 | 12 | action_set, | ||
152 | 13 | action_fail, | ||
153 | 14 | config, | ||
154 | 15 | ) | ||
155 | 16 | |||
156 | 17 | from cinder_utils import ( | ||
157 | 18 | git_install, | ||
158 | 19 | ) | ||
159 | 20 | |||
160 | 21 | from cinder_hooks import ( | ||
161 | 22 | config_changed, | ||
162 | 23 | ) | ||
163 | 24 | |||
164 | 25 | |||
165 | 26 | def git_reinstall(): | ||
166 | 27 | """Reinstall from source and restart services. | ||
167 | 28 | |||
168 | 29 | If the openstack-origin-git config option was used to install openstack | ||
169 | 30 | from source git repositories, then this action can be used to reinstall | ||
170 | 31 | from updated git repositories, followed by a restart of services.""" | ||
171 | 32 | if not git_install_requested(): | ||
172 | 33 | action_fail('openstack-origin-git is not configured') | ||
173 | 34 | return | ||
174 | 35 | |||
175 | 36 | try: | ||
176 | 37 | git_install(config('openstack-origin-git')) | ||
177 | 38 | config_changed() | ||
178 | 39 | except: | ||
179 | 40 | action_set({'traceback': traceback.format_exc()}) | ||
180 | 41 | action_fail('git-reinstall resulted in an unexpected error') | ||
181 | 42 | |||
182 | 43 | |||
183 | 44 | if __name__ == '__main__': | ||
184 | 45 | git_reinstall() | ||
185 | 0 | 46 | ||
186 | === modified file 'charm-helpers-hooks.yaml' | |||
187 | --- charm-helpers-hooks.yaml 2015-03-18 18:35:28 +0000 | |||
188 | +++ charm-helpers-hooks.yaml 2015-04-16 14:41:14 +0000 | |||
189 | @@ -1,4 +1,4 @@ | |||
191 | 1 | branch: lp:charm-helpers | 1 | branch: lp:charm-helpers |
192 | 2 | destination: hooks/charmhelpers | 2 | destination: hooks/charmhelpers |
193 | 3 | include: | 3 | include: |
194 | 4 | - core | 4 | - core |
195 | 5 | 5 | ||
196 | === modified file 'config.yaml' | |||
197 | --- config.yaml 2015-03-16 09:38:03 +0000 | |||
198 | +++ config.yaml 2015-04-16 14:41:14 +0000 | |||
199 | @@ -15,6 +15,22 @@ | |||
200 | 15 | the cloud:precise-folsom/updates repository instead, since Cinder | 15 | the cloud:precise-folsom/updates repository instead, since Cinder |
201 | 16 | was not available in the Ubuntu archive for Precise and is only | 16 | was not available in the Ubuntu archive for Precise and is only |
202 | 17 | available via the Ubuntu Cloud Archive. | 17 | available via the Ubuntu Cloud Archive. |
203 | 18 | |||
204 | 19 | Note that when openstack-origin-git is specified, openstack | ||
205 | 20 | specific packages will be installed from source rather than | ||
206 | 21 | from the openstack-origin repository. | ||
207 | 22 | openstack-origin-git: | ||
208 | 23 | default: | ||
209 | 24 | type: string | ||
210 | 25 | description: | | ||
211 | 26 | Specifies a YAML-formatted dictionary listing the git | ||
212 | 27 | repositories and branches from which to install OpenStack and | ||
213 | 28 | its dependencies. | ||
214 | 29 | |||
215 | 30 | Note that the installed config files will be determined based on | ||
216 | 31 | the OpenStack release of the openstack-origin option. | ||
217 | 32 | |||
218 | 33 | For more details see README.md. | ||
219 | 18 | enabled-services: | 34 | enabled-services: |
220 | 19 | default: all | 35 | default: all |
221 | 20 | type: string | 36 | type: string |
222 | 21 | 37 | ||
223 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' | |||
224 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-04-09 04:52:26 +0000 | |||
225 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-04-16 14:41:14 +0000 | |||
226 | @@ -524,9 +524,10 @@ | |||
227 | 524 | projects = yaml.load(projects_yaml) | 524 | projects = yaml.load(projects_yaml) |
228 | 525 | _git_validate_projects_yaml(projects, core_project) | 525 | _git_validate_projects_yaml(projects, core_project) |
229 | 526 | 526 | ||
230 | 527 | old_environ = dict(os.environ) | ||
231 | 528 | |||
232 | 527 | if 'http_proxy' in projects.keys(): | 529 | if 'http_proxy' in projects.keys(): |
233 | 528 | os.environ['http_proxy'] = projects['http_proxy'] | 530 | os.environ['http_proxy'] = projects['http_proxy'] |
234 | 529 | |||
235 | 530 | if 'https_proxy' in projects.keys(): | 531 | if 'https_proxy' in projects.keys(): |
236 | 531 | os.environ['https_proxy'] = projects['https_proxy'] | 532 | os.environ['https_proxy'] = projects['https_proxy'] |
237 | 532 | 533 | ||
238 | @@ -544,6 +545,8 @@ | |||
239 | 544 | repo_dir = _git_clone_and_install_single(repo, branch, parent_dir, | 545 | repo_dir = _git_clone_and_install_single(repo, branch, parent_dir, |
240 | 545 | update_requirements=True) | 546 | update_requirements=True) |
241 | 546 | 547 | ||
242 | 548 | os.environ = old_environ | ||
243 | 549 | |||
244 | 547 | 550 | ||
245 | 548 | def _git_validate_projects_yaml(projects, core_project): | 551 | def _git_validate_projects_yaml(projects, core_project): |
246 | 549 | """ | 552 | """ |
247 | 550 | 553 | ||
248 | === modified file 'hooks/cinder_hooks.py' | |||
249 | --- hooks/cinder_hooks.py 2015-03-31 08:37:22 +0000 | |||
250 | +++ hooks/cinder_hooks.py 2015-04-16 14:41:14 +0000 | |||
251 | @@ -10,6 +10,7 @@ | |||
252 | 10 | from cinder_utils import ( | 10 | from cinder_utils import ( |
253 | 11 | determine_packages, | 11 | determine_packages, |
254 | 12 | do_openstack_upgrade, | 12 | do_openstack_upgrade, |
255 | 13 | git_install, | ||
256 | 13 | juju_log, | 14 | juju_log, |
257 | 14 | migrate_database, | 15 | migrate_database, |
258 | 15 | configure_lvm_storage, | 16 | configure_lvm_storage, |
259 | @@ -53,10 +54,12 @@ | |||
260 | 53 | ) | 54 | ) |
261 | 54 | 55 | ||
262 | 55 | from charmhelpers.contrib.openstack.utils import ( | 56 | from charmhelpers.contrib.openstack.utils import ( |
263 | 57 | config_value_changed, | ||
264 | 56 | configure_installation_source, | 58 | configure_installation_source, |
265 | 59 | git_install_requested, | ||
266 | 57 | openstack_upgrade_available, | 60 | openstack_upgrade_available, |
267 | 58 | sync_db_with_multi_ipv6_addresses, | 61 | sync_db_with_multi_ipv6_addresses, |
269 | 59 | get_os_codename_package | 62 | os_release, |
270 | 60 | ) | 63 | ) |
271 | 61 | 64 | ||
272 | 62 | from charmhelpers.contrib.storage.linux.ceph import ( | 65 | from charmhelpers.contrib.storage.linux.ceph import ( |
273 | @@ -101,9 +104,12 @@ | |||
274 | 101 | src == 'distro'): | 104 | src == 'distro'): |
275 | 102 | src = 'cloud:precise-folsom' | 105 | src = 'cloud:precise-folsom' |
276 | 103 | configure_installation_source(src) | 106 | configure_installation_source(src) |
277 | 107 | |||
278 | 104 | apt_update() | 108 | apt_update() |
279 | 105 | apt_install(determine_packages(), fatal=True) | 109 | apt_install(determine_packages(), fatal=True) |
280 | 106 | 110 | ||
281 | 111 | git_install(config('openstack-origin-git')) | ||
282 | 112 | |||
283 | 107 | 113 | ||
284 | 108 | @hooks.hook('config-changed') | 114 | @hooks.hook('config-changed') |
285 | 109 | @restart_on_change(restart_map(), stopstart=True) | 115 | @restart_on_change(restart_map(), stopstart=True) |
286 | @@ -123,12 +129,16 @@ | |||
287 | 123 | conf['overwrite'] in ['true', 'True', True], | 129 | conf['overwrite'] in ['true', 'True', True], |
288 | 124 | conf['remove-missing']) | 130 | conf['remove-missing']) |
289 | 125 | 131 | ||
296 | 126 | if openstack_upgrade_available('cinder-common'): | 132 | if git_install_requested(): |
297 | 127 | do_openstack_upgrade(configs=CONFIGS) | 133 | if config_value_changed('openstack-origin-git'): |
298 | 128 | # NOTE(jamespage) tell any storage-backends we just upgraded | 134 | git_install(config('openstack-origin-git')) |
299 | 129 | for rid in relation_ids('storage-backend'): | 135 | else: |
300 | 130 | relation_set(relation_id=rid, | 136 | if openstack_upgrade_available('cinder-common'): |
301 | 131 | upgrade_nonce=uuid.uuid4()) | 137 | do_openstack_upgrade(configs=CONFIGS) |
302 | 138 | # NOTE(jamespage) tell any storage-backends we just upgraded | ||
303 | 139 | for rid in relation_ids('storage-backend'): | ||
304 | 140 | relation_set(relation_id=rid, | ||
305 | 141 | upgrade_nonce=uuid.uuid4()) | ||
306 | 132 | 142 | ||
307 | 133 | CONFIGS.write_all() | 143 | CONFIGS.write_all() |
308 | 134 | configure_https() | 144 | configure_https() |
309 | @@ -255,7 +265,7 @@ | |||
310 | 255 | 'cinder_internal_url': internal_url, | 265 | 'cinder_internal_url': internal_url, |
311 | 256 | 'cinder_admin_url': admin_url, | 266 | 'cinder_admin_url': admin_url, |
312 | 257 | } | 267 | } |
314 | 258 | if get_os_codename_package('cinder-common') >= 'icehouse': | 268 | if os_release('cinder-common') >= 'icehouse': |
315 | 259 | # NOTE(jamespage) register v2 endpoint as well | 269 | # NOTE(jamespage) register v2 endpoint as well |
316 | 260 | public_url = '{}:{}/v2/$(tenant_id)s'.format( | 270 | public_url = '{}:{}/v2/$(tenant_id)s'.format( |
317 | 261 | canonical_url(CONFIGS, PUBLIC), | 271 | canonical_url(CONFIGS, PUBLIC), |
318 | 262 | 272 | ||
319 | === modified file 'hooks/cinder_utils.py' | |||
320 | --- hooks/cinder_utils.py 2015-04-09 03:10:16 +0000 | |||
321 | +++ hooks/cinder_utils.py 2015-04-16 14:41:14 +0000 | |||
322 | @@ -1,10 +1,12 @@ | |||
323 | 1 | import os | 1 | import os |
324 | 2 | import shutil | ||
325 | 2 | import subprocess | 3 | import subprocess |
326 | 3 | 4 | ||
327 | 4 | from collections import OrderedDict | 5 | from collections import OrderedDict |
328 | 5 | from copy import copy | 6 | from copy import copy |
329 | 6 | 7 | ||
330 | 7 | from charmhelpers.core.hookenv import ( | 8 | from charmhelpers.core.hookenv import ( |
331 | 9 | charm_dir, | ||
332 | 8 | config, | 10 | config, |
333 | 9 | relation_ids, | 11 | relation_ids, |
334 | 10 | log, | 12 | log, |
335 | @@ -19,12 +21,17 @@ | |||
336 | 19 | ) | 21 | ) |
337 | 20 | 22 | ||
338 | 21 | from charmhelpers.core.host import ( | 23 | from charmhelpers.core.host import ( |
339 | 24 | adduser, | ||
340 | 25 | add_group, | ||
341 | 26 | add_user_to_group, | ||
342 | 27 | lsb_release, | ||
343 | 28 | mkdir, | ||
344 | 22 | mounts, | 29 | mounts, |
345 | 23 | umount, | 30 | umount, |
346 | 31 | service_restart, | ||
347 | 24 | service_stop, | 32 | service_stop, |
348 | 25 | service_start, | 33 | service_start, |
351 | 26 | mkdir, | 34 | write_file, |
350 | 27 | lsb_release | ||
352 | 28 | ) | 35 | ) |
353 | 29 | 36 | ||
354 | 30 | from charmhelpers.contrib.openstack.alternatives import install_alternative | 37 | from charmhelpers.contrib.openstack.alternatives import install_alternative |
355 | @@ -58,10 +65,15 @@ | |||
356 | 58 | 65 | ||
357 | 59 | from charmhelpers.contrib.openstack.utils import ( | 66 | from charmhelpers.contrib.openstack.utils import ( |
358 | 60 | configure_installation_source, | 67 | configure_installation_source, |
359 | 61 | get_os_codename_package, | ||
360 | 62 | get_os_codename_install_source, | 68 | get_os_codename_install_source, |
361 | 69 | git_install_requested, | ||
362 | 70 | git_clone_and_install, | ||
363 | 71 | git_src_dir, | ||
364 | 72 | os_release, | ||
365 | 63 | ) | 73 | ) |
366 | 64 | 74 | ||
367 | 75 | from charmhelpers.core.templating import render | ||
368 | 76 | |||
369 | 65 | import cinder_contexts | 77 | import cinder_contexts |
370 | 66 | 78 | ||
371 | 67 | COMMON_PACKAGES = [ | 79 | COMMON_PACKAGES = [ |
372 | @@ -81,6 +93,25 @@ | |||
373 | 81 | VOLUME_PACKAGES = ['cinder-volume'] | 93 | VOLUME_PACKAGES = ['cinder-volume'] |
374 | 82 | SCHEDULER_PACKAGES = ['cinder-scheduler'] | 94 | SCHEDULER_PACKAGES = ['cinder-scheduler'] |
375 | 83 | 95 | ||
376 | 96 | BASE_GIT_PACKAGES = [ | ||
377 | 97 | 'libxml2-dev', | ||
378 | 98 | 'libxslt1-dev', | ||
379 | 99 | 'lvm2', | ||
380 | 100 | 'python-dev', | ||
381 | 101 | 'python-pip', | ||
382 | 102 | 'python-setuptools', | ||
383 | 103 | 'zlib1g-dev', | ||
384 | 104 | ] | ||
385 | 105 | |||
386 | 106 | # ubuntu packages that should not be installed when deploying from source | ||
387 | 107 | GIT_PACKAGE_BLACKLIST = [ | ||
388 | 108 | 'cinder-api', | ||
389 | 109 | 'cinder-common', | ||
390 | 110 | 'cinder-scheduler', | ||
391 | 111 | 'cinder-volume', | ||
392 | 112 | 'python-keystoneclient', | ||
393 | 113 | ] | ||
394 | 114 | |||
395 | 84 | DEFAULT_LOOPBACK_SIZE = '5G' | 115 | DEFAULT_LOOPBACK_SIZE = '5G' |
396 | 85 | 116 | ||
397 | 86 | # Cluster resource used to determine leadership when hacluster'd | 117 | # Cluster resource used to determine leadership when hacluster'd |
398 | @@ -166,7 +197,7 @@ | |||
399 | 166 | # if called without anything installed (eg during install hook) | 197 | # if called without anything installed (eg during install hook) |
400 | 167 | # just default to earliest supported release. configs dont get touched | 198 | # just default to earliest supported release. configs dont get touched |
401 | 168 | # till post-install, anyway. | 199 | # till post-install, anyway. |
403 | 169 | release = get_os_codename_package('cinder-common', fatal=False) or 'folsom' | 200 | release = os_release('cinder-common', base='folsom') |
404 | 170 | configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, | 201 | configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, |
405 | 171 | openstack_release=release) | 202 | openstack_release=release) |
406 | 172 | 203 | ||
407 | @@ -218,6 +249,13 @@ | |||
408 | 218 | ('scheduler', SCHEDULER_PACKAGES)]: | 249 | ('scheduler', SCHEDULER_PACKAGES)]: |
409 | 219 | if service_enabled(s): | 250 | if service_enabled(s): |
410 | 220 | pkgs += p | 251 | pkgs += p |
411 | 252 | |||
412 | 253 | if git_install_requested(): | ||
413 | 254 | pkgs.extend(BASE_GIT_PACKAGES) | ||
414 | 255 | # don't include packages that will be installed from git | ||
415 | 256 | for p in GIT_PACKAGE_BLACKLIST: | ||
416 | 257 | pkgs.remove(p) | ||
417 | 258 | |||
418 | 221 | return pkgs | 259 | return pkgs |
419 | 222 | 260 | ||
420 | 223 | 261 | ||
421 | @@ -467,3 +505,142 @@ | |||
422 | 467 | ' main') | 505 | ' main') |
423 | 468 | apt_update() | 506 | apt_update() |
424 | 469 | apt_install('haproxy/trusty-backports', fatal=True) | 507 | apt_install('haproxy/trusty-backports', fatal=True) |
425 | 508 | |||
426 | 509 | |||
427 | 510 | def git_install(projects_yaml): | ||
428 | 511 | """Perform setup, and install git repos specified in yaml parameter.""" | ||
429 | 512 | if git_install_requested(): | ||
430 | 513 | git_pre_install() | ||
431 | 514 | git_clone_and_install(projects_yaml, core_project='cinder') | ||
432 | 515 | git_post_install(projects_yaml) | ||
433 | 516 | |||
434 | 517 | |||
435 | 518 | def git_pre_install(): | ||
436 | 519 | """Perform cinder pre-install setup.""" | ||
437 | 520 | dirs = [{'path': '/etc/tgt', | ||
438 | 521 | 'owner': 'cinder', | ||
439 | 522 | 'group': 'cinder', | ||
440 | 523 | 'perms': 0750, | ||
441 | 524 | }, | ||
442 | 525 | {'path': '/var/lib/cinder', | ||
443 | 526 | 'owner': 'cinder', | ||
444 | 527 | 'group': 'cinder', | ||
445 | 528 | 'perms': 0755, | ||
446 | 529 | }, | ||
447 | 530 | {'path': '/var/lib/cinder/volumes', | ||
448 | 531 | 'owner': 'cinder', | ||
449 | 532 | 'group': 'cinder', | ||
450 | 533 | 'perms': 0750, | ||
451 | 534 | }, | ||
452 | 535 | {'path': '/var/lock/cinder', | ||
453 | 536 | 'owner': 'cinder', | ||
454 | 537 | 'group': 'root', | ||
455 | 538 | 'perms': 0750, | ||
456 | 539 | }, | ||
457 | 540 | {'path': '/var/log/cinder', | ||
458 | 541 | 'owner': 'cinder', | ||
459 | 542 | 'group': 'cinder', | ||
460 | 543 | 'perms': 0750, | ||
461 | 544 | }] | ||
462 | 545 | |||
463 | 546 | logs = [ | ||
464 | 547 | '/var/log/cinder/cinder-api.log', | ||
465 | 548 | '/var/log/cinder/cinder-backup.log', | ||
466 | 549 | '/var/log/cinder/cinder-scheduler.log', | ||
467 | 550 | '/var/log/cinder/cinder-volume.log', | ||
468 | 551 | ] | ||
469 | 552 | |||
470 | 553 | adduser('cinder', shell='/bin/bash', system_user=True) | ||
471 | 554 | add_group('cinder', system_group=True) | ||
472 | 555 | add_user_to_group('cinder', 'cinder') | ||
473 | 556 | |||
474 | 557 | for d in dirs: | ||
475 | 558 | mkdir(d['path'], owner=d['owner'], group=d['group'], perms=d['perms'], | ||
476 | 559 | force=False) | ||
477 | 560 | |||
478 | 561 | for l in logs: | ||
479 | 562 | write_file(l, '', owner='cinder', group='cinder', perms=0600) | ||
480 | 563 | |||
481 | 564 | |||
482 | 565 | def git_post_install(projects_yaml): | ||
483 | 566 | """Perform cinder post-install setup.""" | ||
484 | 567 | src_etc = os.path.join(git_src_dir(projects_yaml, 'cinder'), 'etc/cinder') | ||
485 | 568 | configs = { | ||
486 | 569 | 'src': src_etc, | ||
487 | 570 | 'dest': '/etc/cinder', | ||
488 | 571 | } | ||
489 | 572 | |||
490 | 573 | if os.path.exists(configs['dest']): | ||
491 | 574 | shutil.rmtree(configs['dest']) | ||
492 | 575 | shutil.copytree(configs['src'], configs['dest']) | ||
493 | 576 | |||
494 | 577 | render('cinder.conf', '/etc/cinder/cinder.conf', {}, owner='cinder', | ||
495 | 578 | group='cinder', perms=0o644) | ||
496 | 579 | render('git/cinder_tgt.conf', '/etc/tgt/conf.d', {}, owner='cinder', | ||
497 | 580 | group='cinder', perms=0o644) | ||
498 | 581 | render('git/logging.conf', '/etc/cinder/logging.conf', {}, owner='cinder', | ||
499 | 582 | group='cinder', perms=0o644) | ||
500 | 583 | render('git/cinder_sudoers', '/etc/sudoers.d/cinder_sudoers', {}, | ||
501 | 584 | owner='root', group='root', perms=0o440) | ||
502 | 585 | |||
503 | 586 | os.chmod('/etc/sudoers.d', 0o750) | ||
504 | 587 | |||
505 | 588 | cinder_api_context = { | ||
506 | 589 | 'service_description': 'Cinder API server', | ||
507 | 590 | 'service_name': 'Cinder', | ||
508 | 591 | 'user_name': 'cinder', | ||
509 | 592 | 'start_dir': '/var/lib/cinder', | ||
510 | 593 | 'process_name': 'cinder-api', | ||
511 | 594 | 'executable_name': '/usr/local/bin/cinder-api', | ||
512 | 595 | 'config_files': ['/etc/cinder/cinder.conf'], | ||
513 | 596 | 'log_file': '/var/log/cinder/cinder-api.log', | ||
514 | 597 | } | ||
515 | 598 | |||
516 | 599 | cinder_backup_context = { | ||
517 | 600 | 'service_description': 'Cinder backup server', | ||
518 | 601 | 'service_name': 'Cinder', | ||
519 | 602 | 'user_name': 'cinder', | ||
520 | 603 | 'start_dir': '/var/lib/cinder', | ||
521 | 604 | 'process_name': 'cinder-backup', | ||
522 | 605 | 'executable_name': '/usr/local/bin/cinder-backup', | ||
523 | 606 | 'config_files': ['/etc/cinder/cinder.conf'], | ||
524 | 607 | 'log_file': '/var/log/cinder/cinder-backup.log', | ||
525 | 608 | } | ||
526 | 609 | |||
527 | 610 | cinder_scheduler_context = { | ||
528 | 611 | 'service_description': 'Cinder scheduler server', | ||
529 | 612 | 'service_name': 'Cinder', | ||
530 | 613 | 'user_name': 'cinder', | ||
531 | 614 | 'start_dir': '/var/lib/cinder', | ||
532 | 615 | 'process_name': 'cinder-scheduler', | ||
533 | 616 | 'executable_name': '/usr/local/bin/cinder-scheduler', | ||
534 | 617 | 'config_files': ['/etc/cinder/cinder.conf'], | ||
535 | 618 | 'log_file': '/var/log/cinder/cinder-scheduler.log', | ||
536 | 619 | } | ||
537 | 620 | |||
538 | 621 | cinder_volume_context = { | ||
539 | 622 | 'service_description': 'Cinder volume server', | ||
540 | 623 | 'service_name': 'Cinder', | ||
541 | 624 | 'user_name': 'cinder', | ||
542 | 625 | 'start_dir': '/var/lib/cinder', | ||
543 | 626 | 'process_name': 'cinder-volume', | ||
544 | 627 | 'executable_name': '/usr/local/bin/cinder-volume', | ||
545 | 628 | 'config_files': ['/etc/cinder/cinder.conf'], | ||
546 | 629 | 'log_file': '/var/log/cinder/cinder-volume.log', | ||
547 | 630 | } | ||
548 | 631 | |||
549 | 632 | # NOTE(coreycb): Needs systemd support | ||
550 | 633 | templates_dir = 'hooks/charmhelpers/contrib/openstack/templates' | ||
551 | 634 | templates_dir = os.path.join(charm_dir(), templates_dir) | ||
552 | 635 | render('git.upstart', '/etc/init/cinder-api.conf', | ||
553 | 636 | cinder_api_context, perms=0o644, templates_dir=templates_dir) | ||
554 | 637 | render('git.upstart', '/etc/init/cinder-backup.conf', | ||
555 | 638 | cinder_backup_context, perms=0o644, templates_dir=templates_dir) | ||
556 | 639 | render('git.upstart', '/etc/init/cinder-scheduler.conf', | ||
557 | 640 | cinder_scheduler_context, perms=0o644, templates_dir=templates_dir) | ||
558 | 641 | render('git.upstart', '/etc/init/cinder-volume.conf', | ||
559 | 642 | cinder_volume_context, perms=0o644, templates_dir=templates_dir) | ||
560 | 643 | |||
561 | 644 | service_restart('tgtd') | ||
562 | 645 | |||
563 | 646 | [service_restart(s) for s in services()] | ||
564 | 470 | 647 | ||
565 | === added directory 'templates/git' | |||
566 | === added file 'templates/git/cinder_sudoers' | |||
567 | --- templates/git/cinder_sudoers 1970-01-01 00:00:00 +0000 | |||
568 | +++ templates/git/cinder_sudoers 2015-04-16 14:41:14 +0000 | |||
569 | @@ -0,0 +1,4 @@ | |||
570 | 1 | Defaults:cinder !requiretty | ||
571 | 2 | |||
572 | 3 | cinder ALL = (root) NOPASSWD: /usr/local/bin/cinder-rootwrap /etc/cinder/rootwrap.conf * | ||
573 | 4 | |||
574 | 0 | 5 | ||
575 | === added file 'templates/git/cinder_tgt.conf' | |||
576 | --- templates/git/cinder_tgt.conf 1970-01-01 00:00:00 +0000 | |||
577 | +++ templates/git/cinder_tgt.conf 2015-04-16 14:41:14 +0000 | |||
578 | @@ -0,0 +1,1 @@ | |||
579 | 1 | include /var/lib/cinder/volumes/* | ||
580 | 0 | 2 | ||
581 | === added file 'templates/git/logging.conf' | |||
582 | --- templates/git/logging.conf 1970-01-01 00:00:00 +0000 | |||
583 | +++ templates/git/logging.conf 2015-04-16 14:41:14 +0000 | |||
584 | @@ -0,0 +1,76 @@ | |||
585 | 1 | [loggers] | ||
586 | 2 | keys = root, cinder | ||
587 | 3 | |||
588 | 4 | [handlers] | ||
589 | 5 | keys = stderr, stdout, watchedfile, syslog, null | ||
590 | 6 | |||
591 | 7 | [formatters] | ||
592 | 8 | keys = legacycinder, default | ||
593 | 9 | |||
594 | 10 | [logger_root] | ||
595 | 11 | level = WARNING | ||
596 | 12 | handlers = null | ||
597 | 13 | |||
598 | 14 | [logger_cinder] | ||
599 | 15 | level = INFO | ||
600 | 16 | handlers = stderr | ||
601 | 17 | qualname = cinder | ||
602 | 18 | |||
603 | 19 | [logger_amqplib] | ||
604 | 20 | level = WARNING | ||
605 | 21 | handlers = stderr | ||
606 | 22 | qualname = amqplib | ||
607 | 23 | |||
608 | 24 | [logger_sqlalchemy] | ||
609 | 25 | level = WARNING | ||
610 | 26 | handlers = stderr | ||
611 | 27 | qualname = sqlalchemy | ||
612 | 28 | # "level = INFO" logs SQL queries. | ||
613 | 29 | # "level = DEBUG" logs SQL queries and results. | ||
614 | 30 | # "level = WARNING" logs neither. (Recommended for production systems.) | ||
615 | 31 | |||
616 | 32 | [logger_boto] | ||
617 | 33 | level = WARNING | ||
618 | 34 | handlers = stderr | ||
619 | 35 | qualname = boto | ||
620 | 36 | |||
621 | 37 | [logger_suds] | ||
622 | 38 | level = INFO | ||
623 | 39 | handlers = stderr | ||
624 | 40 | qualname = suds | ||
625 | 41 | |||
626 | 42 | [logger_eventletwsgi] | ||
627 | 43 | level = WARNING | ||
628 | 44 | handlers = stderr | ||
629 | 45 | qualname = eventlet.wsgi.server | ||
630 | 46 | |||
631 | 47 | [handler_stderr] | ||
632 | 48 | class = StreamHandler | ||
633 | 49 | args = (sys.stderr,) | ||
634 | 50 | formatter = legacycinder | ||
635 | 51 | |||
636 | 52 | [handler_stdout] | ||
637 | 53 | class = StreamHandler | ||
638 | 54 | args = (sys.stdout,) | ||
639 | 55 | formatter = legacycinder | ||
640 | 56 | |||
641 | 57 | [handler_watchedfile] | ||
642 | 58 | class = handlers.WatchedFileHandler | ||
643 | 59 | args = ('cinder.log',) | ||
644 | 60 | formatter = legacycinder | ||
645 | 61 | |||
646 | 62 | [handler_syslog] | ||
647 | 63 | class = handlers.SysLogHandler | ||
648 | 64 | args = ('/dev/log', handlers.SysLogHandler.LOG_USER) | ||
649 | 65 | formatter = legacycinder | ||
650 | 66 | |||
651 | 67 | [handler_null] | ||
652 | 68 | class = cinder.log.NullHandler | ||
653 | 69 | formatter = default | ||
654 | 70 | args = () | ||
655 | 71 | |||
656 | 72 | [formatter_legacycinder] | ||
657 | 73 | class = cinder.log.LegacyCinderFormatter | ||
658 | 74 | |||
659 | 75 | [formatter_default] | ||
660 | 76 | format = %(message)s | ||
661 | 0 | 77 | ||
662 | === modified file 'tests/00-setup' | |||
663 | --- tests/00-setup 2014-10-07 18:32:59 +0000 | |||
664 | +++ tests/00-setup 2015-04-16 14:41:14 +0000 | |||
665 | @@ -5,6 +5,7 @@ | |||
666 | 5 | sudo add-apt-repository --yes ppa:juju/stable | 5 | sudo add-apt-repository --yes ppa:juju/stable |
667 | 6 | sudo apt-get update --yes | 6 | sudo apt-get update --yes |
668 | 7 | sudo apt-get install --yes python-amulet \ | 7 | sudo apt-get install --yes python-amulet \ |
669 | 8 | python-cinderclient \ | ||
670 | 9 | python-glanceclient \ | ||
671 | 8 | python-keystoneclient \ | 10 | python-keystoneclient \ |
674 | 9 | python-cinderclient \ | 11 | python-novaclient |
673 | 10 | python-glanceclient | ||
675 | 11 | 12 | ||
676 | === removed file 'tests/11-basic-precise-folsom' | |||
677 | --- tests/11-basic-precise-folsom 2014-07-31 15:27:14 +0000 | |||
678 | +++ tests/11-basic-precise-folsom 1970-01-01 00:00:00 +0000 | |||
679 | @@ -1,11 +0,0 @@ | |||
680 | 1 | #!/usr/bin/python | ||
681 | 2 | |||
682 | 3 | """Amulet tests on a basic cinder deployment on precise-folsom.""" | ||
683 | 4 | |||
684 | 5 | from basic_deployment import CinderBasicDeployment | ||
685 | 6 | |||
686 | 7 | if __name__ == '__main__': | ||
687 | 8 | deployment = CinderBasicDeployment(series='precise', | ||
688 | 9 | openstack='cloud:precise-folsom', | ||
689 | 10 | source='cloud:precise-updates/folsom') | ||
690 | 11 | deployment.run_tests() | ||
691 | 12 | 0 | ||
692 | === removed file 'tests/12-basic-precise-grizzly' | |||
693 | --- tests/12-basic-precise-grizzly 2014-07-31 15:27:14 +0000 | |||
694 | +++ tests/12-basic-precise-grizzly 1970-01-01 00:00:00 +0000 | |||
695 | @@ -1,11 +0,0 @@ | |||
696 | 1 | #!/usr/bin/python | ||
697 | 2 | |||
698 | 3 | """Amulet tests on a basic cinder deployment on precise-grizzly.""" | ||
699 | 4 | |||
700 | 5 | from basic_deployment import CinderBasicDeployment | ||
701 | 6 | |||
702 | 7 | if __name__ == '__main__': | ||
703 | 8 | deployment = CinderBasicDeployment(series='precise', | ||
704 | 9 | openstack='cloud:precise-grizzly', | ||
705 | 10 | source='cloud:precise-updates/grizzly') | ||
706 | 11 | deployment.run_tests() | ||
707 | 12 | 0 | ||
708 | === removed file 'tests/13-basic-precise-havana' | |||
709 | --- tests/13-basic-precise-havana 2014-07-31 15:27:14 +0000 | |||
710 | +++ tests/13-basic-precise-havana 1970-01-01 00:00:00 +0000 | |||
711 | @@ -1,11 +0,0 @@ | |||
712 | 1 | #!/usr/bin/python | ||
713 | 2 | |||
714 | 3 | """Amulet tests on a basic cinder deployment on precise-havana.""" | ||
715 | 4 | |||
716 | 5 | from basic_deployment import CinderBasicDeployment | ||
717 | 6 | |||
718 | 7 | if __name__ == '__main__': | ||
719 | 8 | deployment = CinderBasicDeployment(series='precise', | ||
720 | 9 | openstack='cloud:precise-havana', | ||
721 | 10 | source='cloud:precise-updates/havana') | ||
722 | 11 | deployment.run_tests() | ||
723 | 12 | 0 | ||
724 | === added file 'tests/16-basic-trusty-icehouse-git' | |||
725 | --- tests/16-basic-trusty-icehouse-git 1970-01-01 00:00:00 +0000 | |||
726 | +++ tests/16-basic-trusty-icehouse-git 2015-04-16 14:41:14 +0000 | |||
727 | @@ -0,0 +1,9 @@ | |||
728 | 1 | #!/usr/bin/python | ||
729 | 2 | |||
730 | 3 | """Amulet tests on a basic Cinder git deployment on trusty-icehouse.""" | ||
731 | 4 | |||
732 | 5 | from basic_deployment import CinderBasicDeployment | ||
733 | 6 | |||
734 | 7 | if __name__ == '__main__': | ||
735 | 8 | deployment = CinderBasicDeployment(series='trusty', git=True) | ||
736 | 9 | deployment.run_tests() | ||
737 | 0 | 10 | ||
738 | === removed file 'tests/16-basic-vivid-kilo' | |||
739 | --- tests/16-basic-vivid-kilo 2015-04-13 19:33:14 +0000 | |||
740 | +++ tests/16-basic-vivid-kilo 1970-01-01 00:00:00 +0000 | |||
741 | @@ -1,9 +0,0 @@ | |||
742 | 1 | #!/usr/bin/python | ||
743 | 2 | |||
744 | 3 | """Amulet tests on a basic Cinder deployment on vivid-kilo.""" | ||
745 | 4 | |||
746 | 5 | from basic_deployment import CinderBasicDeployment | ||
747 | 6 | |||
748 | 7 | if __name__ == '__main__': | ||
749 | 8 | deployment = CinderBasicDeployment(series='vivid') | ||
750 | 9 | deployment.run_tests() | ||
751 | 10 | 0 | ||
752 | === added file 'tests/17-basic-trusty-juno' | |||
753 | --- tests/17-basic-trusty-juno 1970-01-01 00:00:00 +0000 | |||
754 | +++ tests/17-basic-trusty-juno 2015-04-16 14:41:14 +0000 | |||
755 | @@ -0,0 +1,11 @@ | |||
756 | 1 | #!/usr/bin/python | ||
757 | 2 | |||
758 | 3 | """Amulet tests on a basic Cinder deployment on trusty-juno.""" | ||
759 | 4 | |||
760 | 5 | from basic_deployment import CinderBasicDeployment | ||
761 | 6 | |||
762 | 7 | if __name__ == '__main__': | ||
763 | 8 | deployment = CinderBasicDeployment(series='trusty', | ||
764 | 9 | openstack='cloud:trusty-juno', | ||
765 | 10 | source='cloud:trusty-updates/juno') | ||
766 | 11 | deployment.run_tests() | ||
767 | 0 | 12 | ||
768 | === removed file 'tests/17-basic-trusty-kilo' | |||
769 | --- tests/17-basic-trusty-kilo 2015-04-13 19:33:14 +0000 | |||
770 | +++ tests/17-basic-trusty-kilo 1970-01-01 00:00:00 +0000 | |||
771 | @@ -1,11 +0,0 @@ | |||
772 | 1 | #!/usr/bin/python | ||
773 | 2 | |||
774 | 3 | """Amulet tests on a basic cinder deployment on trusty-kilo.""" | ||
775 | 4 | |||
776 | 5 | from basic_deployment import CinderBasicDeployment | ||
777 | 6 | |||
778 | 7 | if __name__ == '__main__': | ||
779 | 8 | deployment = CinderBasicDeployment(series='trusty', | ||
780 | 9 | openstack='cloud:trusty-kilo', | ||
781 | 10 | source='cloud:trusty-updates/kilo') | ||
782 | 11 | deployment.run_tests() | ||
783 | 12 | 0 | ||
784 | === added file 'tests/18-basic-trusty-juno-git' | |||
785 | --- tests/18-basic-trusty-juno-git 1970-01-01 00:00:00 +0000 | |||
786 | +++ tests/18-basic-trusty-juno-git 2015-04-16 14:41:14 +0000 | |||
787 | @@ -0,0 +1,12 @@ | |||
788 | 1 | #!/usr/bin/python | ||
789 | 2 | |||
790 | 3 | """Amulet tests on a basic Cinder git deployment on trusty-juno.""" | ||
791 | 4 | |||
792 | 5 | from basic_deployment import CinderBasicDeployment | ||
793 | 6 | |||
794 | 7 | if __name__ == '__main__': | ||
795 | 8 | deployment = CinderBasicDeployment(series='trusty', | ||
796 | 9 | openstack='cloud:trusty-juno', | ||
797 | 10 | source='cloud:trusty-updates/juno', | ||
798 | 11 | git=True) | ||
799 | 12 | deployment.run_tests() | ||
800 | 0 | 13 | ||
801 | === added file 'tests/19-basic-trusty-kilo' | |||
802 | --- tests/19-basic-trusty-kilo 1970-01-01 00:00:00 +0000 | |||
803 | +++ tests/19-basic-trusty-kilo 2015-04-16 14:41:14 +0000 | |||
804 | @@ -0,0 +1,11 @@ | |||
805 | 1 | #!/usr/bin/python | ||
806 | 2 | |||
807 | 3 | """Amulet tests on a basic cinder deployment on trusty-kilo.""" | ||
808 | 4 | |||
809 | 5 | from basic_deployment import CinderBasicDeployment | ||
810 | 6 | |||
811 | 7 | if __name__ == '__main__': | ||
812 | 8 | deployment = CinderBasicDeployment(series='trusty', | ||
813 | 9 | openstack='cloud:trusty-kilo', | ||
814 | 10 | source='cloud:trusty-updates/kilo') | ||
815 | 11 | deployment.run_tests() | ||
816 | 0 | 12 | ||
817 | === added file 'tests/20-basic-trusty-kilo-git' | |||
818 | --- tests/20-basic-trusty-kilo-git 1970-01-01 00:00:00 +0000 | |||
819 | +++ tests/20-basic-trusty-kilo-git 2015-04-16 14:41:14 +0000 | |||
820 | @@ -0,0 +1,12 @@ | |||
821 | 1 | #!/usr/bin/python | ||
822 | 2 | |||
823 | 3 | """Amulet tests on a basic cinder git deployment on trusty-kilo.""" | ||
824 | 4 | |||
825 | 5 | from basic_deployment import CinderBasicDeployment | ||
826 | 6 | |||
827 | 7 | if __name__ == '__main__': | ||
828 | 8 | deployment = CinderBasicDeployment(series='trusty', | ||
829 | 9 | openstack='cloud:trusty-kilo', | ||
830 | 10 | source='cloud:trusty-updates/kilo', | ||
831 | 11 | git=True) | ||
832 | 12 | deployment.run_tests() | ||
833 | 0 | 13 | ||
834 | === added file 'tests/21-basic-vivid-kilo' | |||
835 | --- tests/21-basic-vivid-kilo 1970-01-01 00:00:00 +0000 | |||
836 | +++ tests/21-basic-vivid-kilo 2015-04-16 14:41:14 +0000 | |||
837 | @@ -0,0 +1,9 @@ | |||
838 | 1 | #!/usr/bin/python | ||
839 | 2 | |||
840 | 3 | """Amulet tests on a basic Cinder deployment on vivid-kilo.""" | ||
841 | 4 | |||
842 | 5 | from basic_deployment import CinderBasicDeployment | ||
843 | 6 | |||
844 | 7 | if __name__ == '__main__': | ||
845 | 8 | deployment = CinderBasicDeployment(series='vivid') | ||
846 | 9 | deployment.run_tests() | ||
847 | 0 | 10 | ||
848 | === added file 'tests/22-basic-vivid-kilo-git' | |||
849 | --- tests/22-basic-vivid-kilo-git 1970-01-01 00:00:00 +0000 | |||
850 | +++ tests/22-basic-vivid-kilo-git 2015-04-16 14:41:14 +0000 | |||
851 | @@ -0,0 +1,9 @@ | |||
852 | 1 | #!/usr/bin/python | ||
853 | 2 | |||
854 | 3 | """Amulet tests on a basic Cinder git deployment on vivid-kilo.""" | ||
855 | 4 | |||
856 | 5 | from basic_deployment import CinderBasicDeployment | ||
857 | 6 | |||
858 | 7 | if __name__ == '__main__': | ||
859 | 8 | deployment = CinderBasicDeployment(series='vivid', git=True) | ||
860 | 9 | deployment.run_tests() | ||
861 | 0 | 10 | ||
862 | === modified file 'tests/basic_deployment.py' | |||
863 | --- tests/basic_deployment.py 2015-04-13 19:39:27 +0000 | |||
864 | +++ tests/basic_deployment.py 2015-04-16 14:41:14 +0000 | |||
865 | @@ -1,8 +1,10 @@ | |||
866 | 1 | #!/usr/bin/python | 1 | #!/usr/bin/python |
867 | 2 | 2 | ||
868 | 3 | import amulet | 3 | import amulet |
869 | 4 | import os | ||
870 | 4 | import types | 5 | import types |
871 | 5 | from time import sleep | 6 | from time import sleep |
872 | 7 | import yaml | ||
873 | 6 | import cinderclient.v1.client as cinder_client | 8 | import cinderclient.v1.client as cinder_client |
874 | 7 | 9 | ||
875 | 8 | from charmhelpers.contrib.openstack.amulet.deployment import ( | 10 | from charmhelpers.contrib.openstack.amulet.deployment import ( |
876 | @@ -28,10 +30,12 @@ | |||
877 | 28 | # NOTE(beisner): Features and tests vary across Openstack releases. | 30 | # NOTE(beisner): Features and tests vary across Openstack releases. |
878 | 29 | # https://wiki.openstack.org/wiki/CinderSupportMatrix | 31 | # https://wiki.openstack.org/wiki/CinderSupportMatrix |
879 | 30 | 32 | ||
881 | 31 | def __init__(self, series=None, openstack=None, source=None, stable=False): | 33 | def __init__(self, series=None, openstack=None, source=None, git=False, |
882 | 34 | stable=False): | ||
883 | 32 | '''Deploy the entire test environment.''' | 35 | '''Deploy the entire test environment.''' |
884 | 33 | super(CinderBasicDeployment, self).__init__(series, openstack, source, | 36 | super(CinderBasicDeployment, self).__init__(series, openstack, source, |
885 | 34 | stable) | 37 | stable) |
886 | 38 | self.git = git | ||
887 | 35 | self._add_services() | 39 | self._add_services() |
888 | 36 | self._add_relations() | 40 | self._add_relations() |
889 | 37 | self._configure_services() | 41 | self._configure_services() |
890 | @@ -67,11 +71,31 @@ | |||
891 | 67 | 71 | ||
892 | 68 | def _configure_services(self): | 72 | def _configure_services(self): |
893 | 69 | '''Configure all of the services.''' | 73 | '''Configure all of the services.''' |
894 | 70 | keystone_config = {'admin-password': 'openstack', | ||
895 | 71 | 'admin-token': 'ubuntutesting'} | ||
896 | 72 | cinder_config = {'block-device': 'vdb', | 74 | cinder_config = {'block-device': 'vdb', |
897 | 73 | 'glance-api-version': '2', | 75 | 'glance-api-version': '2', |
898 | 74 | 'overwrite': 'true'} | 76 | 'overwrite': 'true'} |
899 | 77 | if self.git: | ||
900 | 78 | branch = 'stable/' + self._get_openstack_release_string() | ||
901 | 79 | amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY') | ||
902 | 80 | openstack_origin_git = { | ||
903 | 81 | 'repositories': [ | ||
904 | 82 | {'name': 'requirements', | ||
905 | 83 | 'repository': | ||
906 | 84 | 'git://git.openstack.org/openstack/requirements', | ||
907 | 85 | 'branch': branch}, | ||
908 | 86 | {'name': 'cinder', | ||
909 | 87 | 'repository': 'git://git.openstack.org/openstack/cinder', | ||
910 | 88 | 'branch': branch}, | ||
911 | 89 | ], | ||
912 | 90 | 'directory': '/mnt/openstack-git', | ||
913 | 91 | 'http_proxy': amulet_http_proxy, | ||
914 | 92 | 'https_proxy': amulet_http_proxy, | ||
915 | 93 | } | ||
916 | 94 | cinder_config['openstack-origin-git'] = \ | ||
917 | 95 | yaml.dump(openstack_origin_git) | ||
918 | 96 | |||
919 | 97 | keystone_config = {'admin-password': 'openstack', | ||
920 | 98 | 'admin-token': 'ubuntutesting'} | ||
921 | 75 | mysql_config = {'dataset-size': '50%'} | 99 | mysql_config = {'dataset-size': '50%'} |
922 | 76 | configs = {'cinder': cinder_config, | 100 | configs = {'cinder': cinder_config, |
923 | 77 | 'keystone': keystone_config, | 101 | 'keystone': keystone_config, |
924 | 78 | 102 | ||
925 | === modified file 'unit_tests/__init__.py' | |||
926 | --- unit_tests/__init__.py 2013-10-17 21:48:08 +0000 | |||
927 | +++ unit_tests/__init__.py 2015-04-16 14:41:14 +0000 | |||
928 | @@ -1,2 +1,4 @@ | |||
929 | 1 | import sys | 1 | import sys |
930 | 2 | |||
931 | 3 | sys.path.append('actions') | ||
932 | 2 | sys.path.append('hooks') | 4 | sys.path.append('hooks') |
933 | 3 | 5 | ||
934 | === added file 'unit_tests/test_actions_git_reinstall.py' | |||
935 | --- unit_tests/test_actions_git_reinstall.py 1970-01-01 00:00:00 +0000 | |||
936 | +++ unit_tests/test_actions_git_reinstall.py 2015-04-16 14:41:14 +0000 | |||
937 | @@ -0,0 +1,110 @@ | |||
938 | 1 | from mock import patch, MagicMock | ||
939 | 2 | import os | ||
940 | 3 | |||
941 | 4 | os.environ['JUJU_UNIT_NAME'] = 'cinder' | ||
942 | 5 | |||
943 | 6 | from test_utils import RESTART_MAP | ||
944 | 7 | import cinder_utils as utils | ||
945 | 8 | |||
946 | 9 | # Need to do some early patching to get the module loaded. | ||
947 | 10 | _restart_map = utils.restart_map | ||
948 | 11 | _register_configs = utils.register_configs | ||
949 | 12 | |||
950 | 13 | utils.restart_map = MagicMock() | ||
951 | 14 | utils.restart_map.return_value = RESTART_MAP | ||
952 | 15 | utils.register_configs = MagicMock() | ||
953 | 16 | |||
954 | 17 | import git_reinstall | ||
955 | 18 | |||
956 | 19 | # Unpatch it now that its loaded. | ||
957 | 20 | utils.restart_map = _restart_map | ||
958 | 21 | utils.register_configs = _register_configs | ||
959 | 22 | |||
960 | 23 | |||
961 | 24 | from test_utils import ( | ||
962 | 25 | CharmTestCase | ||
963 | 26 | ) | ||
964 | 27 | |||
965 | 28 | TO_PATCH = [ | ||
966 | 29 | 'config', | ||
967 | 30 | ] | ||
968 | 31 | |||
969 | 32 | |||
970 | 33 | openstack_origin_git = \ | ||
971 | 34 | """repositories: | ||
972 | 35 | - {name: requirements, | ||
973 | 36 | repository: 'git://git.openstack.org/openstack/requirements', | ||
974 | 37 | branch: stable/juno} | ||
975 | 38 | - {name: cinder, | ||
976 | 39 | repository: 'git://git.openstack.org/openstack/cinder', | ||
977 | 40 | branch: stable/juno}""" | ||
978 | 41 | |||
979 | 42 | |||
980 | 43 | class TestCinderActions(CharmTestCase): | ||
981 | 44 | |||
982 | 45 | def setUp(self): | ||
983 | 46 | super(TestCinderActions, self).setUp(git_reinstall, TO_PATCH) | ||
984 | 47 | self.config.side_effect = self.test_config.get | ||
985 | 48 | |||
986 | 49 | @patch.object(git_reinstall, 'action_set') | ||
987 | 50 | @patch.object(git_reinstall, 'action_fail') | ||
988 | 51 | @patch.object(git_reinstall, 'git_install') | ||
989 | 52 | @patch.object(git_reinstall, 'config_changed') | ||
990 | 53 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
991 | 54 | def test_git_reinstall(self, _config, config_changed, git_install, | ||
992 | 55 | action_fail, action_set): | ||
993 | 56 | _config.return_value = openstack_origin_git | ||
994 | 57 | self.test_config.set('openstack-origin-git', openstack_origin_git) | ||
995 | 58 | |||
996 | 59 | git_reinstall.git_reinstall() | ||
997 | 60 | |||
998 | 61 | git_install.assert_called_with(openstack_origin_git) | ||
999 | 62 | self.assertTrue(git_install.called) | ||
1000 | 63 | self.assertTrue(config_changed.called) | ||
1001 | 64 | self.assertFalse(action_set.called) | ||
1002 | 65 | self.assertFalse(action_fail.called) | ||
1003 | 66 | |||
1004 | 67 | @patch.object(git_reinstall, 'action_set') | ||
1005 | 68 | @patch.object(git_reinstall, 'action_fail') | ||
1006 | 69 | @patch.object(git_reinstall, 'git_install') | ||
1007 | 70 | @patch.object(git_reinstall, 'config_changed') | ||
1008 | 71 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
1009 | 72 | def test_git_reinstall_not_configured(self, _config, config_changed, | ||
1010 | 73 | git_install, action_fail, | ||
1011 | 74 | action_set): | ||
1012 | 75 | _config.return_value = None | ||
1013 | 76 | |||
1014 | 77 | git_reinstall.git_reinstall() | ||
1015 | 78 | |||
1016 | 79 | msg = 'openstack-origin-git is not configured' | ||
1017 | 80 | action_fail.assert_called_with(msg) | ||
1018 | 81 | self.assertFalse(git_install.called) | ||
1019 | 82 | self.assertFalse(action_set.called) | ||
1020 | 83 | |||
1021 | 84 | @patch.object(git_reinstall, 'action_set') | ||
1022 | 85 | @patch.object(git_reinstall, 'action_fail') | ||
1023 | 86 | @patch.object(git_reinstall, 'git_install') | ||
1024 | 87 | @patch.object(git_reinstall, 'config_changed') | ||
1025 | 88 | @patch('traceback.format_exc') | ||
1026 | 89 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
1027 | 90 | def test_git_reinstall_exception(self, _config, format_exc, config_changed, | ||
1028 | 91 | git_install, action_fail, action_set): | ||
1029 | 92 | _config.return_value = openstack_origin_git | ||
1030 | 93 | e = OSError('something bad happened') | ||
1031 | 94 | git_install.side_effect = e | ||
1032 | 95 | traceback = ( | ||
1033 | 96 | "Traceback (most recent call last):\n" | ||
1034 | 97 | " File \"actions/git_reinstall.py\", line 37, in git_reinstall\n" | ||
1035 | 98 | " git_install(config(\'openstack-origin-git\'))\n" | ||
1036 | 99 | " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 964, in __call__\n" # noqa | ||
1037 | 100 | " return _mock_self._mock_call(*args, **kwargs)\n" | ||
1038 | 101 | " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 1019, in _mock_call\n" # noqa | ||
1039 | 102 | " raise effect\n" | ||
1040 | 103 | "OSError: something bad happened\n") | ||
1041 | 104 | format_exc.return_value = traceback | ||
1042 | 105 | |||
1043 | 106 | git_reinstall.git_reinstall() | ||
1044 | 107 | |||
1045 | 108 | msg = 'git-reinstall resulted in an unexpected error' | ||
1046 | 109 | action_fail.assert_called_with(msg) | ||
1047 | 110 | action_set.assert_called_with({'traceback': traceback}) | ||
1048 | 0 | 111 | ||
1049 | === modified file 'unit_tests/test_cinder_hooks.py' | |||
1050 | --- unit_tests/test_cinder_hooks.py 2015-03-31 08:37:22 +0000 | |||
1051 | +++ unit_tests/test_cinder_hooks.py 2015-04-16 14:41:14 +0000 | |||
1052 | @@ -4,6 +4,7 @@ | |||
1053 | 4 | patch, | 4 | patch, |
1054 | 5 | call | 5 | call |
1055 | 6 | ) | 6 | ) |
1056 | 7 | import yaml | ||
1057 | 7 | 8 | ||
1058 | 8 | import cinder_utils as utils | 9 | import cinder_utils as utils |
1059 | 9 | from test_utils import ( | 10 | from test_utils import ( |
1060 | @@ -35,6 +36,7 @@ | |||
1061 | 35 | 'determine_packages', | 36 | 'determine_packages', |
1062 | 36 | 'do_openstack_upgrade', | 37 | 'do_openstack_upgrade', |
1063 | 37 | 'ensure_ceph_keyring', | 38 | 'ensure_ceph_keyring', |
1064 | 39 | 'git_install', | ||
1065 | 38 | 'juju_log', | 40 | 'juju_log', |
1066 | 39 | 'log', | 41 | 'log', |
1067 | 40 | 'lsb_release', | 42 | 'lsb_release', |
1068 | @@ -63,7 +65,7 @@ | |||
1069 | 63 | # charmhelpers.contrib.openstack.openstack_utils | 65 | # charmhelpers.contrib.openstack.openstack_utils |
1070 | 64 | 'configure_installation_source', | 66 | 'configure_installation_source', |
1071 | 65 | 'openstack_upgrade_available', | 67 | 'openstack_upgrade_available', |
1073 | 66 | 'get_os_codename_package', | 68 | 'os_release', |
1074 | 67 | # charmhelpers.contrib.hahelpers.cluster_utils | 69 | # charmhelpers.contrib.hahelpers.cluster_utils |
1075 | 68 | 'canonical_url', | 70 | 'canonical_url', |
1076 | 69 | 'eligible_leader', | 71 | 'eligible_leader', |
1077 | @@ -79,17 +81,47 @@ | |||
1078 | 79 | 81 | ||
1079 | 80 | def setUp(self): | 82 | def setUp(self): |
1080 | 81 | super(TestInstallHook, self).setUp(hooks, TO_PATCH) | 83 | super(TestInstallHook, self).setUp(hooks, TO_PATCH) |
1082 | 82 | self.config.side_effect = self.test_config.get_all | 84 | self.config.side_effect = self.test_config.get |
1083 | 83 | 85 | ||
1085 | 84 | def test_install_precise_distro(self): | 86 | @patch.object(utils, 'git_install_requested') |
1086 | 87 | def test_install_precise_distro(self, git_requested): | ||
1087 | 85 | 'It redirects to cloud archive if setup to install precise+distro' | 88 | 'It redirects to cloud archive if setup to install precise+distro' |
1088 | 89 | git_requested.return_value = False | ||
1089 | 86 | self.lsb_release.return_value = {'DISTRIB_CODENAME': 'precise'} | 90 | self.lsb_release.return_value = {'DISTRIB_CODENAME': 'precise'} |
1090 | 87 | hooks.hooks.execute(['hooks/install']) | 91 | hooks.hooks.execute(['hooks/install']) |
1091 | 88 | ca = 'cloud:precise-folsom' | 92 | ca = 'cloud:precise-folsom' |
1092 | 89 | self.configure_installation_source.assert_called_with(ca) | 93 | self.configure_installation_source.assert_called_with(ca) |
1093 | 90 | 94 | ||
1095 | 91 | def test_correct_install_packages(self): | 95 | @patch.object(utils, 'git_install_requested') |
1096 | 96 | def test_install_git(self, git_requested): | ||
1097 | 97 | git_requested.return_value = True | ||
1098 | 98 | self.determine_packages.return_value = ['foo', 'bar', 'baz'] | ||
1099 | 99 | repo = 'cloud:trusty-juno' | ||
1100 | 100 | openstack_origin_git = { | ||
1101 | 101 | 'repositories': [ | ||
1102 | 102 | {'name': 'requirements', | ||
1103 | 103 | 'repository': 'git://git.openstack.org/openstack/requirements', # noqa | ||
1104 | 104 | 'branch': 'stable/juno'}, | ||
1105 | 105 | {'name': 'cinder', | ||
1106 | 106 | 'repository': 'git://git.openstack.org/openstack/cinder', | ||
1107 | 107 | 'branch': 'stable/juno'} | ||
1108 | 108 | ], | ||
1109 | 109 | 'directory': '/mnt/openstack-git', | ||
1110 | 110 | } | ||
1111 | 111 | projects_yaml = yaml.dump(openstack_origin_git) | ||
1112 | 112 | self.test_config.set('openstack-origin', repo) | ||
1113 | 113 | self.test_config.set('openstack-origin-git', projects_yaml) | ||
1114 | 114 | hooks.hooks.execute(['hooks/install']) | ||
1115 | 115 | self.assertTrue(self.execd_preinstall.called) | ||
1116 | 116 | self.configure_installation_source.assert_called_with(repo) | ||
1117 | 117 | self.apt_update.assert_called_with() | ||
1118 | 118 | self.apt_install.assert_called_with(['foo', 'bar', 'baz'], fatal=True) | ||
1119 | 119 | self.git_install.assert_called_with(projects_yaml) | ||
1120 | 120 | |||
1121 | 121 | @patch.object(utils, 'git_install_requested') | ||
1122 | 122 | def test_correct_install_packages(self, git_requested): | ||
1123 | 92 | 'It installs the correct packages based on what is determined' | 123 | 'It installs the correct packages based on what is determined' |
1124 | 124 | git_requested.return_value = False | ||
1125 | 93 | self.determine_packages.return_value = ['foo', 'bar', 'baz'] | 125 | self.determine_packages.return_value = ['foo', 'bar', 'baz'] |
1126 | 94 | hooks.hooks.execute(['hooks/install']) | 126 | hooks.hooks.execute(['hooks/install']) |
1127 | 95 | self.apt_install.assert_called_with(['foo', 'bar', 'baz'], fatal=True) | 127 | self.apt_install.assert_called_with(['foo', 'bar', 'baz'], fatal=True) |
1128 | @@ -99,7 +131,7 @@ | |||
1129 | 99 | 131 | ||
1130 | 100 | def setUp(self): | 132 | def setUp(self): |
1131 | 101 | super(TestChangedHooks, self).setUp(hooks, TO_PATCH) | 133 | super(TestChangedHooks, self).setUp(hooks, TO_PATCH) |
1133 | 102 | self.config.side_effect = self.test_config.get_all | 134 | self.config.side_effect = self.test_config.get |
1134 | 103 | 135 | ||
1135 | 104 | @patch.object(hooks, 'amqp_joined') | 136 | @patch.object(hooks, 'amqp_joined') |
1136 | 105 | def test_upgrade_charm_no_amqp(self, _joined): | 137 | def test_upgrade_charm_no_amqp(self, _joined): |
1137 | @@ -114,8 +146,10 @@ | |||
1138 | 114 | _joined.assert_called_with(relation_id='amqp:1') | 146 | _joined.assert_called_with(relation_id='amqp:1') |
1139 | 115 | 147 | ||
1140 | 116 | @patch.object(hooks, 'configure_https') | 148 | @patch.object(hooks, 'configure_https') |
1142 | 117 | def test_config_changed(self, conf_https): | 149 | @patch.object(hooks, 'git_install_requested') |
1143 | 150 | def test_config_changed(self, git_requested, conf_https): | ||
1144 | 118 | 'It writes out all config' | 151 | 'It writes out all config' |
1145 | 152 | git_requested.return_value = False | ||
1146 | 119 | self.openstack_upgrade_available.return_value = False | 153 | self.openstack_upgrade_available.return_value = False |
1147 | 120 | hooks.hooks.execute(['hooks/config-changed']) | 154 | hooks.hooks.execute(['hooks/config-changed']) |
1148 | 121 | self.assertTrue(self.CONFIGS.write_all.called) | 155 | self.assertTrue(self.CONFIGS.write_all.called) |
1149 | @@ -125,8 +159,10 @@ | |||
1150 | 125 | False, False) | 159 | False, False) |
1151 | 126 | 160 | ||
1152 | 127 | @patch.object(hooks, 'configure_https') | 161 | @patch.object(hooks, 'configure_https') |
1154 | 128 | def test_config_changed_block_devices(self, conf_https): | 162 | @patch.object(hooks, 'git_install_requested') |
1155 | 163 | def test_config_changed_block_devices(self, git_requested, conf_https): | ||
1156 | 129 | 'It writes out all config' | 164 | 'It writes out all config' |
1157 | 165 | git_requested.return_value = False | ||
1158 | 130 | self.openstack_upgrade_available.return_value = False | 166 | self.openstack_upgrade_available.return_value = False |
1159 | 131 | self.test_config.set('block-device', 'sdb /dev/sdc sde') | 167 | self.test_config.set('block-device', 'sdb /dev/sdc sde') |
1160 | 132 | self.test_config.set('volume-group', 'cinder-new') | 168 | self.test_config.set('volume-group', 'cinder-new') |
1161 | @@ -141,12 +177,40 @@ | |||
1162 | 141 | True, True) | 177 | True, True) |
1163 | 142 | 178 | ||
1164 | 143 | @patch.object(hooks, 'configure_https') | 179 | @patch.object(hooks, 'configure_https') |
1166 | 144 | def test_config_changed_upgrade_available(self, conf_https): | 180 | @patch.object(hooks, 'git_install_requested') |
1167 | 181 | def test_config_changed_upgrade_available(self, git_requested, conf_https): | ||
1168 | 145 | 'It writes out all config with an available OS upgrade' | 182 | 'It writes out all config with an available OS upgrade' |
1169 | 183 | git_requested.return_value = False | ||
1170 | 146 | self.openstack_upgrade_available.return_value = True | 184 | self.openstack_upgrade_available.return_value = True |
1171 | 147 | hooks.hooks.execute(['hooks/config-changed']) | 185 | hooks.hooks.execute(['hooks/config-changed']) |
1172 | 148 | self.do_openstack_upgrade.assert_called_with(configs=self.CONFIGS) | 186 | self.do_openstack_upgrade.assert_called_with(configs=self.CONFIGS) |
1173 | 149 | 187 | ||
1174 | 188 | @patch.object(hooks, 'configure_https') | ||
1175 | 189 | @patch.object(hooks, 'git_install_requested') | ||
1176 | 190 | @patch.object(hooks, 'config_value_changed') | ||
1177 | 191 | def test_config_changed_git_updated(self, config_val_changed, | ||
1178 | 192 | git_requested, conf_https): | ||
1179 | 193 | git_requested.return_value = True | ||
1180 | 194 | repo = 'cloud:trusty-juno' | ||
1181 | 195 | openstack_origin_git = { | ||
1182 | 196 | 'repositories': [ | ||
1183 | 197 | {'name': 'requirements', | ||
1184 | 198 | 'repository': 'git://git.openstack.org/openstack/requirements', # noqa | ||
1185 | 199 | 'branch': 'stable/juno'}, | ||
1186 | 200 | {'name': 'cinder', | ||
1187 | 201 | 'repository': 'git://git.openstack.org/openstack/', | ||
1188 | 202 | 'branch': 'stable/juno'} | ||
1189 | 203 | ], | ||
1190 | 204 | 'directory': '/mnt/openstack-git', | ||
1191 | 205 | } | ||
1192 | 206 | projects_yaml = yaml.dump(openstack_origin_git) | ||
1193 | 207 | self.test_config.set('openstack-origin', repo) | ||
1194 | 208 | self.test_config.set('openstack-origin-git', projects_yaml) | ||
1195 | 209 | hooks.hooks.execute(['hooks/config-changed']) | ||
1196 | 210 | self.git_install.assert_called_with(projects_yaml) | ||
1197 | 211 | self.assertFalse(self.do_openstack_upgrade.called) | ||
1198 | 212 | self.assertTrue(conf_https.called) | ||
1199 | 213 | |||
1200 | 150 | def test_db_changed(self): | 214 | def test_db_changed(self): |
1201 | 151 | 'It writes out cinder.conf on db changed' | 215 | 'It writes out cinder.conf on db changed' |
1202 | 152 | self.relation_get.return_value = 'cinder/0 cinder/1' | 216 | self.relation_get.return_value = 'cinder/0 cinder/1' |
1203 | @@ -341,7 +405,7 @@ | |||
1204 | 341 | 405 | ||
1205 | 342 | def test_identity_service_joined(self): | 406 | def test_identity_service_joined(self): |
1206 | 343 | 'It properly requests unclustered endpoint via identity-service' | 407 | 'It properly requests unclustered endpoint via identity-service' |
1208 | 344 | self.get_os_codename_package.return_value = 'havana' | 408 | self.os_release.return_value = 'havana' |
1209 | 345 | self.unit_get.return_value = 'cindernode1' | 409 | self.unit_get.return_value = 'cindernode1' |
1210 | 346 | self.config.side_effect = self.test_config.get | 410 | self.config.side_effect = self.test_config.get |
1211 | 347 | self.canonical_url.return_value = 'http://cindernode1' | 411 | self.canonical_url.return_value = 'http://cindernode1' |
1212 | @@ -363,7 +427,7 @@ | |||
1213 | 363 | 427 | ||
1214 | 364 | def test_identity_service_joined_icehouse(self): | 428 | def test_identity_service_joined_icehouse(self): |
1215 | 365 | 'It properly requests unclustered endpoint via identity-service' | 429 | 'It properly requests unclustered endpoint via identity-service' |
1217 | 366 | self.get_os_codename_package.return_value = 'icehouse' | 430 | self.os_release.return_value = 'icehouse' |
1218 | 367 | self.unit_get.return_value = 'cindernode1' | 431 | self.unit_get.return_value = 'cindernode1' |
1219 | 368 | self.config.side_effect = self.test_config.get | 432 | self.config.side_effect = self.test_config.get |
1220 | 369 | self.canonical_url.return_value = 'http://cindernode1' | 433 | self.canonical_url.return_value = 'http://cindernode1' |
1221 | 370 | 434 | ||
1222 | === modified file 'unit_tests/test_cinder_utils.py' | |||
1223 | --- unit_tests/test_cinder_utils.py 2014-12-15 10:17:11 +0000 | |||
1224 | +++ unit_tests/test_cinder_utils.py 2015-04-16 14:41:14 +0000 | |||
1225 | @@ -30,7 +30,7 @@ | |||
1226 | 30 | 'ensure_loopback_device', | 30 | 'ensure_loopback_device', |
1227 | 31 | 'is_block_device', | 31 | 'is_block_device', |
1228 | 32 | 'zap_disk', | 32 | 'zap_disk', |
1230 | 33 | 'get_os_codename_package', | 33 | 'os_release', |
1231 | 34 | 'get_os_codename_install_source', | 34 | 'get_os_codename_install_source', |
1232 | 35 | 'configure_installation_source', | 35 | 'configure_installation_source', |
1233 | 36 | 'eligible_leader', | 36 | 'eligible_leader', |
1234 | @@ -68,6 +68,15 @@ | |||
1235 | 68 | 68 | ||
1236 | 69 | """ | 69 | """ |
1237 | 70 | 70 | ||
1238 | 71 | openstack_origin_git = \ | ||
1239 | 72 | """repositories: | ||
1240 | 73 | - {name: requirements, | ||
1241 | 74 | repository: 'git://git.openstack.org/openstack/requirements', | ||
1242 | 75 | branch: stable/juno} | ||
1243 | 76 | - {name: cinder, | ||
1244 | 77 | repository: 'git://git.openstack.org/openstack/cinder', | ||
1245 | 78 | branch: stable/juno}""" | ||
1246 | 79 | |||
1247 | 71 | 80 | ||
1248 | 72 | class TestCinderUtils(CharmTestCase): | 81 | class TestCinderUtils(CharmTestCase): |
1249 | 73 | 82 | ||
1250 | @@ -97,8 +106,10 @@ | |||
1251 | 97 | self.assertFalse(cinder_utils.service_enabled('volume')) | 106 | self.assertFalse(cinder_utils.service_enabled('volume')) |
1252 | 98 | 107 | ||
1253 | 99 | @patch('cinder_utils.service_enabled') | 108 | @patch('cinder_utils.service_enabled') |
1255 | 100 | def test_determine_packages_all(self, service_enabled): | 109 | @patch('cinder_utils.git_install_requested') |
1256 | 110 | def test_determine_packages_all(self, git_requested, service_enabled): | ||
1257 | 101 | 'It determines all packages required when all services enabled' | 111 | 'It determines all packages required when all services enabled' |
1258 | 112 | git_requested.return_value = False | ||
1259 | 102 | service_enabled.return_value = True | 113 | service_enabled.return_value = True |
1260 | 103 | pkgs = cinder_utils.determine_packages() | 114 | pkgs = cinder_utils.determine_packages() |
1261 | 104 | self.assertEquals(sorted(pkgs), | 115 | self.assertEquals(sorted(pkgs), |
1262 | @@ -108,8 +119,10 @@ | |||
1263 | 108 | cinder_utils.SCHEDULER_PACKAGES)) | 119 | cinder_utils.SCHEDULER_PACKAGES)) |
1264 | 109 | 120 | ||
1265 | 110 | @patch('cinder_utils.service_enabled') | 121 | @patch('cinder_utils.service_enabled') |
1267 | 111 | def test_determine_packages_subset(self, service_enabled): | 122 | @patch('cinder_utils.git_install_requested') |
1268 | 123 | def test_determine_packages_subset(self, git_requested, service_enabled): | ||
1269 | 112 | 'It determines packages required for a subset of enabled services' | 124 | 'It determines packages required for a subset of enabled services' |
1270 | 125 | git_requested.return_value = False | ||
1271 | 113 | service_enabled.side_effect = self.svc_enabled | 126 | service_enabled.side_effect = self.svc_enabled |
1272 | 114 | 127 | ||
1273 | 115 | self.test_config.set('enabled-services', 'api') | 128 | self.test_config.set('enabled-services', 'api') |
1274 | @@ -402,7 +415,7 @@ | |||
1275 | 402 | @patch('os.path.exists') | 415 | @patch('os.path.exists') |
1276 | 403 | def test_register_configs_apache(self, exists): | 416 | def test_register_configs_apache(self, exists): |
1277 | 404 | exists.return_value = False | 417 | exists.return_value = False |
1279 | 405 | self.get_os_codename_package.return_value = 'grizzly' | 418 | self.os_release.return_value = 'grizzly' |
1280 | 406 | self.relation_ids.return_value = False | 419 | self.relation_ids.return_value = False |
1281 | 407 | configs = cinder_utils.register_configs() | 420 | configs = cinder_utils.register_configs() |
1282 | 408 | calls = [] | 421 | calls = [] |
1283 | @@ -419,7 +432,7 @@ | |||
1284 | 419 | @patch('os.path.exists') | 432 | @patch('os.path.exists') |
1285 | 420 | def test_register_configs_apache24(self, exists): | 433 | def test_register_configs_apache24(self, exists): |
1286 | 421 | exists.return_value = True | 434 | exists.return_value = True |
1288 | 422 | self.get_os_codename_package.return_value = 'grizzly' | 435 | self.os_release.return_value = 'grizzly' |
1289 | 423 | self.relation_ids.return_value = False | 436 | self.relation_ids.return_value = False |
1290 | 424 | configs = cinder_utils.register_configs() | 437 | configs = cinder_utils.register_configs() |
1291 | 425 | calls = [] | 438 | calls = [] |
1292 | @@ -438,7 +451,7 @@ | |||
1293 | 438 | def test_register_configs_ceph(self, exists, isdir): | 451 | def test_register_configs_ceph(self, exists, isdir): |
1294 | 439 | exists.return_value = True | 452 | exists.return_value = True |
1295 | 440 | isdir.return_value = False | 453 | isdir.return_value = False |
1297 | 441 | self.get_os_codename_package.return_value = 'grizzly' | 454 | self.os_release.return_value = 'grizzly' |
1298 | 442 | self.relation_ids.return_value = ['ceph:0'] | 455 | self.relation_ids.return_value = ['ceph:0'] |
1299 | 443 | self.ceph_config_file.return_value = '/var/lib/charm/cinder/ceph.conf' | 456 | self.ceph_config_file.return_value = '/var/lib/charm/cinder/ceph.conf' |
1300 | 444 | configs = cinder_utils.register_configs() | 457 | configs = cinder_utils.register_configs() |
1301 | @@ -504,3 +517,149 @@ | |||
1302 | 504 | self.apt_install.assert_called_with(['mypackage'], fatal=True) | 517 | self.apt_install.assert_called_with(['mypackage'], fatal=True) |
1303 | 505 | configs.set_release.assert_called_with(openstack_release='havana') | 518 | configs.set_release.assert_called_with(openstack_release='havana') |
1304 | 506 | self.assertFalse(migrate.called) | 519 | self.assertFalse(migrate.called) |
1305 | 520 | |||
1306 | 521 | @patch.object(cinder_utils, 'git_install_requested') | ||
1307 | 522 | @patch.object(cinder_utils, 'git_clone_and_install') | ||
1308 | 523 | @patch.object(cinder_utils, 'git_post_install') | ||
1309 | 524 | @patch.object(cinder_utils, 'git_pre_install') | ||
1310 | 525 | def test_git_install(self, git_pre, git_post, git_clone_and_install, | ||
1311 | 526 | git_requested): | ||
1312 | 527 | projects_yaml = openstack_origin_git | ||
1313 | 528 | git_requested.return_value = True | ||
1314 | 529 | cinder_utils.git_install(projects_yaml) | ||
1315 | 530 | self.assertTrue(git_pre.called) | ||
1316 | 531 | git_clone_and_install.assert_called_with(openstack_origin_git, | ||
1317 | 532 | core_project='cinder') | ||
1318 | 533 | self.assertTrue(git_post.called) | ||
1319 | 534 | |||
1320 | 535 | @patch.object(cinder_utils, 'mkdir') | ||
1321 | 536 | @patch.object(cinder_utils, 'write_file') | ||
1322 | 537 | @patch.object(cinder_utils, 'add_user_to_group') | ||
1323 | 538 | @patch.object(cinder_utils, 'add_group') | ||
1324 | 539 | @patch.object(cinder_utils, 'adduser') | ||
1325 | 540 | def test_git_pre_install(self, adduser, add_group, add_user_to_group, | ||
1326 | 541 | write_file, mkdir): | ||
1327 | 542 | cinder_utils.git_pre_install() | ||
1328 | 543 | adduser.assert_called_with('cinder', shell='/bin/bash', | ||
1329 | 544 | system_user=True) | ||
1330 | 545 | add_group.assert_called_with('cinder', system_group=True) | ||
1331 | 546 | add_user_to_group.assert_called_with('cinder', 'cinder') | ||
1332 | 547 | expected = [ | ||
1333 | 548 | call('/etc/tgt', owner='cinder', perms=488, force=False, | ||
1334 | 549 | group='cinder'), | ||
1335 | 550 | call('/var/lib/cinder', owner='cinder', perms=493, force=False, | ||
1336 | 551 | group='cinder'), | ||
1337 | 552 | call('/var/lib/cinder/volumes', owner='cinder', perms=488, | ||
1338 | 553 | force=False, group='cinder'), | ||
1339 | 554 | call('/var/lock/cinder', owner='cinder', perms=488, force=False, | ||
1340 | 555 | group='root'), | ||
1341 | 556 | call('/var/log/cinder', owner='cinder', perms=488, force=False, | ||
1342 | 557 | group='cinder'), | ||
1343 | 558 | ] | ||
1344 | 559 | self.assertEquals(mkdir.call_args_list, expected) | ||
1345 | 560 | expected = [ | ||
1346 | 561 | call('/var/log/cinder/cinder-api.log', '', perms=0600, | ||
1347 | 562 | owner='cinder', group='cinder'), | ||
1348 | 563 | call('/var/log/cinder/cinder-backup.log', '', perms=0600, | ||
1349 | 564 | owner='cinder', group='cinder'), | ||
1350 | 565 | call('/var/log/cinder/cinder-scheduler.log', '', perms=0600, | ||
1351 | 566 | owner='cinder', group='cinder'), | ||
1352 | 567 | call('/var/log/cinder/cinder-volume.log', '', perms=0600, | ||
1353 | 568 | owner='cinder', group='cinder'), | ||
1354 | 569 | ] | ||
1355 | 570 | self.assertEquals(write_file.call_args_list, expected) | ||
1356 | 571 | |||
1357 | 572 | @patch.object(cinder_utils, 'git_src_dir') | ||
1358 | 573 | @patch.object(cinder_utils, 'service_restart') | ||
1359 | 574 | @patch.object(cinder_utils, 'render') | ||
1360 | 575 | @patch('os.path.join') | ||
1361 | 576 | @patch('os.path.exists') | ||
1362 | 577 | @patch('shutil.copytree') | ||
1363 | 578 | @patch('shutil.rmtree') | ||
1364 | 579 | @patch('pwd.getpwnam') | ||
1365 | 580 | @patch('grp.getgrnam') | ||
1366 | 581 | @patch('os.chown') | ||
1367 | 582 | @patch('os.chmod') | ||
1368 | 583 | def test_git_post_install(self, chmod, chown, grp, pwd, rmtree, copytree, | ||
1369 | 584 | exists, join, render, service_restart, | ||
1370 | 585 | git_src_dir): | ||
1371 | 586 | projects_yaml = openstack_origin_git | ||
1372 | 587 | join.return_value = 'joined-string' | ||
1373 | 588 | cinder_utils.git_post_install(projects_yaml) | ||
1374 | 589 | expected = [ | ||
1375 | 590 | call('joined-string', '/etc/cinder'), | ||
1376 | 591 | ] | ||
1377 | 592 | copytree.assert_has_calls(expected) | ||
1378 | 593 | |||
1379 | 594 | cinder_api_context = { | ||
1380 | 595 | 'service_description': 'Cinder API server', | ||
1381 | 596 | 'service_name': 'Cinder', | ||
1382 | 597 | 'user_name': 'cinder', | ||
1383 | 598 | 'start_dir': '/var/lib/cinder', | ||
1384 | 599 | 'process_name': 'cinder-api', | ||
1385 | 600 | 'executable_name': '/usr/local/bin/cinder-api', | ||
1386 | 601 | 'config_files': ['/etc/cinder/cinder.conf'], | ||
1387 | 602 | 'log_file': '/var/log/cinder/cinder-api.log', | ||
1388 | 603 | } | ||
1389 | 604 | |||
1390 | 605 | cinder_backup_context = { | ||
1391 | 606 | 'service_description': 'Cinder backup server', | ||
1392 | 607 | 'service_name': 'Cinder', | ||
1393 | 608 | 'user_name': 'cinder', | ||
1394 | 609 | 'start_dir': '/var/lib/cinder', | ||
1395 | 610 | 'process_name': 'cinder-backup', | ||
1396 | 611 | 'executable_name': '/usr/local/bin/cinder-backup', | ||
1397 | 612 | 'config_files': ['/etc/cinder/cinder.conf'], | ||
1398 | 613 | 'log_file': '/var/log/cinder/cinder-backup.log', | ||
1399 | 614 | } | ||
1400 | 615 | |||
1401 | 616 | cinder_scheduler_context = { | ||
1402 | 617 | 'service_description': 'Cinder scheduler server', | ||
1403 | 618 | 'service_name': 'Cinder', | ||
1404 | 619 | 'user_name': 'cinder', | ||
1405 | 620 | 'start_dir': '/var/lib/cinder', | ||
1406 | 621 | 'process_name': 'cinder-scheduler', | ||
1407 | 622 | 'executable_name': '/usr/local/bin/cinder-scheduler', | ||
1408 | 623 | 'config_files': ['/etc/cinder/cinder.conf'], | ||
1409 | 624 | 'log_file': '/var/log/cinder/cinder-scheduler.log', | ||
1410 | 625 | } | ||
1411 | 626 | |||
1412 | 627 | cinder_volume_context = { | ||
1413 | 628 | 'service_description': 'Cinder volume server', | ||
1414 | 629 | 'service_name': 'Cinder', | ||
1415 | 630 | 'user_name': 'cinder', | ||
1416 | 631 | 'start_dir': '/var/lib/cinder', | ||
1417 | 632 | 'process_name': 'cinder-volume', | ||
1418 | 633 | 'executable_name': '/usr/local/bin/cinder-volume', | ||
1419 | 634 | 'config_files': ['/etc/cinder/cinder.conf'], | ||
1420 | 635 | 'log_file': '/var/log/cinder/cinder-volume.log', | ||
1421 | 636 | } | ||
1422 | 637 | expected = [ | ||
1423 | 638 | call('cinder.conf', '/etc/cinder/cinder.conf', {}, owner='cinder', | ||
1424 | 639 | group='cinder', perms=0o644), | ||
1425 | 640 | call('git/cinder_tgt.conf', '/etc/tgt/conf.d', {}, owner='cinder', | ||
1426 | 641 | group='cinder', perms=0o644), | ||
1427 | 642 | call('git/logging.conf', '/etc/cinder/logging.conf', {}, | ||
1428 | 643 | owner='cinder', group='cinder', perms=0o644), | ||
1429 | 644 | call('git/cinder_sudoers', '/etc/sudoers.d/cinder_sudoers', {}, | ||
1430 | 645 | owner='root', group='root', perms=0o440), | ||
1431 | 646 | call('git.upstart', '/etc/init/cinder-api.conf', | ||
1432 | 647 | cinder_api_context, perms=0o644, | ||
1433 | 648 | templates_dir='joined-string'), | ||
1434 | 649 | call('git.upstart', '/etc/init/cinder-backup.conf', | ||
1435 | 650 | cinder_backup_context, perms=0o644, | ||
1436 | 651 | templates_dir='joined-string'), | ||
1437 | 652 | call('git.upstart', '/etc/init/cinder-scheduler.conf', | ||
1438 | 653 | cinder_scheduler_context, perms=0o644, | ||
1439 | 654 | templates_dir='joined-string'), | ||
1440 | 655 | call('git.upstart', '/etc/init/cinder-volume.conf', | ||
1441 | 656 | cinder_volume_context, perms=0o644, | ||
1442 | 657 | templates_dir='joined-string'), | ||
1443 | 658 | ] | ||
1444 | 659 | self.assertEquals(render.call_args_list, expected) | ||
1445 | 660 | expected = [ | ||
1446 | 661 | call('tgtd'), call('haproxy'), call('apache2'), | ||
1447 | 662 | call('cinder-api'), call('cinder-volume'), | ||
1448 | 663 | call('cinder-scheduler'), | ||
1449 | 664 | ] | ||
1450 | 665 | self.assertEquals(service_restart.call_args_list, expected) |
The conflicts don't make any sense to me so I'm leaving them as is. I don't think they're an issue.