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