Merge lp:~corey.bryant/charms/trusty/nova-compute/git into lp:~openstack-charmers-archive/charms/trusty/nova-compute/next
- Trusty Tahr (14.04)
- git
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 123 |
Proposed branch: | lp:~corey.bryant/charms/trusty/nova-compute/git |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-compute/next |
Diff against target: |
1288 lines (+811/-65) 29 files modified
.bzrignore (+1/-0) Makefile (+4/-2) README.md (+88/-3) actions.yaml (+2/-0) actions/git_reinstall.py (+45/-0) config.yaml (+16/-0) hooks/charmhelpers/contrib/openstack/utils.py (+4/-1) hooks/nova_compute_hooks.py (+12/-2) hooks/nova_compute_utils.py (+191/-2) templates/git/nova-compute-kvm.conf (+4/-0) templates/git/nova-compute-lxc.conf (+4/-0) templates/git/nova-compute-qemu.conf (+4/-0) templates/git/nova-compute-vmware.conf (+2/-0) templates/git/nova-compute-xen.conf (+4/-0) templates/git/nova_sudoers (+4/-0) templates/git/nova_tgt.conf (+1/-0) templates/git/upstart/nova-compute.upstart (+27/-0) tests/10-basic-precise-essex (+0/-9) tests/11-basic-precise-folsom (+0/-17) tests/12-basic-precise-grizzly (+0/-11) tests/13-basic-precise-havana (+0/-11) tests/16-basic-trusty-icehouse-git (+9/-0) tests/17-basic-trusty-juno (+11/-0) tests/18-basic-trusty-juno-git (+12/-0) tests/basic_deployment.py (+23/-1) unit_tests/__init__.py (+1/-0) unit_tests/test_actions_git_reinstall.py (+96/-0) unit_tests/test_nova_compute_hooks.py (+57/-0) unit_tests/test_nova_compute_utils.py (+189/-6) |
To merge this branch: | bzr merge lp:~corey.bryant/charms/trusty/nova-compute/git |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenStack Charmers | Pending | ||
Review via email: mp+255945@code.launchpad.net |
Commit message
Description of the change
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3119 nova-compute-next for corey.bryant mp255945
UNIT FAIL: unit-test failed
UNIT Results (max last 2 lines):
make: *** [unit_test] Error 1
ERROR:root:Make target returned non-zero.
Full unit test output: http://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3334 nova-compute-next for corey.bryant mp255945
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3122 nova-compute-next for corey.bryant mp255945
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3153 nova-compute-next for corey.bryant mp255945
AMULET OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3157 nova-compute-next for corey.bryant mp255945
AMULET OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3383 nova-compute-next for corey.bryant mp255945
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3171 nova-compute-next for corey.bryant mp255945
UNIT OK: passed
- 118. By Corey Bryant
-
Deploy from source
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3387 nova-compute-next for corey.bryant mp255945
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3175 nova-compute-next for corey.bryant mp255945
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3171 nova-compute-next for corey.bryant mp255945
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://
- 119. By Corey Bryant
-
Fixup test_git_
reinstall_ exception( )
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3177 nova-compute-next for corey.bryant mp255945
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://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3399 nova-compute-next for corey.bryant mp255945
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3187 nova-compute-next for corey.bryant mp255945
UNIT OK: passed
- 120. By Corey Bryant
-
Sync charm-helpers
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3406 nova-compute-next for corey.bryant mp255945
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3194 nova-compute-next for corey.bryant mp255945
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3189 nova-compute-next for corey.bryant mp255945
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://
- 121. By Corey Bryant
-
Move config_changed into try block
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3415 nova-compute-next for corey.bryant mp255945
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3203 nova-compute-next for corey.bryant mp255945
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3199 nova-compute-next for corey.bryant mp255945
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://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3208 nova-compute-next for corey.bryant mp255945
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://
- 122. By Corey Bryant
-
Fix nova_conf path
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3418 nova-compute-next for corey.bryant mp255945
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3206 nova-compute-next for corey.bryant mp255945
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3212 nova-compute-next for corey.bryant mp255945
AMULET OK: passed
Build: http://
- 123. By Corey Bryant
-
Sync charm-helpers
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3456 nova-compute-next for corey.bryant mp255945
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3244 nova-compute-next for corey.bryant mp255945
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3254 nova-compute-next for corey.bryant mp255945
AMULET OK: passed
Build: http://
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2014-07-02 08:23:51 +0000 |
3 | +++ .bzrignore 2015-04-16 14:46:17 +0000 |
4 | @@ -1,2 +1,3 @@ |
5 | bin |
6 | .coverage |
7 | +tags |
8 | |
9 | === modified file 'Makefile' |
10 | --- Makefile 2015-03-31 08:46:52 +0000 |
11 | +++ Makefile 2015-04-16 14:46:17 +0000 |
12 | @@ -2,7 +2,7 @@ |
13 | PYTHON := /usr/bin/env python |
14 | |
15 | lint: |
16 | - @flake8 --exclude hooks/charmhelpers hooks unit_tests tests |
17 | + @flake8 --exclude hooks/charmhelpers actions hooks unit_tests tests |
18 | @charm proof |
19 | |
20 | unit_test: |
21 | @@ -24,7 +24,9 @@ |
22 | # raise_status() messages to stderr: |
23 | # https://bugs.launchpad.net/amulet/+bug/1320357 |
24 | @juju test -v -p AMULET_HTTP_PROXY --timeout 900 \ |
25 | - 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse |
26 | + 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse \ |
27 | + 16-basic-trusty-icehouse-git 17-basic-trusty-juno \ |
28 | + 18-basic-trusty-juno-git |
29 | |
30 | publish: lint unit_test |
31 | bzr push lp:charms/nova-compute |
32 | |
33 | === modified file 'README.md' |
34 | --- README.md 2015-02-09 15:39:23 +0000 |
35 | +++ README.md 2015-04-16 14:46:17 +0000 |
36 | @@ -16,17 +16,102 @@ |
37 | - nrpe-external-master - Used to generate Nagios checks. |
38 | |
39 | Database |
40 | --------- |
41 | +======== |
42 | |
43 | Nova compute only requires database access if using nova-network. If using |
44 | Neutron, no direct database access is required and the shared-db relation need |
45 | not be added. |
46 | |
47 | Networking |
48 | ----------- |
49 | +========== |
50 | This charm support nova-network (legacy) and Neutron networking. |
51 | |
52 | Storage |
53 | -------- |
54 | +======= |
55 | This charm supports a number of different storage backends depending on |
56 | your hypervisor type and storage relations. |
57 | + |
58 | +Deploying from source |
59 | +===================== |
60 | + |
61 | +The minimum openstack-origin-git config required to deploy from source is: |
62 | + |
63 | + openstack-origin-git: |
64 | + "repositories: |
65 | + - {name: requirements, |
66 | + repository: 'git://git.openstack.org/openstack/requirements', |
67 | + branch: stable/juno} |
68 | + - {name: nova, |
69 | + repository: 'git://git.openstack.org/openstack/nova', |
70 | + branch: stable/juno}" |
71 | + |
72 | +Note that there are only two 'name' values the charm knows about: 'requirements' |
73 | +and 'nova'. These repositories must correspond to these 'name' values. |
74 | +Additionally, the requirements repository must be specified first and the |
75 | +nova repository must be specified last. All other repostories are installed |
76 | +in the order in which they are specified. |
77 | + |
78 | +The following is a full list of current tip repos (may not be up-to-date): |
79 | + |
80 | + openstack-origin-git: |
81 | + "repositories: |
82 | + - {name: requirements, |
83 | + repository: 'git://git.openstack.org/openstack/requirements', |
84 | + branch: master} |
85 | + - {name: oslo-concurrency, |
86 | + repository: 'git://git.openstack.org/openstack/oslo.concurrency', |
87 | + branch: master} |
88 | + - {name: oslo-config, |
89 | + repository: 'git://git.openstack.org/openstack/oslo.config', |
90 | + branch: master} |
91 | + - {name: oslo-context, |
92 | + repository: 'git://git.openstack.org/openstack/oslo.context.git', |
93 | + branch: master} |
94 | + - {name: oslo-db, |
95 | + repository: 'git://git.openstack.org/openstack/oslo.db', |
96 | + branch: master} |
97 | + - {name: oslo-i18n, |
98 | + repository: 'git://git.openstack.org/openstack/oslo.i18n', |
99 | + branch: master} |
100 | + - {name: oslo-log, |
101 | + repository: 'git://git.openstack.org/openstack/oslo.log', |
102 | + branch: master} |
103 | + - {name: oslo-messaging, |
104 | + repository: 'git://git.openstack.org/openstack/oslo.messaging.git', |
105 | + branch: master} |
106 | + - {name: oslo-middleware, |
107 | + repository': 'git://git.openstack.org/openstack/oslo.middleware.git', |
108 | + branch: master} |
109 | + - {name: oslo-rootwrap', |
110 | + repository: 'git://git.openstack.org/openstack/oslo.rootwrap.git', |
111 | + branch: master} |
112 | + - {name: oslo-serialization, |
113 | + repository: 'git://git.openstack.org/openstack/oslo.serialization', |
114 | + branch: master} |
115 | + - {name: oslo-utils, |
116 | + repository: 'git://git.openstack.org/openstack/oslo.utils', |
117 | + branch: master} |
118 | + - {name: pbr, |
119 | + repository: 'git://git.openstack.org/openstack-dev/pbr', |
120 | + branch: master} |
121 | + - {name: stevedore, |
122 | + repository: 'git://git.openstack.org/openstack/stevedore.git', |
123 | + branch: 'master'} |
124 | + - {name: sqlalchemy-migrate, |
125 | + repository: 'git://git.openstack.org/stackforge/sqlalchemy-migrate', |
126 | + branch: master} |
127 | + - {name: python-cinderclient, |
128 | + repository: 'git://git.openstack.org/openstack/python-cinderclient.git', |
129 | + branch: master} |
130 | + - {name: python-glanceclient, |
131 | + repository': 'git://git.openstack.org/openstack/python-glanceclient.git', |
132 | + branch: master} |
133 | + - {name: python-neutronlient, |
134 | + repository': 'git://git.openstack.org/openstack/python-neutronclient.git', |
135 | + branch: master} |
136 | + - {name: keystonemiddleware, |
137 | + repository: 'git://git.openstack.org/openstack/keystonemiddleware', |
138 | + branch: master} |
139 | + - {name: nova, |
140 | + repository: 'git://git.openstack.org/openstack/nova', |
141 | + branch: master}" |
142 | |
143 | === added directory 'actions' |
144 | === added file 'actions.yaml' |
145 | --- actions.yaml 1970-01-01 00:00:00 +0000 |
146 | +++ actions.yaml 2015-04-16 14:46:17 +0000 |
147 | @@ -0,0 +1,2 @@ |
148 | +git-reinstall: |
149 | + description: Reinstall nova-compute from the openstack-origin-git repositories. |
150 | |
151 | === added symlink 'actions/git-reinstall' |
152 | === target is u'git_reinstall.py' |
153 | === added file 'actions/git_reinstall.py' |
154 | --- actions/git_reinstall.py 1970-01-01 00:00:00 +0000 |
155 | +++ actions/git_reinstall.py 2015-04-16 14:46:17 +0000 |
156 | @@ -0,0 +1,45 @@ |
157 | +#!/usr/bin/python |
158 | +import sys |
159 | +import traceback |
160 | + |
161 | +sys.path.append('hooks/') |
162 | + |
163 | +from charmhelpers.contrib.openstack.utils import ( |
164 | + git_install_requested, |
165 | +) |
166 | + |
167 | +from charmhelpers.core.hookenv import ( |
168 | + action_set, |
169 | + action_fail, |
170 | + config, |
171 | +) |
172 | + |
173 | +from nova_compute_utils import ( |
174 | + git_install, |
175 | +) |
176 | + |
177 | +from nova_compute_hooks import ( |
178 | + config_changed, |
179 | +) |
180 | + |
181 | + |
182 | +def git_reinstall(): |
183 | + """Reinstall from source and restart services. |
184 | + |
185 | + If the openstack-origin-git config option was used to install openstack |
186 | + from source git repositories, then this action can be used to reinstall |
187 | + from updated git repositories, followed by a restart of services.""" |
188 | + if not git_install_requested(): |
189 | + action_fail('openstack-origin-git is not configured') |
190 | + return |
191 | + |
192 | + try: |
193 | + git_install(config('openstack-origin-git')) |
194 | + config_changed() |
195 | + except: |
196 | + action_set({'traceback': traceback.format_exc()}) |
197 | + action_fail('git-reinstall resulted in an unexpected error') |
198 | + |
199 | + |
200 | +if __name__ == '__main__': |
201 | + git_reinstall() |
202 | |
203 | === modified file 'config.yaml' |
204 | --- config.yaml 2015-04-13 12:22:05 +0000 |
205 | +++ config.yaml 2015-04-16 14:46:17 +0000 |
206 | @@ -22,6 +22,22 @@ |
207 | Note that updating this setting to a source that is known to |
208 | provide a later version of OpenStack will trigger a software |
209 | upgrade. |
210 | + |
211 | + Note that when openstack-origin-git is specified, openstack |
212 | + specific packages will be installed from source rather than |
213 | + from the openstack-origin repository. |
214 | + openstack-origin-git: |
215 | + default: |
216 | + type: string |
217 | + description: | |
218 | + Specifies a YAML-formatted dictionary listing the git |
219 | + repositories and branches from which to install OpenStack and |
220 | + its dependencies. |
221 | + |
222 | + Note that the installed config files will be determined based on |
223 | + the OpenStack release of the openstack-origin option. |
224 | + |
225 | + For more details see README.md. |
226 | nova-config: |
227 | default: /etc/nova/nova.conf |
228 | type: string |
229 | |
230 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' |
231 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-04-13 08:57:13 +0000 |
232 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-04-16 14:46:17 +0000 |
233 | @@ -524,9 +524,10 @@ |
234 | projects = yaml.load(projects_yaml) |
235 | _git_validate_projects_yaml(projects, core_project) |
236 | |
237 | + old_environ = dict(os.environ) |
238 | + |
239 | if 'http_proxy' in projects.keys(): |
240 | os.environ['http_proxy'] = projects['http_proxy'] |
241 | - |
242 | if 'https_proxy' in projects.keys(): |
243 | os.environ['https_proxy'] = projects['https_proxy'] |
244 | |
245 | @@ -544,6 +545,8 @@ |
246 | repo_dir = _git_clone_and_install_single(repo, branch, parent_dir, |
247 | update_requirements=True) |
248 | |
249 | + os.environ = old_environ |
250 | + |
251 | |
252 | def _git_validate_projects_yaml(projects, core_project): |
253 | """ |
254 | |
255 | === modified file 'hooks/nova_compute_hooks.py' |
256 | --- hooks/nova_compute_hooks.py 2015-03-31 15:01:48 +0000 |
257 | +++ hooks/nova_compute_hooks.py 2015-04-16 14:46:17 +0000 |
258 | @@ -28,7 +28,9 @@ |
259 | ) |
260 | |
261 | from charmhelpers.contrib.openstack.utils import ( |
262 | + config_value_changed, |
263 | configure_installation_source, |
264 | + git_install_requested, |
265 | openstack_upgrade_available, |
266 | os_requires_version, |
267 | ) |
268 | @@ -43,6 +45,7 @@ |
269 | from nova_compute_utils import ( |
270 | create_libvirt_secret, |
271 | determine_packages, |
272 | + git_install, |
273 | import_authorized_keys, |
274 | import_keystone_ca_cert, |
275 | initialize_ssh_keys, |
276 | @@ -84,9 +87,12 @@ |
277 | def install(): |
278 | execd_preinstall() |
279 | configure_installation_source(config('openstack-origin')) |
280 | + |
281 | apt_update() |
282 | apt_install(determine_packages(), fatal=True) |
283 | |
284 | + git_install(config('openstack-origin-git')) |
285 | + |
286 | |
287 | @hooks.hook('config-changed') |
288 | @restart_on_change(restart_map()) |
289 | @@ -95,8 +101,12 @@ |
290 | assert_charm_supports_ipv6() |
291 | |
292 | global CONFIGS |
293 | - if openstack_upgrade_available('nova-common'): |
294 | - CONFIGS = do_openstack_upgrade() |
295 | + if git_install_requested(): |
296 | + if config_value_changed('openstack-origin-git'): |
297 | + git_install(config('openstack-origin-git')) |
298 | + else: |
299 | + if openstack_upgrade_available('nova-common'): |
300 | + CONFIGS = do_openstack_upgrade() |
301 | |
302 | sysctl_dict = config('sysctl') |
303 | if sysctl_dict: |
304 | |
305 | === modified file 'hooks/nova_compute_utils.py' |
306 | --- hooks/nova_compute_utils.py 2015-04-14 05:26:04 +0000 |
307 | +++ hooks/nova_compute_utils.py 2015-04-16 14:46:17 +0000 |
308 | @@ -1,4 +1,5 @@ |
309 | import os |
310 | +import shutil |
311 | import pwd |
312 | |
313 | from base64 import b64decode |
314 | @@ -8,16 +9,21 @@ |
315 | from charmhelpers.fetch import ( |
316 | apt_update, |
317 | apt_upgrade, |
318 | - apt_install |
319 | + apt_install, |
320 | ) |
321 | |
322 | from charmhelpers.core.host import ( |
323 | + adduser, |
324 | + add_group, |
325 | + add_user_to_group, |
326 | mkdir, |
327 | service_restart, |
328 | - lsb_release |
329 | + lsb_release, |
330 | + write_file, |
331 | ) |
332 | |
333 | from charmhelpers.core.hookenv import ( |
334 | + charm_dir, |
335 | config, |
336 | log, |
337 | related_units, |
338 | @@ -27,6 +33,7 @@ |
339 | INFO, |
340 | ) |
341 | |
342 | +from charmhelpers.core.templating import render |
343 | from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute |
344 | from charmhelpers.contrib.openstack import templating, context |
345 | from charmhelpers.contrib.openstack.alternatives import install_alternative |
346 | @@ -34,6 +41,9 @@ |
347 | from charmhelpers.contrib.openstack.utils import ( |
348 | configure_installation_source, |
349 | get_os_codename_install_source, |
350 | + git_install_requested, |
351 | + git_clone_and_install, |
352 | + git_src_dir, |
353 | os_release |
354 | ) |
355 | |
356 | @@ -61,6 +71,57 @@ |
357 | 'python-six', |
358 | ] |
359 | |
360 | +BASE_GIT_PACKAGES = [ |
361 | + 'libvirt-bin', |
362 | + 'libxml2-dev', |
363 | + 'libxslt1-dev', |
364 | + 'python-dev', |
365 | + 'python-pip', |
366 | + 'python-setuptools', |
367 | + 'zlib1g-dev', |
368 | +] |
369 | + |
370 | +LATE_GIT_PACKAGES = [ |
371 | + 'bridge-utils', |
372 | + 'dnsmasq-base', |
373 | + 'dnsmasq-utils', |
374 | + 'ebtables', |
375 | + 'genisoimage', |
376 | + 'iptables', |
377 | + 'iputils-arping', |
378 | + 'kpartx', |
379 | + 'kvm', |
380 | + 'netcat', |
381 | + 'open-iscsi', |
382 | + 'parted', |
383 | + 'python-libvirt', |
384 | + 'qemu', |
385 | + 'qemu-system', |
386 | + 'qemu-utils', |
387 | + 'vlan', |
388 | + 'xen-system-amd64', |
389 | +] |
390 | + |
391 | +# ubuntu packages that should not be installed when deploying from git |
392 | +GIT_PACKAGE_BLACKLIST = [ |
393 | + 'neutron-plugin-openvswitch', |
394 | + 'neutron-plugin-openvswitch-agent', |
395 | + 'neutron-server', |
396 | + 'nova-api', |
397 | + 'nova-api-metadata', |
398 | + 'nova-compute', |
399 | + 'nova-compute-kvm', |
400 | + 'nova-compute-lxc', |
401 | + 'nova-compute-qemu', |
402 | + 'nova-compute-uml', |
403 | + 'nova-compute-xen', |
404 | + 'nova-network', |
405 | + 'python-six', |
406 | + 'quantum-plugin-openvswitch', |
407 | + 'quantum-plugin-openvswitch-agent', |
408 | + 'quantum-server', |
409 | +] |
410 | + |
411 | NOVA_CONF_DIR = "/etc/nova" |
412 | QEMU_CONF = '/etc/libvirt/qemu.conf' |
413 | LIBVIRTD_CONF = '/etc/libvirt/libvirtd.conf' |
414 | @@ -289,6 +350,14 @@ |
415 | if enable_nova_metadata(): |
416 | packages.append('nova-api-metadata') |
417 | |
418 | + if git_install_requested(): |
419 | + packages = list(set(packages)) |
420 | + packages.extend(BASE_GIT_PACKAGES) |
421 | + # don't include packages that will be installed from git |
422 | + for p in GIT_PACKAGE_BLACKLIST: |
423 | + if p in packages: |
424 | + packages.remove(p) |
425 | + |
426 | return packages |
427 | |
428 | |
429 | @@ -527,3 +596,123 @@ |
430 | |
431 | def manage_ovs(): |
432 | return neutron_plugin_legacy_mode() and neutron_plugin() == 'ovs' |
433 | + |
434 | + |
435 | +def git_install(projects_yaml): |
436 | + """Perform setup, and install git repos specified in yaml parameter.""" |
437 | + if git_install_requested(): |
438 | + git_pre_install() |
439 | + git_clone_and_install(projects_yaml, core_project='nova') |
440 | + git_post_install(projects_yaml) |
441 | + |
442 | + |
443 | +def git_pre_install(): |
444 | + """Perform pre-install setup.""" |
445 | + dirs = [ |
446 | + '/var/lib/nova', |
447 | + '/var/lib/nova/buckets', |
448 | + '/var/lib/nova/CA', |
449 | + '/var/lib/nova/CA/INTER', |
450 | + '/var/lib/nova/CA/newcerts', |
451 | + '/var/lib/nova/CA/private', |
452 | + '/var/lib/nova/CA/reqs', |
453 | + '/var/lib/nova/images', |
454 | + '/var/lib/nova/instances', |
455 | + '/var/lib/nova/keys', |
456 | + '/var/lib/nova/networks', |
457 | + '/var/lib/nova/tmp', |
458 | + '/var/log/nova', |
459 | + ] |
460 | + |
461 | + logs = [ |
462 | + '/var/log/nova/nova-api.log', |
463 | + '/var/log/nova/nova-compute.log', |
464 | + '/var/log/nova/nova-manage.log', |
465 | + '/var/log/nova/nova-network.log', |
466 | + ] |
467 | + |
468 | + adduser('nova', shell='/bin/bash', system_user=True) |
469 | + check_call(['usermod', '--home', '/var/lib/nova', 'nova']) |
470 | + add_group('nova', system_group=True) |
471 | + add_user_to_group('nova', 'nova') |
472 | + add_user_to_group('nova', 'libvirtd') |
473 | + |
474 | + for d in dirs: |
475 | + mkdir(d, owner='nova', group='nova', perms=0755, force=False) |
476 | + |
477 | + for l in logs: |
478 | + write_file(l, '', owner='nova', group='nova', perms=0644) |
479 | + |
480 | + |
481 | +def git_post_install(projects_yaml): |
482 | + """Perform post-install setup.""" |
483 | + src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova') |
484 | + configs = [ |
485 | + {'src': src_etc, |
486 | + 'dest': '/etc/nova'}, |
487 | + ] |
488 | + |
489 | + for c in configs: |
490 | + if os.path.exists(c['dest']): |
491 | + shutil.rmtree(c['dest']) |
492 | + shutil.copytree(c['src'], c['dest']) |
493 | + |
494 | + virt_type = VIRT_TYPES[config('virt-type')][0] |
495 | + nova_compute_conf = 'git/{}.conf'.format(virt_type) |
496 | + render(nova_compute_conf, '/etc/nova/nova-compute.conf', {}, perms=0o644) |
497 | + render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440) |
498 | + |
499 | + service_name = 'nova-compute' |
500 | + nova_user = 'nova' |
501 | + start_dir = '/var/lib/nova' |
502 | + nova_conf = '/etc/nova/nova.conf' |
503 | + nova_api_metadata_context = { |
504 | + 'service_description': 'Nova Metadata API server', |
505 | + 'service_name': service_name, |
506 | + 'user_name': nova_user, |
507 | + 'start_dir': start_dir, |
508 | + 'process_name': 'nova-api-metadata', |
509 | + 'executable_name': '/usr/local/bin/nova-api-metadata', |
510 | + 'config_files': [nova_conf], |
511 | + } |
512 | + nova_api_context = { |
513 | + 'service_description': 'Nova API server', |
514 | + 'service_name': service_name, |
515 | + 'user_name': nova_user, |
516 | + 'start_dir': start_dir, |
517 | + 'process_name': 'nova-api', |
518 | + 'executable_name': '/usr/local/bin/nova-api', |
519 | + 'config_files': [nova_conf], |
520 | + } |
521 | + nova_compute_context = { |
522 | + 'service_description': 'Nova compute worker', |
523 | + 'service_name': service_name, |
524 | + 'user_name': nova_user, |
525 | + 'process_name': 'nova-compute', |
526 | + 'executable_name': '/usr/local/bin/nova-compute', |
527 | + 'config_files': [nova_conf, '/etc/nova/nova-compute.conf'], |
528 | + } |
529 | + nova_network_context = { |
530 | + 'service_description': 'Nova network worker', |
531 | + 'service_name': service_name, |
532 | + 'user_name': nova_user, |
533 | + 'start_dir': start_dir, |
534 | + 'process_name': 'nova-network', |
535 | + 'executable_name': '/usr/local/bin/nova-network', |
536 | + 'config_files': [nova_conf], |
537 | + } |
538 | + |
539 | + # NOTE(coreycb): Needs systemd support |
540 | + templates_dir = 'hooks/charmhelpers/contrib/openstack/templates' |
541 | + templates_dir = os.path.join(charm_dir(), templates_dir) |
542 | + render('git.upstart', '/etc/init/nova-api-metadata.conf', |
543 | + nova_api_metadata_context, perms=0o644, templates_dir=templates_dir) |
544 | + render('git.upstart', '/etc/init/nova-api.conf', |
545 | + nova_api_context, perms=0o644, templates_dir=templates_dir) |
546 | + render('git/upstart/nova-compute.upstart', '/etc/init/nova-compute.conf', |
547 | + nova_compute_context, perms=0o644) |
548 | + render('git.upstart', '/etc/init/nova-network.conf', |
549 | + nova_network_context, perms=0o644, templates_dir=templates_dir) |
550 | + |
551 | + apt_update() |
552 | + apt_install(LATE_GIT_PACKAGES, fatal=True) |
553 | |
554 | === added directory 'templates/git' |
555 | === added file 'templates/git/nova-compute-kvm.conf' |
556 | --- templates/git/nova-compute-kvm.conf 1970-01-01 00:00:00 +0000 |
557 | +++ templates/git/nova-compute-kvm.conf 2015-04-16 14:46:17 +0000 |
558 | @@ -0,0 +1,4 @@ |
559 | +[DEFAULT] |
560 | +compute_driver=libvirt.LibvirtDriver |
561 | +[libvirt] |
562 | +virt_type=kvm |
563 | |
564 | === added file 'templates/git/nova-compute-lxc.conf' |
565 | --- templates/git/nova-compute-lxc.conf 1970-01-01 00:00:00 +0000 |
566 | +++ templates/git/nova-compute-lxc.conf 2015-04-16 14:46:17 +0000 |
567 | @@ -0,0 +1,4 @@ |
568 | +[DEFAULT] |
569 | +compute_driver=libvirt.LibvirtDriver |
570 | +[libvirt] |
571 | +virt_type=lxc |
572 | |
573 | === added file 'templates/git/nova-compute-qemu.conf' |
574 | --- templates/git/nova-compute-qemu.conf 1970-01-01 00:00:00 +0000 |
575 | +++ templates/git/nova-compute-qemu.conf 2015-04-16 14:46:17 +0000 |
576 | @@ -0,0 +1,4 @@ |
577 | +[DEFAULT] |
578 | +compute_driver=libvirt.LibvirtDriver |
579 | +[libvirt] |
580 | +virt_type=qemu |
581 | |
582 | === added file 'templates/git/nova-compute-vmware.conf' |
583 | --- templates/git/nova-compute-vmware.conf 1970-01-01 00:00:00 +0000 |
584 | +++ templates/git/nova-compute-vmware.conf 2015-04-16 14:46:17 +0000 |
585 | @@ -0,0 +1,2 @@ |
586 | +[DEFAULT] |
587 | +compute_driver=vmwareapi.VMwareVCDriver |
588 | |
589 | === added file 'templates/git/nova-compute-xen.conf' |
590 | --- templates/git/nova-compute-xen.conf 1970-01-01 00:00:00 +0000 |
591 | +++ templates/git/nova-compute-xen.conf 2015-04-16 14:46:17 +0000 |
592 | @@ -0,0 +1,4 @@ |
593 | +[DEFAULT] |
594 | +compute_driver=libvirt.LibvirtDriver |
595 | +[libvirt] |
596 | +virt_type=xen |
597 | |
598 | === added file 'templates/git/nova_sudoers' |
599 | --- templates/git/nova_sudoers 1970-01-01 00:00:00 +0000 |
600 | +++ templates/git/nova_sudoers 2015-04-16 14:46:17 +0000 |
601 | @@ -0,0 +1,4 @@ |
602 | +Defaults:nova !requiretty |
603 | + |
604 | +nova ALL = (root) NOPASSWD: /usr/local/bin/nova-rootwrap /etc/nova/rootwrap.conf * |
605 | + |
606 | |
607 | === added file 'templates/git/nova_tgt.conf' |
608 | --- templates/git/nova_tgt.conf 1970-01-01 00:00:00 +0000 |
609 | +++ templates/git/nova_tgt.conf 2015-04-16 14:46:17 +0000 |
610 | @@ -0,0 +1,1 @@ |
611 | +include /var/lib/nova/volumes/* |
612 | |
613 | === added directory 'templates/git/upstart' |
614 | === added file 'templates/git/upstart/nova-compute.upstart' |
615 | --- templates/git/upstart/nova-compute.upstart 1970-01-01 00:00:00 +0000 |
616 | +++ templates/git/upstart/nova-compute.upstart 2015-04-16 14:46:17 +0000 |
617 | @@ -0,0 +1,27 @@ |
618 | +description "{{ service_description }}" |
619 | +author "Juju {{ service_name }} Charm <juju@localhost>" |
620 | + |
621 | +start on runlevel [2345] |
622 | +stop on runlevel [!2345] |
623 | + |
624 | +chdir /var/run |
625 | + |
626 | +pre-start script |
627 | + mkdir -p /var/run/nova |
628 | + chown nova:root /var/run/nova/ |
629 | + |
630 | + mkdir -p /var/lock/nova |
631 | + chown nova:root /var/lock/nova/ |
632 | + |
633 | + modprobe nbd |
634 | + |
635 | + # If libvirt-bin is installed, always wait for it to start first |
636 | + if status libvirt-bin; then |
637 | + start wait-for-state WAIT_FOR=libvirt-bin WAIT_STATE=running WAITER={{ process_name }} |
638 | + fi |
639 | +end script |
640 | + |
641 | +exec start-stop-daemon --start --chuid {{ user_name }} --exec {{ executable_name }} -- \ |
642 | + {% for config_file in config_files -%} |
643 | + --config-file={{ config_file }} \ |
644 | + {% endfor -%} |
645 | |
646 | === removed file 'tests/10-basic-precise-essex' |
647 | --- tests/10-basic-precise-essex 2014-07-11 14:09:08 +0000 |
648 | +++ tests/10-basic-precise-essex 1970-01-01 00:00:00 +0000 |
649 | @@ -1,9 +0,0 @@ |
650 | -#!/usr/bin/python |
651 | - |
652 | -"""Amulet tests on a basic nova compute deployment on precise-essex.""" |
653 | - |
654 | -from basic_deployment import NovaBasicDeployment |
655 | - |
656 | -if __name__ == '__main__': |
657 | - deployment = NovaBasicDeployment(series='precise') |
658 | - deployment.run_tests() |
659 | |
660 | === removed file 'tests/11-basic-precise-folsom' |
661 | --- tests/11-basic-precise-folsom 2014-07-11 14:09:08 +0000 |
662 | +++ tests/11-basic-precise-folsom 1970-01-01 00:00:00 +0000 |
663 | @@ -1,17 +0,0 @@ |
664 | -#!/usr/bin/python |
665 | - |
666 | -"""Amulet tests on a basic nova compute deployment on precise-folsom.""" |
667 | - |
668 | -import amulet |
669 | -from basic_deployment import NovaBasicDeployment |
670 | - |
671 | -if __name__ == '__main__': |
672 | - # NOTE(coreycb): Skipping failing test until resolved. 'nova-manage db sync' |
673 | - # fails in shared-db-relation-changed (only fails on folsom) |
674 | - message = "Skipping failing test until resolved" |
675 | - amulet.raise_status(amulet.SKIP, msg=message) |
676 | - |
677 | - deployment = NovaBasicDeployment(series='precise', |
678 | - openstack='cloud:precise-folsom', |
679 | - source='cloud:precise-updates/folsom') |
680 | - deployment.run_tests() |
681 | |
682 | === removed file 'tests/12-basic-precise-grizzly' |
683 | --- tests/12-basic-precise-grizzly 2014-07-11 14:09:08 +0000 |
684 | +++ tests/12-basic-precise-grizzly 1970-01-01 00:00:00 +0000 |
685 | @@ -1,11 +0,0 @@ |
686 | -#!/usr/bin/python |
687 | - |
688 | -"""Amulet tests on a basic nova compute deployment on precise-grizzly.""" |
689 | - |
690 | -from basic_deployment import NovaBasicDeployment |
691 | - |
692 | -if __name__ == '__main__': |
693 | - deployment = NovaBasicDeployment(series='precise', |
694 | - openstack='cloud:precise-grizzly', |
695 | - source='cloud:precise-updates/grizzly') |
696 | - deployment.run_tests() |
697 | |
698 | === removed file 'tests/13-basic-precise-havana' |
699 | --- tests/13-basic-precise-havana 2014-07-11 14:09:08 +0000 |
700 | +++ tests/13-basic-precise-havana 1970-01-01 00:00:00 +0000 |
701 | @@ -1,11 +0,0 @@ |
702 | -#!/usr/bin/python |
703 | - |
704 | -"""Amulet tests on a basic nova compute deployment on precise-havana.""" |
705 | - |
706 | -from basic_deployment import NovaBasicDeployment |
707 | - |
708 | -if __name__ == '__main__': |
709 | - deployment = NovaBasicDeployment(series='precise', |
710 | - openstack='cloud:precise-havana', |
711 | - source='cloud:precise-updates/havana') |
712 | - deployment.run_tests() |
713 | |
714 | === added file 'tests/16-basic-trusty-icehouse-git' |
715 | --- tests/16-basic-trusty-icehouse-git 1970-01-01 00:00:00 +0000 |
716 | +++ tests/16-basic-trusty-icehouse-git 2015-04-16 14:46:17 +0000 |
717 | @@ -0,0 +1,9 @@ |
718 | +#!/usr/bin/python |
719 | + |
720 | +"""Amulet tests on a basic nova compute git deployment on trusty-icehouse.""" |
721 | + |
722 | +from basic_deployment import NovaBasicDeployment |
723 | + |
724 | +if __name__ == '__main__': |
725 | + deployment = NovaBasicDeployment(series='trusty', git=True) |
726 | + deployment.run_tests() |
727 | |
728 | === added file 'tests/17-basic-trusty-juno' |
729 | --- tests/17-basic-trusty-juno 1970-01-01 00:00:00 +0000 |
730 | +++ tests/17-basic-trusty-juno 2015-04-16 14:46:17 +0000 |
731 | @@ -0,0 +1,11 @@ |
732 | +#!/usr/bin/python |
733 | + |
734 | +"""Amulet tests on a basic nova compute deployment on trusty-juno.""" |
735 | + |
736 | +from basic_deployment import NovaBasicDeployment |
737 | + |
738 | +if __name__ == '__main__': |
739 | + deployment = NovaBasicDeployment(series='trusty', |
740 | + openstack='cloud:trusty-juno', |
741 | + source='cloud:trusty-updates/juno') |
742 | + deployment.run_tests() |
743 | |
744 | === added file 'tests/18-basic-trusty-juno-git' |
745 | --- tests/18-basic-trusty-juno-git 1970-01-01 00:00:00 +0000 |
746 | +++ tests/18-basic-trusty-juno-git 2015-04-16 14:46:17 +0000 |
747 | @@ -0,0 +1,12 @@ |
748 | +#!/usr/bin/python |
749 | + |
750 | +"""Amulet tests on a basic nova compute git deployment on trusty-juno.""" |
751 | + |
752 | +from basic_deployment import NovaBasicDeployment |
753 | + |
754 | +if __name__ == '__main__': |
755 | + deployment = NovaBasicDeployment(series='trusty', |
756 | + openstack='cloud:trusty-juno', |
757 | + source='cloud:trusty-updates/juno', |
758 | + git=True) |
759 | + deployment.run_tests() |
760 | |
761 | === modified file 'tests/basic_deployment.py' |
762 | --- tests/basic_deployment.py 2015-04-14 09:02:53 +0000 |
763 | +++ tests/basic_deployment.py 2015-04-16 14:46:17 +0000 |
764 | @@ -1,7 +1,9 @@ |
765 | #!/usr/bin/python |
766 | |
767 | import amulet |
768 | +import os |
769 | import time |
770 | +import yaml |
771 | |
772 | from charmhelpers.contrib.openstack.amulet.deployment import ( |
773 | OpenStackAmuletDeployment |
774 | @@ -20,9 +22,11 @@ |
775 | class NovaBasicDeployment(OpenStackAmuletDeployment): |
776 | """Amulet tests on a basic nova compute deployment.""" |
777 | |
778 | - def __init__(self, series=None, openstack=None, source=None, stable=False): |
779 | + def __init__(self, series=None, openstack=None, source=None, git=False, |
780 | + stable=True): |
781 | """Deploy the entire test environment.""" |
782 | super(NovaBasicDeployment, self).__init__(series, openstack, source, stable) |
783 | + self.git = git |
784 | self._add_services() |
785 | self._add_relations() |
786 | self._configure_services() |
787 | @@ -65,6 +69,24 @@ |
788 | """Configure all of the services.""" |
789 | nova_config = {'config-flags': 'auto_assign_floating_ip=False', |
790 | 'enable-live-migration': 'False'} |
791 | + if self.git: |
792 | + branch = 'stable/' + self._get_openstack_release_string() |
793 | + amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY') |
794 | + openstack_origin_git = { |
795 | + 'repositories': [ |
796 | + {'name': 'requirements', |
797 | + 'repository': 'git://git.openstack.org/openstack/requirements', |
798 | + 'branch': branch}, |
799 | + {'name': 'nova', |
800 | + 'repository': 'git://git.openstack.org/openstack/nova', |
801 | + 'branch': branch}, |
802 | + ], |
803 | + 'directory': '/mnt/openstack-git', |
804 | + 'http_proxy': amulet_http_proxy, |
805 | + 'https_proxy': amulet_http_proxy, |
806 | + } |
807 | + nova_config['openstack-origin-git'] = yaml.dump(openstack_origin_git) |
808 | + |
809 | keystone_config = {'admin-password': 'openstack', |
810 | 'admin-token': 'ubuntutesting'} |
811 | configs = {'nova-compute': nova_config, 'keystone': keystone_config} |
812 | |
813 | === modified file 'unit_tests/__init__.py' |
814 | --- unit_tests/__init__.py 2013-07-26 21:22:44 +0000 |
815 | +++ unit_tests/__init__.py 2015-04-16 14:46:17 +0000 |
816 | @@ -1,3 +1,4 @@ |
817 | import sys |
818 | |
819 | +sys.path.append('actions/') |
820 | sys.path.append('hooks/') |
821 | |
822 | === added file 'unit_tests/test_actions_git_reinstall.py' |
823 | --- unit_tests/test_actions_git_reinstall.py 1970-01-01 00:00:00 +0000 |
824 | +++ unit_tests/test_actions_git_reinstall.py 2015-04-16 14:46:17 +0000 |
825 | @@ -0,0 +1,96 @@ |
826 | +from mock import patch |
827 | + |
828 | +with patch('charmhelpers.core.hookenv.config') as config: |
829 | + config.return_value = 'nova' |
830 | + import nova_compute_utils as utils # noqa |
831 | + |
832 | +with patch('nova_compute_utils.restart_map'): |
833 | + with patch('nova_compute_utils.register_configs'): |
834 | + import git_reinstall |
835 | + |
836 | +from test_utils import ( |
837 | + CharmTestCase |
838 | +) |
839 | + |
840 | +TO_PATCH = [ |
841 | + 'config', |
842 | +] |
843 | + |
844 | + |
845 | +openstack_origin_git = \ |
846 | + """repositories: |
847 | + - {name: requirements, |
848 | + repository: 'git://git.openstack.org/openstack/requirements', |
849 | + branch: stable/juno} |
850 | + - {name: nova, |
851 | + repository: 'git://git.openstack.org/openstack/nova', |
852 | + branch: stable/juno}""" |
853 | + |
854 | + |
855 | +class TestnovaAPIActions(CharmTestCase): |
856 | + |
857 | + def setUp(self): |
858 | + super(TestnovaAPIActions, self).setUp(git_reinstall, TO_PATCH) |
859 | + self.config.side_effect = self.test_config.get |
860 | + |
861 | + @patch.object(git_reinstall, 'action_set') |
862 | + @patch.object(git_reinstall, 'action_fail') |
863 | + @patch.object(git_reinstall, 'git_install') |
864 | + @patch.object(git_reinstall, 'config_changed') |
865 | + def test_git_reinstall(self, config_changed, git_install, action_fail, |
866 | + action_set): |
867 | + self.test_config.set('openstack-origin-git', openstack_origin_git) |
868 | + |
869 | + git_reinstall.git_reinstall() |
870 | + |
871 | + git_install.assert_called_with(openstack_origin_git) |
872 | + self.assertTrue(git_install.called) |
873 | + self.assertTrue(config_changed.called) |
874 | + self.assertFalse(action_set.called) |
875 | + self.assertFalse(action_fail.called) |
876 | + |
877 | + @patch.object(git_reinstall, 'action_set') |
878 | + @patch.object(git_reinstall, 'action_fail') |
879 | + @patch.object(git_reinstall, 'git_install') |
880 | + @patch.object(git_reinstall, 'config_changed') |
881 | + @patch('charmhelpers.contrib.openstack.utils.config') |
882 | + def test_git_reinstall_not_configured(self, _config, config_changed, |
883 | + git_install, action_fail, |
884 | + action_set): |
885 | + _config.return_value = None |
886 | + |
887 | + git_reinstall.git_reinstall() |
888 | + |
889 | + msg = 'openstack-origin-git is not configured' |
890 | + action_fail.assert_called_with(msg) |
891 | + self.assertFalse(git_install.called) |
892 | + self.assertFalse(action_set.called) |
893 | + |
894 | + @patch.object(git_reinstall, 'action_set') |
895 | + @patch.object(git_reinstall, 'action_fail') |
896 | + @patch.object(git_reinstall, 'git_install') |
897 | + @patch.object(git_reinstall, 'config_changed') |
898 | + @patch('traceback.format_exc') |
899 | + @patch('charmhelpers.contrib.openstack.utils.config') |
900 | + def test_git_reinstall_exception(self, _config, format_exc, |
901 | + config_changed, git_install, action_fail, |
902 | + action_set): |
903 | + _config.return_value = openstack_origin_git |
904 | + e = OSError('something bad happened') |
905 | + git_install.side_effect = e |
906 | + traceback = ( |
907 | + "Traceback (most recent call last):\n" |
908 | + " File \"actions/git_reinstall.py\", line 37, in git_reinstall\n" |
909 | + " git_install(config(\'openstack-origin-git\'))\n" |
910 | + " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 964, in __call__\n" # noqa |
911 | + " return _mock_self._mock_call(*args, **kwargs)\n" |
912 | + " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 1019, in _mock_call\n" # noqa |
913 | + " raise effect\n" |
914 | + "OSError: something bad happened\n") |
915 | + format_exc.return_value = traceback |
916 | + |
917 | + git_reinstall.git_reinstall() |
918 | + |
919 | + msg = 'git-reinstall resulted in an unexpected error' |
920 | + action_fail.assert_called_with(msg) |
921 | + action_set.assert_called_with({'traceback': traceback}) |
922 | |
923 | === modified file 'unit_tests/test_nova_compute_hooks.py' |
924 | --- unit_tests/test_nova_compute_hooks.py 2015-03-31 15:01:48 +0000 |
925 | +++ unit_tests/test_nova_compute_hooks.py 2015-04-16 14:46:17 +0000 |
926 | @@ -3,6 +3,7 @@ |
927 | patch, |
928 | MagicMock |
929 | ) |
930 | +import yaml |
931 | |
932 | from test_utils import CharmTestCase |
933 | |
934 | @@ -48,6 +49,8 @@ |
935 | 'disable_shell', |
936 | 'enable_shell', |
937 | 'update_nrpe_config', |
938 | + 'git_install', |
939 | + 'git_install_requested', |
940 | # misc_utils |
941 | 'ensure_ceph_keyring', |
942 | 'execd_preinstall', |
943 | @@ -77,13 +80,40 @@ |
944 | self.apt_install.assert_called_with(['foo', 'bar'], fatal=True) |
945 | self.execd_preinstall.assert_called() |
946 | |
947 | + def test_install_hook_git(self): |
948 | + self.git_install_requested.return_value = True |
949 | + self.determine_packages.return_value = ['foo', 'bar'] |
950 | + repo = 'cloud:trusty-juno' |
951 | + openstack_origin_git = { |
952 | + 'repositories': [ |
953 | + {'name': 'requirements', |
954 | + 'repository': 'git://git.openstack.org/openstack/requirements', # noqa |
955 | + 'branch': 'stable/juno'}, |
956 | + {'name': 'nova', |
957 | + 'repository': 'git://git.openstack.org/openstack/nova', |
958 | + 'branch': 'stable/juno'} |
959 | + ], |
960 | + 'directory': '/mnt/openstack-git', |
961 | + } |
962 | + projects_yaml = yaml.dump(openstack_origin_git) |
963 | + self.test_config.set('openstack-origin', repo) |
964 | + self.test_config.set('openstack-origin-git', projects_yaml) |
965 | + hooks.install() |
966 | + self.configure_installation_source.assert_called_with(repo) |
967 | + self.assertTrue(self.apt_update.called) |
968 | + self.apt_install.assert_called_with(['foo', 'bar'], fatal=True) |
969 | + self.git_install.assert_called_with(projects_yaml) |
970 | + self.execd_preinstall.assert_called() |
971 | + |
972 | def test_config_changed_with_upgrade(self): |
973 | + self.git_install_requested.return_value = False |
974 | self.openstack_upgrade_available.return_value = True |
975 | hooks.config_changed() |
976 | self.assertTrue(self.do_openstack_upgrade.called) |
977 | |
978 | @patch.object(hooks, 'compute_joined') |
979 | def test_config_changed_with_migration(self, compute_joined): |
980 | + self.git_install_requested.return_value = False |
981 | self.migration_enabled.return_value = True |
982 | _zmq_joined = self.patch('zeromq_configuration_relation_joined') |
983 | self.test_config.set('migration-auth-type', 'ssh') |
984 | @@ -102,6 +132,7 @@ |
985 | |
986 | @patch.object(hooks, 'compute_joined') |
987 | def test_config_changed_with_resize(self, compute_joined): |
988 | + self.git_install_requested.return_value = False |
989 | self.test_config.set('enable-resize', True) |
990 | _zmq_joined = self.patch('zeromq_configuration_relation_joined') |
991 | self.relation_ids.return_value = [ |
992 | @@ -120,6 +151,7 @@ |
993 | |
994 | @patch.object(hooks, 'compute_joined') |
995 | def test_config_changed_without_resize(self, compute_joined): |
996 | + self.git_install_requested.return_value = False |
997 | self.test_config.set('enable-resize', False) |
998 | _zmq_joined = self.patch('zeromq_configuration_relation_joined') |
999 | self.relation_ids.return_value = [ |
1000 | @@ -137,6 +169,7 @@ |
1001 | |
1002 | @patch.object(hooks, 'compute_joined') |
1003 | def test_config_changed_no_upgrade_no_migration(self, compute_joined): |
1004 | + self.git_install_requested.return_value = False |
1005 | self.openstack_upgrade_available.return_value = False |
1006 | self.migration_enabled.return_value = False |
1007 | hooks.config_changed() |
1008 | @@ -145,10 +178,34 @@ |
1009 | |
1010 | @patch.object(hooks, 'compute_joined') |
1011 | def test_config_changed_with_sysctl(self, compute_joined): |
1012 | + self.git_install_requested.return_value = False |
1013 | self.test_config.set('sysctl', '{ kernel.max_pid : "1337" }') |
1014 | hooks.config_changed() |
1015 | self.create_sysctl.assert_called() |
1016 | |
1017 | + @patch.object(hooks, 'config_value_changed') |
1018 | + def test_config_changed_git(self, config_val_changed): |
1019 | + self.git_install_requested.return_value = True |
1020 | + repo = 'cloud:trusty-juno' |
1021 | + openstack_origin_git = { |
1022 | + 'repositories': [ |
1023 | + {'name': 'requirements', |
1024 | + 'repository': |
1025 | + 'git://git.openstack.org/openstack/requirements', |
1026 | + 'branch': 'stable/juno'}, |
1027 | + {'name': 'nova', |
1028 | + 'repository': 'git://git.openstack.org/openstack/nova', |
1029 | + 'branch': 'stable/juno'} |
1030 | + ], |
1031 | + 'directory': '/mnt/openstack-git', |
1032 | + } |
1033 | + projects_yaml = yaml.dump(openstack_origin_git) |
1034 | + self.test_config.set('openstack-origin', repo) |
1035 | + self.test_config.set('openstack-origin-git', projects_yaml) |
1036 | + hooks.config_changed() |
1037 | + self.git_install.assert_called_with(projects_yaml) |
1038 | + self.assertFalse(self.do_openstack_upgrade.called) |
1039 | + |
1040 | def test_amqp_joined(self): |
1041 | hooks.amqp_joined() |
1042 | self.relation_set.assert_called_with( |
1043 | |
1044 | === modified file 'unit_tests/test_nova_compute_utils.py' |
1045 | --- unit_tests/test_nova_compute_utils.py 2015-03-31 11:43:21 +0000 |
1046 | +++ unit_tests/test_nova_compute_utils.py 2015-04-16 14:46:17 +0000 |
1047 | @@ -35,6 +35,15 @@ |
1048 | |
1049 | OVS_PKGS_FLAT = list(itertools.chain.from_iterable(OVS_PKGS)) |
1050 | |
1051 | +openstack_origin_git = \ |
1052 | + """repositories: |
1053 | + - {name: requirements, |
1054 | + repository: 'git://git.openstack.org/openstack/requirements', |
1055 | + branch: stable/juno} |
1056 | + - {name: nova, |
1057 | + repository: 'git://git.openstack.org/openstack/nova', |
1058 | + branch: stable/juno}""" |
1059 | + |
1060 | |
1061 | class NovaComputeUtilsTests(CharmTestCase): |
1062 | |
1063 | @@ -44,7 +53,10 @@ |
1064 | |
1065 | @patch.object(utils, 'enable_nova_metadata') |
1066 | @patch.object(utils, 'network_manager') |
1067 | - def test_determine_packages_nova_network(self, net_man, en_meta): |
1068 | + @patch.object(utils, 'git_install_requested') |
1069 | + def test_determine_packages_nova_network(self, git_requested, net_man, |
1070 | + en_meta): |
1071 | + git_requested.return_value = False |
1072 | en_meta.return_value = False |
1073 | net_man.return_value = 'flatdhcpmanager' |
1074 | self.relation_ids.return_value = [] |
1075 | @@ -59,7 +71,10 @@ |
1076 | @patch.object(utils, 'enable_nova_metadata') |
1077 | @patch.object(utils, 'neutron_plugin') |
1078 | @patch.object(utils, 'network_manager') |
1079 | - def test_determine_packages_quantum(self, net_man, n_plugin, en_meta): |
1080 | + @patch.object(utils, 'git_install_requested') |
1081 | + def test_determine_packages_quantum(self, git_requested, net_man, n_plugin, |
1082 | + en_meta): |
1083 | + git_requested.return_value = False |
1084 | en_meta.return_value = False |
1085 | self.neutron_plugin_attribute.return_value = OVS_PKGS |
1086 | net_man.return_value = 'quantum' |
1087 | @@ -73,8 +88,11 @@ |
1088 | @patch.object(utils, 'enable_nova_metadata') |
1089 | @patch.object(utils, 'neutron_plugin') |
1090 | @patch.object(utils, 'network_manager') |
1091 | - def test_determine_packages_quantum_legacy_off(self, net_man, n_plugin, |
1092 | + @patch.object(utils, 'git_install_requested') |
1093 | + def test_determine_packages_quantum_legacy_off(self, git_requested, |
1094 | + net_man, n_plugin, |
1095 | en_meta, leg_mode): |
1096 | + git_requested.return_value = False |
1097 | en_meta.return_value = False |
1098 | leg_mode.return_value = False |
1099 | self.neutron_plugin_attribute.return_value = OVS_PKGS |
1100 | @@ -89,8 +107,10 @@ |
1101 | @patch.object(utils, 'enable_nova_metadata') |
1102 | @patch.object(utils, 'neutron_plugin') |
1103 | @patch.object(utils, 'network_manager') |
1104 | - def test_determine_packages_quantum_ceph(self, net_man, n_plugin, en_meta, |
1105 | - leg_mode): |
1106 | + @patch.object(utils, 'git_install_requested') |
1107 | + def test_determine_packages_quantum_ceph(self, git_requested, net_man, |
1108 | + n_plugin, en_meta, leg_mode): |
1109 | + git_requested.return_value = False |
1110 | en_meta.return_value = False |
1111 | leg_mode.return_value = True |
1112 | self.neutron_plugin_attribute.return_value = OVS_PKGS |
1113 | @@ -105,7 +125,10 @@ |
1114 | @patch.object(utils, 'enable_nova_metadata') |
1115 | @patch.object(utils, 'neutron_plugin') |
1116 | @patch.object(utils, 'network_manager') |
1117 | - def test_determine_packages_metadata(self, net_man, n_plugin, en_meta): |
1118 | + @patch.object(utils, 'git_install_requested') |
1119 | + def test_determine_packages_metadata(self, git_requested, net_man, |
1120 | + n_plugin, en_meta): |
1121 | + git_requested.return_value = False |
1122 | en_meta.return_value = True |
1123 | self.neutron_plugin_attribute.return_value = OVS_PKGS |
1124 | net_man.return_value = 'bob' |
1125 | @@ -475,3 +498,163 @@ |
1126 | _neutron_plugin_legacy_mode.return_value = True |
1127 | _neutron_plugin.return_value = 'bobvs' |
1128 | self.assertFalse(utils.manage_ovs()) |
1129 | + |
1130 | + @patch.object(utils, 'git_install_requested') |
1131 | + @patch.object(utils, 'git_clone_and_install') |
1132 | + @patch.object(utils, 'git_post_install') |
1133 | + @patch.object(utils, 'git_pre_install') |
1134 | + def test_git_install(self, git_pre, git_post, git_clone_and_install, |
1135 | + git_requested): |
1136 | + projects_yaml = openstack_origin_git |
1137 | + git_requested.return_value = True |
1138 | + utils.git_install(projects_yaml) |
1139 | + self.assertTrue(git_pre.called) |
1140 | + git_clone_and_install.assert_called_with(openstack_origin_git, |
1141 | + core_project='nova') |
1142 | + self.assertTrue(git_post.called) |
1143 | + |
1144 | + @patch.object(utils, 'mkdir') |
1145 | + @patch.object(utils, 'write_file') |
1146 | + @patch.object(utils, 'add_user_to_group') |
1147 | + @patch.object(utils, 'add_group') |
1148 | + @patch.object(utils, 'adduser') |
1149 | + @patch.object(utils, 'check_call') |
1150 | + def test_git_pre_install(self, check_call, adduser, add_group, |
1151 | + add_user_to_group, write_file, mkdir): |
1152 | + utils.git_pre_install() |
1153 | + adduser.assert_called_with('nova', shell='/bin/bash', |
1154 | + system_user=True) |
1155 | + check_call.assert_called_with(['usermod', '--home', '/var/lib/nova', |
1156 | + 'nova']) |
1157 | + add_group.assert_called_with('nova', system_group=True) |
1158 | + expected = [ |
1159 | + call('nova', 'nova'), |
1160 | + call('nova', 'libvirtd'), |
1161 | + ] |
1162 | + self.assertEquals(add_user_to_group.call_args_list, expected) |
1163 | + expected = [ |
1164 | + call('/var/lib/nova', owner='nova', |
1165 | + group='nova', perms=0755, force=False), |
1166 | + call('/var/lib/nova/buckets', owner='nova', |
1167 | + group='nova', perms=0755, force=False), |
1168 | + call('/var/lib/nova/CA', owner='nova', |
1169 | + group='nova', perms=0755, force=False), |
1170 | + call('/var/lib/nova/CA/INTER', owner='nova', |
1171 | + group='nova', perms=0755, force=False), |
1172 | + call('/var/lib/nova/CA/newcerts', owner='nova', |
1173 | + group='nova', perms=0755, force=False), |
1174 | + call('/var/lib/nova/CA/private', owner='nova', |
1175 | + group='nova', perms=0755, force=False), |
1176 | + call('/var/lib/nova/CA/reqs', owner='nova', |
1177 | + group='nova', perms=0755, force=False), |
1178 | + call('/var/lib/nova/images', owner='nova', |
1179 | + group='nova', perms=0755, force=False), |
1180 | + call('/var/lib/nova/instances', owner='nova', |
1181 | + group='nova', perms=0755, force=False), |
1182 | + call('/var/lib/nova/keys', owner='nova', |
1183 | + group='nova', perms=0755, force=False), |
1184 | + call('/var/lib/nova/networks', owner='nova', |
1185 | + group='nova', perms=0755, force=False), |
1186 | + call('/var/lib/nova/tmp', owner='nova', |
1187 | + group='nova', perms=0755, force=False), |
1188 | + call('/var/log/nova', owner='nova', |
1189 | + group='nova', perms=0755, force=False), |
1190 | + ] |
1191 | + self.assertEquals(mkdir.call_args_list, expected) |
1192 | + expected = [ |
1193 | + call('/var/log/nova/nova-api.log', '', owner='nova', |
1194 | + group='nova', perms=0644), |
1195 | + call('/var/log/nova/nova-compute.log', '', owner='nova', |
1196 | + group='nova', perms=0644), |
1197 | + call('/var/log/nova/nova-manage.log', '', owner='nova', |
1198 | + group='nova', perms=0644), |
1199 | + call('/var/log/nova/nova-network.log', '', owner='nova', |
1200 | + group='nova', perms=0644), |
1201 | + ] |
1202 | + self.assertEquals(write_file.call_args_list, expected) |
1203 | + |
1204 | + @patch.object(utils, 'git_src_dir') |
1205 | + @patch.object(utils, 'service_restart') |
1206 | + @patch.object(utils, 'render') |
1207 | + @patch('os.path.join') |
1208 | + @patch('os.path.exists') |
1209 | + @patch('shutil.copytree') |
1210 | + @patch('shutil.rmtree') |
1211 | + @patch.object(utils, 'apt_install') |
1212 | + @patch.object(utils, 'apt_update') |
1213 | + def test_git_post_install(self, apt_update, apt_install, rmtree, copytree, |
1214 | + exists, join, render, service_restart, |
1215 | + git_src_dir): |
1216 | + projects_yaml = openstack_origin_git |
1217 | + join.return_value = 'joined-string' |
1218 | + utils.git_post_install(projects_yaml) |
1219 | + expected = [ |
1220 | + call('joined-string', '/etc/nova'), |
1221 | + ] |
1222 | + copytree.assert_has_calls(expected) |
1223 | + |
1224 | + service_name = 'nova-compute' |
1225 | + nova_user = 'nova' |
1226 | + start_dir = '/var/lib/nova' |
1227 | + nova_conf = '/etc/nova/nova.conf' |
1228 | + nova_api_metadata_context = { |
1229 | + 'service_description': 'Nova Metadata API server', |
1230 | + 'service_name': service_name, |
1231 | + 'user_name': nova_user, |
1232 | + 'start_dir': start_dir, |
1233 | + 'process_name': 'nova-api-metadata', |
1234 | + 'executable_name': '/usr/local/bin/nova-api-metadata', |
1235 | + 'config_files': [nova_conf], |
1236 | + } |
1237 | + nova_api_context = { |
1238 | + 'service_description': 'Nova API server', |
1239 | + 'service_name': service_name, |
1240 | + 'user_name': nova_user, |
1241 | + 'start_dir': start_dir, |
1242 | + 'process_name': 'nova-api', |
1243 | + 'executable_name': '/usr/local/bin/nova-api', |
1244 | + 'config_files': [nova_conf], |
1245 | + } |
1246 | + nova_compute_context = { |
1247 | + 'service_description': 'Nova compute worker', |
1248 | + 'service_name': service_name, |
1249 | + 'user_name': nova_user, |
1250 | + 'process_name': 'nova-compute', |
1251 | + 'executable_name': '/usr/local/bin/nova-compute', |
1252 | + 'config_files': [nova_conf, '/etc/nova/nova-compute.conf'], |
1253 | + } |
1254 | + nova_network_context = { |
1255 | + 'service_description': 'Nova network worker', |
1256 | + 'service_name': service_name, |
1257 | + 'user_name': nova_user, |
1258 | + 'start_dir': start_dir, |
1259 | + 'process_name': 'nova-network', |
1260 | + 'executable_name': '/usr/local/bin/nova-network', |
1261 | + 'config_files': [nova_conf], |
1262 | + } |
1263 | + expected = [ |
1264 | + call('git/nova-compute-kvm.conf', '/etc/nova/nova-compute.conf', |
1265 | + {}, perms=0o644), |
1266 | + call('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', |
1267 | + {}, perms=0o440), |
1268 | + call('git.upstart', '/etc/init/nova-api-metadata.conf', |
1269 | + nova_api_metadata_context, perms=0o644, |
1270 | + templates_dir='joined-string'), |
1271 | + call('git.upstart', '/etc/init/nova-api.conf', |
1272 | + nova_api_context, perms=0o644, |
1273 | + templates_dir='joined-string'), |
1274 | + call('git/upstart/nova-compute.upstart', |
1275 | + '/etc/init/nova-compute.conf', |
1276 | + nova_compute_context, perms=0o644), |
1277 | + call('git.upstart', '/etc/init/nova-network.conf', |
1278 | + nova_network_context, perms=0o644, |
1279 | + templates_dir='joined-string'), |
1280 | + ] |
1281 | + self.assertEquals(render.call_args_list, expected) |
1282 | + self.assertTrue(apt_update.called) |
1283 | + apt_install.assert_called_with( |
1284 | + ['bridge-utils', 'dnsmasq-base', |
1285 | + 'dnsmasq-utils', 'ebtables', 'genisoimage', 'iptables', |
1286 | + 'iputils-arping', 'kpartx', 'kvm', 'netcat', 'open-iscsi', |
1287 | + 'parted', 'python-libvirt', 'qemu', 'qemu-system', |
1288 | + 'qemu-utils', 'vlan', 'xen-system-amd64'], fatal=True) |
charm_lint_check #3331 nova-compute-next for corey.bryant mp255945
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/3331/