Merge lp:~corey.bryant/charms/trusty/nova-cloud-controller/git-ods into lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
- Trusty Tahr (14.04)
- git-ods
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 166 |
Proposed branch: | lp:~corey.bryant/charms/trusty/nova-cloud-controller/git-ods |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next |
Diff against target: |
1342 lines (+1001/-21) 17 files modified
.bzrignore (+1/-0) Makefile (+1/-1) README.txt (+89/-0) actions.yaml (+2/-0) actions/git_reinstall.py (+45/-0) config.yaml (+16/-0) hooks/nova_cc_hooks.py (+17/-6) hooks/nova_cc_utils.py (+323/-3) templates/git/nova_sudoers (+4/-0) tests/050-basic-trusty-icehouse-git (+10/-0) tests/051-basic-trusty-juno-git (+13/-0) tests/basic_deployment.py (+25/-2) unit_tests/__init__.py (+2/-0) unit_tests/test_actions_git_reinstall.py (+107/-0) unit_tests/test_nova_cc_contexts.py (+1/-3) unit_tests/test_nova_cc_hooks.py (+56/-0) unit_tests/test_nova_cc_utils.py (+289/-6) |
To merge this branch: | bzr merge lp:~corey.bryant/charms/trusty/nova-cloud-controller/git-ods |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Page | Needs Fixing | ||
Review via email: mp+258923@code.launchpad.net |
Commit message
Description of the change
- 176. By Corey Bryant
-
Add libyaml-dev as base git package
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #4188 nova-cloud-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #4086 nova-cloud-
AMULET OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #4531 nova-cloud-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #4256 nova-cloud-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #4110 nova-cloud-
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 #4539 nova-cloud-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #4264 nova-cloud-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #4118 nova-cloud-
AMULET OK: passed
Build: http://
- 177. By Corey Bryant
-
Sync charm-helpers
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #4843 nova-cloud-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #4523 nova-cloud-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #4334 nova-cloud-
AMULET OK: passed
Build: http://
James Page (james-page) wrote : | # |
Looks OK - but see unit test failure on merged branch:
=======
ERROR: test_config_
-------
Traceback (most recent call last):
File "/usr/lib/
return func(*args, **keywargs)
File "/home/
hooks.
File "hooks/
f(*args)
File "hooks/
f(*args, **kwargs)
File "hooks/
if config_
File "hooks/
with hook_data():
File "/usr/lib/
return self.gen.next()
File "hooks/
self.
File "hooks/
os.
File "/usr/lib/
elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'
- 178. By Corey Bryant
-
Merge next branch
- 179. By Corey Bryant
-
Update failing unit test
Corey Bryant (corey.bryant) wrote : | # |
Thanks for the review! I've merged the latest next branch and updated the failing test.
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #5239 nova-cloud-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #4918 nova-cloud-
UNIT OK: passed
- 180. By Corey Bryant
-
Merge next branch
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #5338 nova-cloud-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #4971 nova-cloud-
UNIT OK: passed
Preview Diff
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2015-04-20 10:21:36 +0000 | |||
3 | +++ .bzrignore 2015-06-11 13:34:00 +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-04-20 10:21:36 +0000 | |||
11 | +++ Makefile 2015-06-11 13:34:00 +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 | 9 | 9 | ||
22 | === modified file 'README.txt' | |||
23 | --- README.txt 2015-04-20 10:21:36 +0000 | |||
24 | +++ README.txt 2015-06-11 13:34:00 +0000 | |||
25 | @@ -23,3 +23,92 @@ | |||
26 | 23 | 23 | ||
27 | 24 | juju add-relation "nova-cloud-controller:pgsql-nova-db" "postgresql:db" | 24 | juju add-relation "nova-cloud-controller:pgsql-nova-db" "postgresql:db" |
28 | 25 | juju add-relation "nova-cloud-controller:pgsql-neutron-db" "postgresql:db" | 25 | juju add-relation "nova-cloud-controller:pgsql-neutron-db" "postgresql:db" |
29 | 26 | |||
30 | 27 | Deploying from source | ||
31 | 28 | ===================== | ||
32 | 29 | |||
33 | 30 | The minimum openstack-origin-git config required to deploy from source is: | ||
34 | 31 | |||
35 | 32 | openstack-origin-git: include-file://nova-juno.yaml | ||
36 | 33 | |||
37 | 34 | nova-juno.yaml | ||
38 | 35 | repositories: | ||
39 | 36 | - {name: requirements, | ||
40 | 37 | repository: 'git://github.com/openstack/requirements', | ||
41 | 38 | branch: stable/juno} | ||
42 | 39 | - {name: nova, | ||
43 | 40 | repository: 'git://github.com/openstack/nova', | ||
44 | 41 | branch: stable/juno} | ||
45 | 42 | |||
46 | 43 | Note that there are only two 'name' values the charm knows about: 'requirements' | ||
47 | 44 | and 'nova'. These repositories must correspond to these 'name' values. | ||
48 | 45 | Additionally, the requirements repository must be specified first and the | ||
49 | 46 | nova repository must be specified last. All other repostories are installed | ||
50 | 47 | in the order in which they are specified. | ||
51 | 48 | |||
52 | 49 | The following is a full list of current tip repos (may not be up-to-date): | ||
53 | 50 | |||
54 | 51 | openstack-origin-git: include-file://nova-master.yaml | ||
55 | 52 | |||
56 | 53 | nova-master.yaml | ||
57 | 54 | repositories: | ||
58 | 55 | - {name: requirements, | ||
59 | 56 | repository: 'git://github.com/openstack/requirements', | ||
60 | 57 | branch: master} | ||
61 | 58 | - {name: oslo-concurrency, | ||
62 | 59 | repository: 'git://github.com/openstack/oslo.concurrency', | ||
63 | 60 | branch: master} | ||
64 | 61 | - {name: oslo-config, | ||
65 | 62 | repository: 'git://github.com/openstack/oslo.config', | ||
66 | 63 | branch: master} | ||
67 | 64 | - {name: oslo-context, | ||
68 | 65 | repository: 'git://github.com/openstack/oslo.context', | ||
69 | 66 | branch: master} | ||
70 | 67 | - {name: oslo-db, | ||
71 | 68 | repository: 'git://github.com/openstack/oslo.db', | ||
72 | 69 | branch: master} | ||
73 | 70 | - {name: oslo-i18n, | ||
74 | 71 | repository: 'git://github.com/openstack/oslo.i18n', | ||
75 | 72 | branch: master} | ||
76 | 73 | - {name: oslo-log, | ||
77 | 74 | repository: 'git://github.com/openstack/oslo.log', | ||
78 | 75 | branch: master} | ||
79 | 76 | - {name: oslo-messaging, | ||
80 | 77 | repository: 'git://github.com/openstack/oslo.messaging', | ||
81 | 78 | branch: master} | ||
82 | 79 | - {name: oslo-middleware, | ||
83 | 80 | repository': 'git://github.com/openstack/oslo.middleware', | ||
84 | 81 | branch: master} | ||
85 | 82 | - {name: oslo-rootwrap', | ||
86 | 83 | repository: 'git://github.com/openstack/oslo.rootwrap', | ||
87 | 84 | branch: master} | ||
88 | 85 | - {name: oslo-serialization, | ||
89 | 86 | repository: 'git://github.com/openstack/oslo.serialization', | ||
90 | 87 | branch: master} | ||
91 | 88 | - {name: oslo-utils, | ||
92 | 89 | repository: 'git://github.com/openstack/oslo.utils', | ||
93 | 90 | branch: master} | ||
94 | 91 | - {name: pbr, | ||
95 | 92 | repository: 'git://github.com/openstack-dev/pbr', | ||
96 | 93 | branch: master} | ||
97 | 94 | - {name: stevedore, | ||
98 | 95 | repository: 'git://github.com/openstack/stevedore', | ||
99 | 96 | branch: 'master'} | ||
100 | 97 | - {name: sqlalchemy-migrate, | ||
101 | 98 | repository: 'git://github.com/stackforge/sqlalchemy-migrate', | ||
102 | 99 | branch: master} | ||
103 | 100 | - {name: python-cinderclient, | ||
104 | 101 | repository: 'git://github.com/openstack/python-cinderclient', | ||
105 | 102 | branch: master} | ||
106 | 103 | - {name: python-glanceclient, | ||
107 | 104 | repository': 'git://github.com/openstack/python-glanceclient', | ||
108 | 105 | branch: master} | ||
109 | 106 | - {name: python-neutronlient, | ||
110 | 107 | repository': 'git://github.com/openstack/python-neutronclient', | ||
111 | 108 | branch: master} | ||
112 | 109 | - {name: keystonemiddleware, | ||
113 | 110 | repository: 'git://github.com/openstack/keystonemiddleware', | ||
114 | 111 | branch: master} | ||
115 | 112 | - {name: nova, | ||
116 | 113 | repository: 'git://github.com/openstack/nova', | ||
117 | 114 | branch: master} | ||
118 | 26 | 115 | ||
119 | === added directory 'actions' | |||
120 | === added file 'actions.yaml' | |||
121 | --- actions.yaml 1970-01-01 00:00:00 +0000 | |||
122 | +++ actions.yaml 2015-06-11 13:34:00 +0000 | |||
123 | @@ -0,0 +1,2 @@ | |||
124 | 1 | git-reinstall: | ||
125 | 2 | description: Reinstall nova-cloud-controller from the openstack-origin-git repositories. | ||
126 | 0 | 3 | ||
127 | === added symlink 'actions/git-reinstall' | |||
128 | === target is u'git_reinstall.py' | |||
129 | === added file 'actions/git_reinstall.py' | |||
130 | --- actions/git_reinstall.py 1970-01-01 00:00:00 +0000 | |||
131 | +++ actions/git_reinstall.py 2015-06-11 13:34:00 +0000 | |||
132 | @@ -0,0 +1,45 @@ | |||
133 | 1 | #!/usr/bin/python | ||
134 | 2 | import sys | ||
135 | 3 | import traceback | ||
136 | 4 | |||
137 | 5 | sys.path.append('hooks/') | ||
138 | 6 | |||
139 | 7 | from charmhelpers.contrib.openstack.utils import ( | ||
140 | 8 | git_install_requested, | ||
141 | 9 | ) | ||
142 | 10 | |||
143 | 11 | from charmhelpers.core.hookenv import ( | ||
144 | 12 | action_set, | ||
145 | 13 | action_fail, | ||
146 | 14 | config, | ||
147 | 15 | ) | ||
148 | 16 | |||
149 | 17 | from nova_cc_utils import ( | ||
150 | 18 | git_install, | ||
151 | 19 | ) | ||
152 | 20 | |||
153 | 21 | from nova_cc_hooks import ( | ||
154 | 22 | config_changed, | ||
155 | 23 | ) | ||
156 | 24 | |||
157 | 25 | |||
158 | 26 | def git_reinstall(): | ||
159 | 27 | """Reinstall from source and restart services. | ||
160 | 28 | |||
161 | 29 | If the openstack-origin-git config option was used to install openstack | ||
162 | 30 | from source git repositories, then this action can be used to reinstall | ||
163 | 31 | from updated git repositories, followed by a restart of services.""" | ||
164 | 32 | if not git_install_requested(): | ||
165 | 33 | action_fail('openstack-origin-git is not configured') | ||
166 | 34 | return | ||
167 | 35 | |||
168 | 36 | try: | ||
169 | 37 | git_install(config('openstack-origin-git')) | ||
170 | 38 | config_changed() | ||
171 | 39 | except: | ||
172 | 40 | action_set({'traceback': traceback.format_exc()}) | ||
173 | 41 | action_fail('git-reinstall resulted in an unexpected error') | ||
174 | 42 | |||
175 | 43 | |||
176 | 44 | if __name__ == '__main__': | ||
177 | 45 | git_reinstall() | ||
178 | 0 | 46 | ||
179 | === modified file 'config.yaml' | |||
180 | --- config.yaml 2015-06-10 20:32:48 +0000 | |||
181 | +++ config.yaml 2015-06-11 13:34:00 +0000 | |||
182 | @@ -14,6 +14,22 @@ | |||
183 | 14 | Note that updating this setting to a source that is known to | 14 | Note that updating this setting to a source that is known to |
184 | 15 | provide a later version of OpenStack will trigger a software | 15 | provide a later version of OpenStack will trigger a software |
185 | 16 | upgrade. | 16 | upgrade. |
186 | 17 | |||
187 | 18 | Note that when openstack-origin-git is specified, openstack | ||
188 | 19 | specific packages will be installed from source rather than | ||
189 | 20 | from the openstack-origin repository. | ||
190 | 21 | openstack-origin-git: | ||
191 | 22 | default: | ||
192 | 23 | type: string | ||
193 | 24 | description: | | ||
194 | 25 | Specifies a YAML-formatted dictionary listing the git | ||
195 | 26 | repositories and branches from which to install OpenStack and | ||
196 | 27 | its dependencies. | ||
197 | 28 | |||
198 | 29 | Note that the installed config files will be determined based on | ||
199 | 30 | the OpenStack release of the openstack-origin option. | ||
200 | 31 | |||
201 | 32 | For more details see README.md. | ||
202 | 17 | rabbit-user: | 33 | rabbit-user: |
203 | 18 | default: nova | 34 | default: nova |
204 | 19 | type: string | 35 | type: string |
205 | 20 | 36 | ||
206 | === modified file 'hooks/nova_cc_hooks.py' | |||
207 | --- hooks/nova_cc_hooks.py 2015-06-04 08:45:01 +0000 | |||
208 | +++ hooks/nova_cc_hooks.py 2015-06-11 13:34:00 +0000 | |||
209 | @@ -43,7 +43,9 @@ | |||
210 | 43 | ) | 43 | ) |
211 | 44 | 44 | ||
212 | 45 | from charmhelpers.contrib.openstack.utils import ( | 45 | from charmhelpers.contrib.openstack.utils import ( |
213 | 46 | config_value_changed, | ||
214 | 46 | configure_installation_source, | 47 | configure_installation_source, |
215 | 48 | git_install_requested, | ||
216 | 47 | openstack_upgrade_available, | 49 | openstack_upgrade_available, |
217 | 48 | os_release, | 50 | os_release, |
218 | 49 | os_requires_version, | 51 | os_requires_version, |
219 | @@ -75,6 +77,7 @@ | |||
220 | 75 | disable_services, | 77 | disable_services, |
221 | 76 | do_openstack_upgrade, | 78 | do_openstack_upgrade, |
222 | 77 | enable_services, | 79 | enable_services, |
223 | 80 | git_install, | ||
224 | 78 | keystone_ca_cert_b64, | 81 | keystone_ca_cert_b64, |
225 | 79 | migrate_neutron_database, | 82 | migrate_neutron_database, |
226 | 80 | migrate_nova_database, | 83 | migrate_nova_database, |
227 | @@ -142,9 +145,12 @@ | |||
228 | 142 | def install(): | 145 | def install(): |
229 | 143 | execd_preinstall() | 146 | execd_preinstall() |
230 | 144 | configure_installation_source(config('openstack-origin')) | 147 | configure_installation_source(config('openstack-origin')) |
231 | 148 | |||
232 | 145 | apt_update() | 149 | apt_update() |
233 | 146 | apt_install(determine_packages(), fatal=True) | 150 | apt_install(determine_packages(), fatal=True) |
234 | 147 | 151 | ||
235 | 152 | git_install(config('openstack-origin-git')) | ||
236 | 153 | |||
237 | 148 | _files = os.path.join(charm_dir(), 'files') | 154 | _files = os.path.join(charm_dir(), 'files') |
238 | 149 | if os.path.isdir(_files): | 155 | if os.path.isdir(_files): |
239 | 150 | for f in os.listdir(_files): | 156 | for f in os.listdir(_files): |
240 | @@ -170,16 +176,21 @@ | |||
241 | 170 | relation_prefix='nova') | 176 | relation_prefix='nova') |
242 | 171 | 177 | ||
243 | 172 | global CONFIGS | 178 | global CONFIGS |
248 | 173 | if openstack_upgrade_available('nova-common'): | 179 | if git_install_requested(): |
249 | 174 | CONFIGS = do_openstack_upgrade() | 180 | if config_value_changed('openstack-origin-git'): |
250 | 175 | [neutron_api_relation_joined(rid=rid, remote_restart=True) | 181 | git_install(config('openstack-origin-git')) |
251 | 176 | for rid in relation_ids('neutron-api')] | 182 | else: |
252 | 183 | if openstack_upgrade_available('nova-common'): | ||
253 | 184 | CONFIGS = do_openstack_upgrade() | ||
254 | 185 | [neutron_api_relation_joined(rid=rid, remote_restart=True) | ||
255 | 186 | for rid in relation_ids('neutron-api')] | ||
256 | 177 | save_script_rc() | 187 | save_script_rc() |
257 | 178 | configure_https() | 188 | configure_https() |
258 | 179 | CONFIGS.write_all() | 189 | CONFIGS.write_all() |
259 | 180 | if console_attributes('protocol'): | 190 | if console_attributes('protocol'): |
262 | 181 | apt_update() | 191 | if not git_install_requested(): |
263 | 182 | apt_install(console_attributes('packages'), fatal=True) | 192 | apt_update() |
264 | 193 | apt_install(console_attributes('packages'), fatal=True) | ||
265 | 183 | [compute_joined(rid=rid) | 194 | [compute_joined(rid=rid) |
266 | 184 | for rid in relation_ids('cloud-compute')] | 195 | for rid in relation_ids('cloud-compute')] |
267 | 185 | for r_id in relation_ids('identity-service'): | 196 | for r_id in relation_ids('identity-service'): |
268 | 186 | 197 | ||
269 | === modified file 'hooks/nova_cc_utils.py' | |||
270 | --- hooks/nova_cc_utils.py 2015-05-11 07:38:35 +0000 | |||
271 | +++ hooks/nova_cc_utils.py 2015-06-11 13:34:00 +0000 | |||
272 | @@ -1,4 +1,5 @@ | |||
273 | 1 | import os | 1 | import os |
274 | 2 | import shutil | ||
275 | 2 | import subprocess | 3 | import subprocess |
276 | 3 | import ConfigParser | 4 | import ConfigParser |
277 | 4 | 5 | ||
278 | @@ -14,11 +15,20 @@ | |||
279 | 14 | 15 | ||
280 | 15 | from charmhelpers.contrib.peerstorage import peer_store | 16 | from charmhelpers.contrib.peerstorage import peer_store |
281 | 16 | 17 | ||
282 | 18 | from charmhelpers.contrib.python.packages import ( | ||
283 | 19 | pip_install, | ||
284 | 20 | ) | ||
285 | 21 | |||
286 | 17 | from charmhelpers.contrib.openstack.utils import ( | 22 | from charmhelpers.contrib.openstack.utils import ( |
287 | 18 | configure_installation_source, | 23 | configure_installation_source, |
288 | 19 | get_host_ip, | 24 | get_host_ip, |
289 | 20 | get_hostname, | 25 | get_hostname, |
290 | 21 | get_os_codename_install_source, | 26 | get_os_codename_install_source, |
291 | 27 | git_install_requested, | ||
292 | 28 | git_clone_and_install, | ||
293 | 29 | git_src_dir, | ||
294 | 30 | git_pip_venv_dir, | ||
295 | 31 | git_yaml_value, | ||
296 | 22 | is_ip, | 32 | is_ip, |
297 | 23 | os_release, | 33 | os_release, |
298 | 24 | save_script_rc as _save_script_rc) | 34 | save_script_rc as _save_script_rc) |
299 | @@ -31,6 +41,7 @@ | |||
300 | 31 | ) | 41 | ) |
301 | 32 | 42 | ||
302 | 33 | from charmhelpers.core.hookenv import ( | 43 | from charmhelpers.core.hookenv import ( |
303 | 44 | charm_dir, | ||
304 | 34 | config, | 45 | config, |
305 | 35 | log, | 46 | log, |
306 | 36 | relation_get, | 47 | relation_get, |
307 | @@ -42,13 +53,19 @@ | |||
308 | 42 | ) | 53 | ) |
309 | 43 | 54 | ||
310 | 44 | from charmhelpers.core.host import ( | 55 | from charmhelpers.core.host import ( |
311 | 56 | adduser, | ||
312 | 57 | add_group, | ||
313 | 58 | add_user_to_group, | ||
314 | 59 | mkdir, | ||
315 | 45 | service, | 60 | service, |
316 | 46 | service_start, | 61 | service_start, |
317 | 47 | service_stop, | 62 | service_stop, |
318 | 48 | service_running, | 63 | service_running, |
320 | 49 | lsb_release | 64 | lsb_release, |
321 | 50 | ) | 65 | ) |
322 | 51 | 66 | ||
323 | 67 | from charmhelpers.core.templating import render | ||
324 | 68 | |||
325 | 52 | from charmhelpers.contrib.network.ip import ( | 69 | from charmhelpers.contrib.network.ip import ( |
326 | 53 | is_ipv6 | 70 | is_ipv6 |
327 | 54 | ) | 71 | ) |
328 | @@ -76,6 +93,46 @@ | |||
329 | 76 | 'python-memcache', | 93 | 'python-memcache', |
330 | 77 | ] | 94 | ] |
331 | 78 | 95 | ||
332 | 96 | BASE_GIT_PACKAGES = [ | ||
333 | 97 | 'libffi-dev', | ||
334 | 98 | 'libmysqlclient-dev', | ||
335 | 99 | 'libssl-dev', | ||
336 | 100 | 'libxml2-dev', | ||
337 | 101 | 'libxslt1-dev', | ||
338 | 102 | 'libyaml-dev', | ||
339 | 103 | 'python-dev', | ||
340 | 104 | 'python-pip', | ||
341 | 105 | 'python-setuptools', | ||
342 | 106 | 'zlib1g-dev', | ||
343 | 107 | ] | ||
344 | 108 | |||
345 | 109 | LATE_GIT_PACKAGES = [ | ||
346 | 110 | 'novnc', | ||
347 | 111 | 'spice-html5', | ||
348 | 112 | 'websockify', | ||
349 | 113 | ] | ||
350 | 114 | |||
351 | 115 | # ubuntu packages that should not be installed when deploying from git | ||
352 | 116 | GIT_PACKAGE_BLACKLIST = [ | ||
353 | 117 | 'neutron-common', | ||
354 | 118 | 'neutron-server', | ||
355 | 119 | 'neutron-plugin-ml2', | ||
356 | 120 | 'nova-api-ec2', | ||
357 | 121 | 'nova-api-os-compute', | ||
358 | 122 | 'nova-api-os-volume', | ||
359 | 123 | 'nova-cert', | ||
360 | 124 | 'nova-conductor', | ||
361 | 125 | 'nova-consoleauth', | ||
362 | 126 | 'nova-novncproxy', | ||
363 | 127 | 'nova-objectstore', | ||
364 | 128 | 'nova-scheduler', | ||
365 | 129 | 'nova-spiceproxy', | ||
366 | 130 | 'nova-xvpvncproxy', | ||
367 | 131 | 'python-keystoneclient', | ||
368 | 132 | 'python-six', | ||
369 | 133 | 'quantum-server', | ||
370 | 134 | ] | ||
371 | 135 | |||
372 | 79 | BASE_SERVICES = [ | 136 | BASE_SERVICES = [ |
373 | 80 | 'nova-api-ec2', | 137 | 'nova-api-ec2', |
374 | 81 | 'nova-api-os-compute', | 138 | 'nova-api-os-compute', |
375 | @@ -381,6 +438,15 @@ | |||
376 | 381 | packages.extend(pkgs) | 438 | packages.extend(pkgs) |
377 | 382 | if console_attributes('packages'): | 439 | if console_attributes('packages'): |
378 | 383 | packages.extend(console_attributes('packages')) | 440 | packages.extend(console_attributes('packages')) |
379 | 441 | |||
380 | 442 | if git_install_requested(): | ||
381 | 443 | packages = list(set(packages)) | ||
382 | 444 | packages.extend(BASE_GIT_PACKAGES) | ||
383 | 445 | # don't include packages that will be installed from git | ||
384 | 446 | for p in GIT_PACKAGE_BLACKLIST: | ||
385 | 447 | if p in packages: | ||
386 | 448 | packages.remove(p) | ||
387 | 449 | |||
388 | 384 | return list(set(packages)) | 450 | return list(set(packages)) |
389 | 385 | 451 | ||
390 | 386 | 452 | ||
391 | @@ -454,8 +520,8 @@ | |||
392 | 454 | os.unlink('/usr/sbin/policy-rc.d') | 520 | os.unlink('/usr/sbin/policy-rc.d') |
393 | 455 | 521 | ||
394 | 456 | 522 | ||
397 | 457 | QUANTUM_DB_MANAGE = "/usr/bin/quantum-db-manage" | 523 | QUANTUM_DB_MANAGE = "quantum-db-manage" |
398 | 458 | NEUTRON_DB_MANAGE = "/usr/bin/neutron-db-manage" | 524 | NEUTRON_DB_MANAGE = "neutron-db-manage" |
399 | 459 | 525 | ||
400 | 460 | 526 | ||
401 | 461 | def reset_os_release(): | 527 | def reset_os_release(): |
402 | @@ -985,3 +1051,257 @@ | |||
403 | 985 | ' main') | 1051 | ' main') |
404 | 986 | apt_update() | 1052 | apt_update() |
405 | 987 | apt_install('haproxy/trusty-backports', fatal=True) | 1053 | apt_install('haproxy/trusty-backports', fatal=True) |
406 | 1054 | |||
407 | 1055 | |||
408 | 1056 | def git_install(projects_yaml): | ||
409 | 1057 | """Perform setup, and install git repos specified in yaml parameter.""" | ||
410 | 1058 | if git_install_requested(): | ||
411 | 1059 | git_pre_install() | ||
412 | 1060 | git_clone_and_install(projects_yaml, core_project='nova') | ||
413 | 1061 | git_post_install(projects_yaml) | ||
414 | 1062 | |||
415 | 1063 | |||
416 | 1064 | def git_pre_install(): | ||
417 | 1065 | """Perform pre-install setup.""" | ||
418 | 1066 | dirs = [ | ||
419 | 1067 | '/var/lib/nova', | ||
420 | 1068 | '/var/lib/nova/buckets', | ||
421 | 1069 | '/var/lib/nova/CA', | ||
422 | 1070 | '/var/lib/nova/CA/INTER', | ||
423 | 1071 | '/var/lib/nova/CA/newcerts', | ||
424 | 1072 | '/var/lib/nova/CA/private', | ||
425 | 1073 | '/var/lib/nova/CA/reqs', | ||
426 | 1074 | '/var/lib/nova/images', | ||
427 | 1075 | '/var/lib/nova/instances', | ||
428 | 1076 | '/var/lib/nova/keys', | ||
429 | 1077 | '/var/lib/nova/networks', | ||
430 | 1078 | '/var/lib/nova/tmp', | ||
431 | 1079 | '/var/lib/neutron', | ||
432 | 1080 | '/var/lib/neutron/lock', | ||
433 | 1081 | '/var/log/nova', | ||
434 | 1082 | '/etc/neutron', | ||
435 | 1083 | '/etc/neutron/plugins', | ||
436 | 1084 | '/etc/neutron/plugins/ml2', | ||
437 | 1085 | ] | ||
438 | 1086 | |||
439 | 1087 | adduser('nova', shell='/bin/bash', system_user=True) | ||
440 | 1088 | subprocess.check_call(['usermod', '--home', '/var/lib/nova', 'nova']) | ||
441 | 1089 | add_group('nova', system_group=True) | ||
442 | 1090 | add_user_to_group('nova', 'nova') | ||
443 | 1091 | |||
444 | 1092 | adduser('neutron', shell='/bin/bash', system_user=True) | ||
445 | 1093 | add_group('neutron', system_group=True) | ||
446 | 1094 | add_user_to_group('neutron', 'neutron') | ||
447 | 1095 | |||
448 | 1096 | for d in dirs: | ||
449 | 1097 | mkdir(d, owner='nova', group='nova', perms=0755, force=False) | ||
450 | 1098 | |||
451 | 1099 | |||
452 | 1100 | def git_post_install(projects_yaml): | ||
453 | 1101 | """Perform post-install setup.""" | ||
454 | 1102 | http_proxy = git_yaml_value(projects_yaml, 'http_proxy') | ||
455 | 1103 | if http_proxy: | ||
456 | 1104 | pip_install('mysql-python', proxy=http_proxy, | ||
457 | 1105 | venv=git_pip_venv_dir(projects_yaml)) | ||
458 | 1106 | else: | ||
459 | 1107 | pip_install('mysql-python', | ||
460 | 1108 | venv=git_pip_venv_dir(projects_yaml)) | ||
461 | 1109 | |||
462 | 1110 | src_etc = os.path.join(git_src_dir(projects_yaml, 'nova'), 'etc/nova') | ||
463 | 1111 | configs = [ | ||
464 | 1112 | {'src': src_etc, | ||
465 | 1113 | 'dest': '/etc/nova'}, | ||
466 | 1114 | ] | ||
467 | 1115 | |||
468 | 1116 | for c in configs: | ||
469 | 1117 | if os.path.exists(c['dest']): | ||
470 | 1118 | shutil.rmtree(c['dest']) | ||
471 | 1119 | shutil.copytree(c['src'], c['dest']) | ||
472 | 1120 | |||
473 | 1121 | # NOTE(coreycb): Need to find better solution than bin symlinks. | ||
474 | 1122 | symlinks = [ | ||
475 | 1123 | {'src': os.path.join(git_pip_venv_dir(projects_yaml), | ||
476 | 1124 | 'bin/nova-manage'), | ||
477 | 1125 | 'link': '/usr/local/bin/nova-manage'}, | ||
478 | 1126 | {'src': os.path.join(git_pip_venv_dir(projects_yaml), | ||
479 | 1127 | 'bin/nova-rootwrap'), | ||
480 | 1128 | 'link': '/usr/local/bin/nova-rootwrap'}, | ||
481 | 1129 | ] | ||
482 | 1130 | |||
483 | 1131 | for s in symlinks: | ||
484 | 1132 | if os.path.lexists(s['link']): | ||
485 | 1133 | os.remove(s['link']) | ||
486 | 1134 | os.symlink(s['src'], s['link']) | ||
487 | 1135 | |||
488 | 1136 | render('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', {}, perms=0o440) | ||
489 | 1137 | |||
490 | 1138 | nova_cc = 'nova-cloud-controller' | ||
491 | 1139 | nova_user = 'nova' | ||
492 | 1140 | start_dir = '/var/lib/nova' | ||
493 | 1141 | bin_dir = os.path.join(git_pip_venv_dir(projects_yaml), 'bin') | ||
494 | 1142 | nova_conf = '/etc/nova/nova.conf' | ||
495 | 1143 | nova_ec2_api_context = { | ||
496 | 1144 | 'service_description': 'Nova EC2 API server', | ||
497 | 1145 | 'service_name': nova_cc, | ||
498 | 1146 | 'user_name': nova_user, | ||
499 | 1147 | 'start_dir': start_dir, | ||
500 | 1148 | 'process_name': 'nova-api-ec2', | ||
501 | 1149 | 'executable_name': os.path.join(bin_dir, 'nova-api-ec2'), | ||
502 | 1150 | 'config_files': [nova_conf], | ||
503 | 1151 | } | ||
504 | 1152 | nova_api_os_compute_context = { | ||
505 | 1153 | 'service_description': 'Nova OpenStack Compute API server', | ||
506 | 1154 | 'service_name': nova_cc, | ||
507 | 1155 | 'user_name': nova_user, | ||
508 | 1156 | 'start_dir': start_dir, | ||
509 | 1157 | 'process_name': 'nova-api-os-compute', | ||
510 | 1158 | 'executable_name': os.path.join(bin_dir, 'nova-api-os-compute'), | ||
511 | 1159 | 'config_files': [nova_conf], | ||
512 | 1160 | } | ||
513 | 1161 | nova_cells_context = { | ||
514 | 1162 | 'service_description': 'Nova cells', | ||
515 | 1163 | 'service_name': nova_cc, | ||
516 | 1164 | 'user_name': nova_user, | ||
517 | 1165 | 'start_dir': start_dir, | ||
518 | 1166 | 'process_name': 'nova-cells', | ||
519 | 1167 | 'executable_name': os.path.join(bin_dir, 'nova-cells'), | ||
520 | 1168 | 'config_files': [nova_conf], | ||
521 | 1169 | } | ||
522 | 1170 | nova_cert_context = { | ||
523 | 1171 | 'service_description': 'Nova cert', | ||
524 | 1172 | 'service_name': nova_cc, | ||
525 | 1173 | 'user_name': nova_user, | ||
526 | 1174 | 'start_dir': start_dir, | ||
527 | 1175 | 'process_name': 'nova-cert', | ||
528 | 1176 | 'executable_name': os.path.join(bin_dir, 'nova-cert'), | ||
529 | 1177 | 'config_files': [nova_conf], | ||
530 | 1178 | } | ||
531 | 1179 | nova_conductor_context = { | ||
532 | 1180 | 'service_description': 'Nova conductor', | ||
533 | 1181 | 'service_name': nova_cc, | ||
534 | 1182 | 'user_name': nova_user, | ||
535 | 1183 | 'start_dir': start_dir, | ||
536 | 1184 | 'process_name': 'nova-conductor', | ||
537 | 1185 | 'executable_name': os.path.join(bin_dir, 'nova-conductor'), | ||
538 | 1186 | 'config_files': [nova_conf], | ||
539 | 1187 | } | ||
540 | 1188 | nova_consoleauth_context = { | ||
541 | 1189 | 'service_description': 'Nova console auth', | ||
542 | 1190 | 'service_name': nova_cc, | ||
543 | 1191 | 'user_name': nova_user, | ||
544 | 1192 | 'start_dir': start_dir, | ||
545 | 1193 | 'process_name': 'nova-consoleauth', | ||
546 | 1194 | 'executable_name': os.path.join(bin_dir, 'nova-consoleauth'), | ||
547 | 1195 | 'config_files': [nova_conf], | ||
548 | 1196 | } | ||
549 | 1197 | nova_console_context = { | ||
550 | 1198 | 'service_description': 'Nova console', | ||
551 | 1199 | 'service_name': nova_cc, | ||
552 | 1200 | 'user_name': nova_user, | ||
553 | 1201 | 'start_dir': start_dir, | ||
554 | 1202 | 'process_name': 'nova-console', | ||
555 | 1203 | 'executable_name': os.path.join(bin_dir, 'nova-console'), | ||
556 | 1204 | 'config_files': [nova_conf], | ||
557 | 1205 | } | ||
558 | 1206 | nova_novncproxy_context = { | ||
559 | 1207 | 'service_description': 'Nova NoVNC proxy', | ||
560 | 1208 | 'service_name': nova_cc, | ||
561 | 1209 | 'user_name': nova_user, | ||
562 | 1210 | 'start_dir': start_dir, | ||
563 | 1211 | 'process_name': 'nova-novncproxy', | ||
564 | 1212 | 'executable_name': os.path.join(bin_dir, 'nova-novncproxy'), | ||
565 | 1213 | 'config_files': [nova_conf], | ||
566 | 1214 | } | ||
567 | 1215 | nova_objectstore_context = { | ||
568 | 1216 | 'service_description': 'Nova object store', | ||
569 | 1217 | 'service_name': nova_cc, | ||
570 | 1218 | 'user_name': nova_user, | ||
571 | 1219 | 'start_dir': start_dir, | ||
572 | 1220 | 'process_name': 'nova-objectstore', | ||
573 | 1221 | 'executable_name': os.path.join(bin_dir, 'nova-objectstore'), | ||
574 | 1222 | 'config_files': [nova_conf], | ||
575 | 1223 | } | ||
576 | 1224 | nova_scheduler_context = { | ||
577 | 1225 | 'service_description': 'Nova scheduler', | ||
578 | 1226 | 'service_name': nova_cc, | ||
579 | 1227 | 'user_name': nova_user, | ||
580 | 1228 | 'start_dir': start_dir, | ||
581 | 1229 | 'process_name': 'nova-scheduler', | ||
582 | 1230 | 'executable_name': os.path.join(bin_dir, 'nova-scheduler'), | ||
583 | 1231 | 'config_files': [nova_conf], | ||
584 | 1232 | } | ||
585 | 1233 | nova_serialproxy_context = { | ||
586 | 1234 | 'service_description': 'Nova serial proxy', | ||
587 | 1235 | 'service_name': nova_cc, | ||
588 | 1236 | 'user_name': nova_user, | ||
589 | 1237 | 'start_dir': start_dir, | ||
590 | 1238 | 'process_name': 'nova-serialproxy', | ||
591 | 1239 | 'executable_name': os.path.join(bin_dir, 'nova-serialproxy'), | ||
592 | 1240 | 'config_files': [nova_conf], | ||
593 | 1241 | } | ||
594 | 1242 | nova_spiceproxy_context = { | ||
595 | 1243 | 'service_description': 'Nova spice proxy', | ||
596 | 1244 | 'service_name': nova_cc, | ||
597 | 1245 | 'user_name': nova_user, | ||
598 | 1246 | 'start_dir': start_dir, | ||
599 | 1247 | 'process_name': 'nova-spicehtml5proxy', | ||
600 | 1248 | 'executable_name': os.path.join(bin_dir, 'nova-spicehtml5proxy'), | ||
601 | 1249 | 'config_files': [nova_conf], | ||
602 | 1250 | } | ||
603 | 1251 | nova_xvpvncproxy_context = { | ||
604 | 1252 | 'service_description': 'Nova XVPVNC proxy', | ||
605 | 1253 | 'service_name': nova_cc, | ||
606 | 1254 | 'user_name': nova_user, | ||
607 | 1255 | 'start_dir': start_dir, | ||
608 | 1256 | 'process_name': 'nova-xvpvncproxy', | ||
609 | 1257 | 'executable_name': os.path.join(bin_dir, 'nova-xvpvncproxy'), | ||
610 | 1258 | 'config_files': [nova_conf], | ||
611 | 1259 | } | ||
612 | 1260 | |||
613 | 1261 | # NOTE(coreycb): Needs systemd support | ||
614 | 1262 | templates_dir = 'hooks/charmhelpers/contrib/openstack/templates' | ||
615 | 1263 | templates_dir = os.path.join(charm_dir(), templates_dir) | ||
616 | 1264 | os_rel = os_release('nova-common') | ||
617 | 1265 | render('git.upstart', '/etc/init/nova-api-ec2.conf', | ||
618 | 1266 | nova_ec2_api_context, perms=0o644, | ||
619 | 1267 | templates_dir=templates_dir) | ||
620 | 1268 | render('git.upstart', '/etc/init/nova-api-os-compute.conf', | ||
621 | 1269 | nova_api_os_compute_context, perms=0o644, | ||
622 | 1270 | templates_dir=templates_dir) | ||
623 | 1271 | render('git.upstart', '/etc/init/nova-cells.conf', | ||
624 | 1272 | nova_cells_context, perms=0o644, | ||
625 | 1273 | templates_dir=templates_dir) | ||
626 | 1274 | render('git.upstart', '/etc/init/nova-cert.conf', | ||
627 | 1275 | nova_cert_context, perms=0o644, | ||
628 | 1276 | templates_dir=templates_dir) | ||
629 | 1277 | render('git.upstart', '/etc/init/nova-conductor.conf', | ||
630 | 1278 | nova_conductor_context, perms=0o644, | ||
631 | 1279 | templates_dir=templates_dir) | ||
632 | 1280 | render('git.upstart', '/etc/init/nova-consoleauth.conf', | ||
633 | 1281 | nova_consoleauth_context, perms=0o644, | ||
634 | 1282 | templates_dir=templates_dir) | ||
635 | 1283 | render('git.upstart', '/etc/init/nova-console.conf', | ||
636 | 1284 | nova_console_context, perms=0o644, | ||
637 | 1285 | templates_dir=templates_dir) | ||
638 | 1286 | render('git.upstart', '/etc/init/nova-novncproxy.conf', | ||
639 | 1287 | nova_novncproxy_context, perms=0o644, | ||
640 | 1288 | templates_dir=templates_dir) | ||
641 | 1289 | render('git.upstart', '/etc/init/nova-objectstore.conf', | ||
642 | 1290 | nova_objectstore_context, perms=0o644, | ||
643 | 1291 | templates_dir=templates_dir) | ||
644 | 1292 | render('git.upstart', '/etc/init/nova-scheduler.conf', | ||
645 | 1293 | nova_scheduler_context, perms=0o644, | ||
646 | 1294 | templates_dir=templates_dir) | ||
647 | 1295 | if os_rel >= 'juno': | ||
648 | 1296 | render('git.upstart', '/etc/init/nova-serialproxy.conf', | ||
649 | 1297 | nova_serialproxy_context, perms=0o644, | ||
650 | 1298 | templates_dir=templates_dir) | ||
651 | 1299 | render('git.upstart', '/etc/init/nova-spiceproxy.conf', | ||
652 | 1300 | nova_spiceproxy_context, perms=0o644, | ||
653 | 1301 | templates_dir=templates_dir) | ||
654 | 1302 | render('git.upstart', '/etc/init/nova-xvpvncproxy.conf', | ||
655 | 1303 | nova_xvpvncproxy_context, perms=0o644, | ||
656 | 1304 | templates_dir=templates_dir) | ||
657 | 1305 | |||
658 | 1306 | apt_update() | ||
659 | 1307 | apt_install(LATE_GIT_PACKAGES, fatal=True) | ||
660 | 988 | 1308 | ||
661 | === added directory 'templates/git' | |||
662 | === added file 'templates/git/nova_sudoers' | |||
663 | --- templates/git/nova_sudoers 1970-01-01 00:00:00 +0000 | |||
664 | +++ templates/git/nova_sudoers 2015-06-11 13:34:00 +0000 | |||
665 | @@ -0,0 +1,4 @@ | |||
666 | 1 | Defaults:nova !requiretty | ||
667 | 2 | |||
668 | 3 | nova ALL = (root) NOPASSWD: /usr/local/bin/nova-rootwrap /etc/nova/rootwrap.conf * | ||
669 | 4 | |||
670 | 0 | 5 | ||
671 | === added file 'tests/050-basic-trusty-icehouse-git' | |||
672 | --- tests/050-basic-trusty-icehouse-git 1970-01-01 00:00:00 +0000 | |||
673 | +++ tests/050-basic-trusty-icehouse-git 2015-06-11 13:34:00 +0000 | |||
674 | @@ -0,0 +1,10 @@ | |||
675 | 1 | #!/usr/bin/python | ||
676 | 2 | |||
677 | 3 | """Amulet tests on a basic nova cloud controller git deployment on | ||
678 | 4 | trusty-icehouse.""" | ||
679 | 5 | |||
680 | 6 | from basic_deployment import NovaCCBasicDeployment | ||
681 | 7 | |||
682 | 8 | if __name__ == '__main__': | ||
683 | 9 | deployment = NovaCCBasicDeployment(series='trusty', git=True) | ||
684 | 10 | deployment.run_tests() | ||
685 | 0 | 11 | ||
686 | === added file 'tests/051-basic-trusty-juno-git' | |||
687 | --- tests/051-basic-trusty-juno-git 1970-01-01 00:00:00 +0000 | |||
688 | +++ tests/051-basic-trusty-juno-git 2015-06-11 13:34:00 +0000 | |||
689 | @@ -0,0 +1,13 @@ | |||
690 | 1 | #!/usr/bin/python | ||
691 | 2 | |||
692 | 3 | """Amulet tests on a basic nova cloud controller git deployment on | ||
693 | 4 | trusty-juno.""" | ||
694 | 5 | |||
695 | 6 | from basic_deployment import NovaCCBasicDeployment | ||
696 | 7 | |||
697 | 8 | if __name__ == '__main__': | ||
698 | 9 | deployment = NovaCCBasicDeployment(series='trusty', | ||
699 | 10 | openstack='cloud:trusty-juno', | ||
700 | 11 | source='cloud:trusty-updates/juno', | ||
701 | 12 | git=True) | ||
702 | 13 | deployment.run_tests() | ||
703 | 0 | 14 | ||
704 | === modified file 'tests/basic_deployment.py' | |||
705 | --- tests/basic_deployment.py 2015-04-20 10:21:36 +0000 | |||
706 | +++ tests/basic_deployment.py 2015-06-11 13:34:00 +0000 | |||
707 | @@ -1,6 +1,8 @@ | |||
708 | 1 | #!/usr/bin/python | 1 | #!/usr/bin/python |
709 | 2 | 2 | ||
710 | 3 | import amulet | 3 | import amulet |
711 | 4 | import os | ||
712 | 5 | import yaml | ||
713 | 4 | 6 | ||
714 | 5 | from charmhelpers.contrib.openstack.amulet.deployment import ( | 7 | from charmhelpers.contrib.openstack.amulet.deployment import ( |
715 | 6 | OpenStackAmuletDeployment | 8 | OpenStackAmuletDeployment |
716 | @@ -19,9 +21,11 @@ | |||
717 | 19 | class NovaCCBasicDeployment(OpenStackAmuletDeployment): | 21 | class NovaCCBasicDeployment(OpenStackAmuletDeployment): |
718 | 20 | """Amulet tests on a basic nova cloud controller deployment.""" | 22 | """Amulet tests on a basic nova cloud controller deployment.""" |
719 | 21 | 23 | ||
721 | 22 | def __init__(self, series=None, openstack=None, source=None, stable=False): | 24 | def __init__(self, series=None, openstack=None, source=None, git=False, |
722 | 25 | stable=False): | ||
723 | 23 | """Deploy the entire test environment.""" | 26 | """Deploy the entire test environment.""" |
724 | 24 | super(NovaCCBasicDeployment, self).__init__(series, openstack, source, stable) | 27 | super(NovaCCBasicDeployment, self).__init__(series, openstack, source, stable) |
725 | 28 | self.git = git | ||
726 | 25 | self._add_services() | 29 | self._add_services() |
727 | 26 | self._add_relations() | 30 | self._add_relations() |
728 | 27 | self._configure_services() | 31 | self._configure_services() |
729 | @@ -62,9 +66,28 @@ | |||
730 | 62 | 66 | ||
731 | 63 | def _configure_services(self): | 67 | def _configure_services(self): |
732 | 64 | """Configure all of the services.""" | 68 | """Configure all of the services.""" |
733 | 69 | nova_cc_config = {} | ||
734 | 70 | if self.git: | ||
735 | 71 | branch = 'stable/' + self._get_openstack_release_string() | ||
736 | 72 | amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY') | ||
737 | 73 | openstack_origin_git = { | ||
738 | 74 | 'repositories': [ | ||
739 | 75 | {'name': 'requirements', | ||
740 | 76 | 'repository': 'git://github.com/openstack/requirements', | ||
741 | 77 | 'branch': branch}, | ||
742 | 78 | {'name': 'nova', | ||
743 | 79 | 'repository': 'git://github.com/openstack/nova', | ||
744 | 80 | 'branch': branch}, | ||
745 | 81 | ], | ||
746 | 82 | 'directory': '/mnt/openstack-git', | ||
747 | 83 | 'http_proxy': amulet_http_proxy, | ||
748 | 84 | 'https_proxy': amulet_http_proxy, | ||
749 | 85 | } | ||
750 | 86 | nova_cc_config['openstack-origin-git'] = yaml.dump(openstack_origin_git) | ||
751 | 65 | keystone_config = {'admin-password': 'openstack', | 87 | keystone_config = {'admin-password': 'openstack', |
752 | 66 | 'admin-token': 'ubuntutesting'} | 88 | 'admin-token': 'ubuntutesting'} |
754 | 67 | configs = {'keystone': keystone_config} | 89 | configs = {'nova-cloud-controller': nova_cc_config, |
755 | 90 | 'keystone': keystone_config} | ||
756 | 68 | super(NovaCCBasicDeployment, self)._configure_services(configs) | 91 | super(NovaCCBasicDeployment, self)._configure_services(configs) |
757 | 69 | 92 | ||
758 | 70 | def _initialize_tests(self): | 93 | def _initialize_tests(self): |
759 | 71 | 94 | ||
760 | === modified file 'unit_tests/__init__.py' | |||
761 | --- unit_tests/__init__.py 2015-04-20 10:21:36 +0000 | |||
762 | +++ unit_tests/__init__.py 2015-06-11 13:34:00 +0000 | |||
763 | @@ -1,2 +1,4 @@ | |||
764 | 1 | import sys | 1 | import sys |
765 | 2 | |||
766 | 3 | sys.path.append('actions/') | ||
767 | 2 | sys.path.append('hooks/') | 4 | sys.path.append('hooks/') |
768 | 3 | 5 | ||
769 | === added file 'unit_tests/test_actions_git_reinstall.py' | |||
770 | --- unit_tests/test_actions_git_reinstall.py 1970-01-01 00:00:00 +0000 | |||
771 | +++ unit_tests/test_actions_git_reinstall.py 2015-06-11 13:34:00 +0000 | |||
772 | @@ -0,0 +1,107 @@ | |||
773 | 1 | from mock import patch, MagicMock | ||
774 | 2 | |||
775 | 3 | with patch('charmhelpers.core.hookenv.config') as config: | ||
776 | 4 | config.return_value = 'nova' | ||
777 | 5 | import nova_cc_utils as utils # noqa | ||
778 | 6 | |||
779 | 7 | _reg = utils.register_configs | ||
780 | 8 | _map = utils.restart_map | ||
781 | 9 | |||
782 | 10 | utils.register_configs = MagicMock() | ||
783 | 11 | utils.restart_map = MagicMock() | ||
784 | 12 | |||
785 | 13 | with patch('nova_cc_utils.guard_map') as gmap: | ||
786 | 14 | with patch('charmhelpers.core.hookenv.config') as config: | ||
787 | 15 | config.return_value = False | ||
788 | 16 | gmap.return_value = {} | ||
789 | 17 | import git_reinstall | ||
790 | 18 | |||
791 | 19 | utils.register_configs = _reg | ||
792 | 20 | utils.restart_map = _map | ||
793 | 21 | |||
794 | 22 | from test_utils import ( | ||
795 | 23 | CharmTestCase | ||
796 | 24 | ) | ||
797 | 25 | |||
798 | 26 | TO_PATCH = [ | ||
799 | 27 | 'config', | ||
800 | 28 | ] | ||
801 | 29 | |||
802 | 30 | |||
803 | 31 | openstack_origin_git = \ | ||
804 | 32 | """repositories: | ||
805 | 33 | - {name: requirements, | ||
806 | 34 | repository: 'git://git.openstack.org/openstack/requirements', | ||
807 | 35 | branch: stable/juno} | ||
808 | 36 | - {name: nova, | ||
809 | 37 | repository: 'git://git.openstack.org/openstack/nova', | ||
810 | 38 | branch: stable/juno}""" | ||
811 | 39 | |||
812 | 40 | |||
813 | 41 | class TestnovaAPIActions(CharmTestCase): | ||
814 | 42 | |||
815 | 43 | def setUp(self): | ||
816 | 44 | super(TestnovaAPIActions, self).setUp(git_reinstall, TO_PATCH) | ||
817 | 45 | self.config.side_effect = self.test_config.get | ||
818 | 46 | |||
819 | 47 | @patch.object(git_reinstall, 'action_set') | ||
820 | 48 | @patch.object(git_reinstall, 'action_fail') | ||
821 | 49 | @patch.object(git_reinstall, 'git_install') | ||
822 | 50 | @patch.object(git_reinstall, 'config_changed') | ||
823 | 51 | def test_git_reinstall(self, config_changed, git_install, action_fail, | ||
824 | 52 | action_set): | ||
825 | 53 | self.test_config.set('openstack-origin-git', openstack_origin_git) | ||
826 | 54 | |||
827 | 55 | git_reinstall.git_reinstall() | ||
828 | 56 | |||
829 | 57 | git_install.assert_called_with(openstack_origin_git) | ||
830 | 58 | self.assertTrue(git_install.called) | ||
831 | 59 | self.assertTrue(config_changed.called) | ||
832 | 60 | self.assertFalse(action_set.called) | ||
833 | 61 | self.assertFalse(action_fail.called) | ||
834 | 62 | |||
835 | 63 | @patch.object(git_reinstall, 'action_set') | ||
836 | 64 | @patch.object(git_reinstall, 'action_fail') | ||
837 | 65 | @patch.object(git_reinstall, 'git_install') | ||
838 | 66 | @patch.object(git_reinstall, 'config_changed') | ||
839 | 67 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
840 | 68 | def test_git_reinstall_not_configured(self, _config, config_changed, | ||
841 | 69 | git_install, action_fail, | ||
842 | 70 | action_set): | ||
843 | 71 | _config.return_value = None | ||
844 | 72 | |||
845 | 73 | git_reinstall.git_reinstall() | ||
846 | 74 | |||
847 | 75 | msg = 'openstack-origin-git is not configured' | ||
848 | 76 | action_fail.assert_called_with(msg) | ||
849 | 77 | self.assertFalse(git_install.called) | ||
850 | 78 | self.assertFalse(action_set.called) | ||
851 | 79 | |||
852 | 80 | @patch.object(git_reinstall, 'action_set') | ||
853 | 81 | @patch.object(git_reinstall, 'action_fail') | ||
854 | 82 | @patch.object(git_reinstall, 'git_install') | ||
855 | 83 | @patch.object(git_reinstall, 'config_changed') | ||
856 | 84 | @patch('traceback.format_exc') | ||
857 | 85 | @patch('charmhelpers.contrib.openstack.utils.config') | ||
858 | 86 | def test_git_reinstall_exception(self, _config, format_exc, | ||
859 | 87 | config_changed, git_install, action_fail, | ||
860 | 88 | action_set): | ||
861 | 89 | _config.return_value = openstack_origin_git | ||
862 | 90 | e = OSError('something bad happened') | ||
863 | 91 | git_install.side_effect = e | ||
864 | 92 | traceback = ( | ||
865 | 93 | "Traceback (most recent call last):\n" | ||
866 | 94 | " File \"actions/git_reinstall.py\", line 37, in git_reinstall\n" | ||
867 | 95 | " git_install(config(\'openstack-origin-git\'))\n" | ||
868 | 96 | " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 964, in __call__\n" # noqa | ||
869 | 97 | " return _mock_self._mock_call(*args, **kwargs)\n" | ||
870 | 98 | " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 1019, in _mock_call\n" # noqa | ||
871 | 99 | " raise effect\n" | ||
872 | 100 | "OSError: something bad happened\n") | ||
873 | 101 | format_exc.return_value = traceback | ||
874 | 102 | |||
875 | 103 | git_reinstall.git_reinstall() | ||
876 | 104 | |||
877 | 105 | msg = 'git-reinstall resulted in an unexpected error' | ||
878 | 106 | action_fail.assert_called_with(msg) | ||
879 | 107 | action_set.assert_called_with({'traceback': traceback}) | ||
880 | 0 | 108 | ||
881 | === modified file 'unit_tests/test_nova_cc_contexts.py' | |||
882 | --- unit_tests/test_nova_cc_contexts.py 2015-06-03 00:06:30 +0000 | |||
883 | +++ unit_tests/test_nova_cc_contexts.py 2015-06-11 13:34:00 +0000 | |||
884 | @@ -9,9 +9,7 @@ | |||
885 | 9 | from charmhelpers.core import hookenv | 9 | from charmhelpers.core import hookenv |
886 | 10 | _conf = hookenv.config | 10 | _conf = hookenv.config |
887 | 11 | hookenv.config = mock.MagicMock() | 11 | hookenv.config = mock.MagicMock() |
891 | 12 | import nova_cc_utils as _utils | 12 | import nova_cc_utils as _utils # noqa |
889 | 13 | # this assert is a double check + to avoid pep8 warning | ||
890 | 14 | assert _utils.config == hookenv.config | ||
892 | 15 | hookenv.config = _conf | 13 | hookenv.config = _conf |
893 | 16 | ##### | 14 | ##### |
894 | 17 | 15 | ||
895 | 18 | 16 | ||
896 | === modified file 'unit_tests/test_nova_cc_hooks.py' | |||
897 | --- unit_tests/test_nova_cc_hooks.py 2015-06-10 20:32:48 +0000 | |||
898 | +++ unit_tests/test_nova_cc_hooks.py 2015-06-11 13:34:00 +0000 | |||
899 | @@ -1,6 +1,7 @@ | |||
900 | 1 | from mock import MagicMock, patch, call | 1 | from mock import MagicMock, patch, call |
901 | 2 | from test_utils import CharmTestCase, patch_open | 2 | from test_utils import CharmTestCase, patch_open |
902 | 3 | import os | 3 | import os |
903 | 4 | import yaml | ||
904 | 4 | import tempfile | 5 | import tempfile |
905 | 5 | 6 | ||
906 | 6 | with patch('charmhelpers.core.hookenv.config') as config: | 7 | with patch('charmhelpers.core.hookenv.config') as config: |
907 | @@ -70,6 +71,8 @@ | |||
908 | 70 | 'get_iface_for_address', | 71 | 'get_iface_for_address', |
909 | 71 | 'get_netmask_for_address', | 72 | 'get_netmask_for_address', |
910 | 72 | 'update_nrpe_config', | 73 | 'update_nrpe_config', |
911 | 74 | 'git_install', | ||
912 | 75 | 'git_install_requested', | ||
913 | 73 | ] | 76 | ] |
914 | 74 | 77 | ||
915 | 75 | 78 | ||
916 | @@ -116,12 +119,63 @@ | |||
917 | 116 | self.disable_services.assert_called() | 119 | self.disable_services.assert_called() |
918 | 117 | self.cmd_all_services.assert_called_with('stop') | 120 | self.cmd_all_services.assert_called_with('stop') |
919 | 118 | 121 | ||
920 | 122 | def test_install_hook_git(self): | ||
921 | 123 | self.git_install_requested.return_value = True | ||
922 | 124 | self.determine_packages.return_value = ['foo', 'bar'] | ||
923 | 125 | self.determine_ports.return_value = [80, 81, 82] | ||
924 | 126 | repo = 'cloud:trusty-juno' | ||
925 | 127 | openstack_origin_git = { | ||
926 | 128 | 'repositories': [ | ||
927 | 129 | {'name': 'requirements', | ||
928 | 130 | 'repository': 'git://git.openstack.org/openstack/requirements', # noqa | ||
929 | 131 | 'branch': 'stable/juno'}, | ||
930 | 132 | {'name': 'nova', | ||
931 | 133 | 'repository': 'git://git.openstack.org/openstack/nova', | ||
932 | 134 | 'branch': 'stable/juno'} | ||
933 | 135 | ], | ||
934 | 136 | 'directory': '/mnt/openstack-git', | ||
935 | 137 | } | ||
936 | 138 | projects_yaml = yaml.dump(openstack_origin_git) | ||
937 | 139 | self.test_config.set('openstack-origin', repo) | ||
938 | 140 | self.test_config.set('openstack-origin-git', projects_yaml) | ||
939 | 141 | hooks.install() | ||
940 | 142 | self.git_install.assert_called_with(projects_yaml) | ||
941 | 143 | self.apt_install.assert_called_with(['foo', 'bar'], fatal=True) | ||
942 | 144 | self.execd_preinstall.assert_called() | ||
943 | 145 | self.disable_services.assert_called() | ||
944 | 146 | self.cmd_all_services.assert_called_with('stop') | ||
945 | 147 | |||
946 | 119 | @patch.object(hooks, 'configure_https') | 148 | @patch.object(hooks, 'configure_https') |
947 | 120 | def test_config_changed_no_upgrade(self, conf_https): | 149 | def test_config_changed_no_upgrade(self, conf_https): |
948 | 150 | self.git_install_requested.return_value = False | ||
949 | 121 | self.openstack_upgrade_available.return_value = False | 151 | self.openstack_upgrade_available.return_value = False |
950 | 122 | hooks.config_changed() | 152 | hooks.config_changed() |
951 | 123 | self.assertTrue(self.save_script_rc.called) | 153 | self.assertTrue(self.save_script_rc.called) |
952 | 124 | 154 | ||
953 | 155 | @patch.object(hooks, 'config_value_changed') | ||
954 | 156 | @patch.object(hooks, 'configure_https') | ||
955 | 157 | def test_config_changed_git(self, configure_https, config_val_changed): | ||
956 | 158 | self.git_install_requested.return_value = True | ||
957 | 159 | repo = 'cloud:trusty-juno' | ||
958 | 160 | openstack_origin_git = { | ||
959 | 161 | 'repositories': [ | ||
960 | 162 | {'name': 'requirements', | ||
961 | 163 | 'repository': | ||
962 | 164 | 'git://git.openstack.org/openstack/requirements', | ||
963 | 165 | 'branch': 'stable/juno'}, | ||
964 | 166 | {'name': 'nova', | ||
965 | 167 | 'repository': 'git://git.openstack.org/openstack/nova', | ||
966 | 168 | 'branch': 'stable/juno'} | ||
967 | 169 | ], | ||
968 | 170 | 'directory': '/mnt/openstack-git', | ||
969 | 171 | } | ||
970 | 172 | projects_yaml = yaml.dump(openstack_origin_git) | ||
971 | 173 | self.test_config.set('openstack-origin', repo) | ||
972 | 174 | self.test_config.set('openstack-origin-git', projects_yaml) | ||
973 | 175 | hooks.config_changed() | ||
974 | 176 | self.git_install.assert_called_with(projects_yaml) | ||
975 | 177 | self.assertFalse(self.do_openstack_upgrade.called) | ||
976 | 178 | |||
977 | 125 | @patch('charmhelpers.contrib.openstack.ip.service_name', | 179 | @patch('charmhelpers.contrib.openstack.ip.service_name', |
978 | 126 | lambda *args: 'nova-cloud-controller') | 180 | lambda *args: 'nova-cloud-controller') |
979 | 127 | @patch.object(hooks, 'cluster_joined') | 181 | @patch.object(hooks, 'cluster_joined') |
980 | @@ -130,6 +184,7 @@ | |||
981 | 130 | @patch.object(hooks, 'configure_https') | 184 | @patch.object(hooks, 'configure_https') |
982 | 131 | def test_config_changed_with_upgrade(self, conf_https, neutron_api_joined, | 185 | def test_config_changed_with_upgrade(self, conf_https, neutron_api_joined, |
983 | 132 | identity_joined, cluster_joined): | 186 | identity_joined, cluster_joined): |
984 | 187 | self.git_install_requested.return_value = False | ||
985 | 133 | self.openstack_upgrade_available.return_value = True | 188 | self.openstack_upgrade_available.return_value = True |
986 | 134 | self.relation_ids.return_value = ['generic_rid'] | 189 | self.relation_ids.return_value = ['generic_rid'] |
987 | 135 | _zmq_joined = self.patch('zeromq_configuration_relation_joined') | 190 | _zmq_joined = self.patch('zeromq_configuration_relation_joined') |
988 | @@ -768,6 +823,7 @@ | |||
989 | 768 | @patch('nova_cc_hooks.configure_https') | 823 | @patch('nova_cc_hooks.configure_https') |
990 | 769 | @patch('nova_cc_utils.config') | 824 | @patch('nova_cc_utils.config') |
991 | 770 | def test_config_changed_single_consoleauth(self, config, *args): | 825 | def test_config_changed_single_consoleauth(self, config, *args): |
992 | 826 | self.git_install_requested.return_value = False | ||
993 | 771 | config.return_value = 'novnc' | 827 | config.return_value = 'novnc' |
994 | 772 | rids = {'ha': ['ha:1']} | 828 | rids = {'ha': ['ha:1']} |
995 | 773 | 829 | ||
996 | 774 | 830 | ||
997 | === modified file 'unit_tests/test_nova_cc_utils.py' | |||
998 | --- unit_tests/test_nova_cc_utils.py 2015-05-11 09:51:21 +0000 | |||
999 | +++ unit_tests/test_nova_cc_utils.py 2015-06-11 13:34:00 +0000 | |||
1000 | @@ -127,6 +127,15 @@ | |||
1001 | 127 | '--option', 'Dpkg::Options::=--force-confdef', | 127 | '--option', 'Dpkg::Options::=--force-confdef', |
1002 | 128 | ] | 128 | ] |
1003 | 129 | 129 | ||
1004 | 130 | openstack_origin_git = \ | ||
1005 | 131 | """repositories: | ||
1006 | 132 | - {name: requirements, | ||
1007 | 133 | repository: 'git://git.openstack.org/openstack/requirements', | ||
1008 | 134 | branch: stable/juno} | ||
1009 | 135 | - {name: nova, | ||
1010 | 136 | repository: 'git://git.openstack.org/openstack/nova', | ||
1011 | 137 | branch: stable/juno}""" | ||
1012 | 138 | |||
1013 | 130 | 139 | ||
1014 | 131 | def fake_plugin_attribute(plugin, attr, net_manager): | 140 | def fake_plugin_attribute(plugin, attr, net_manager): |
1015 | 132 | if plugin in PLUGIN_ATTRIBUTES: | 141 | if plugin in PLUGIN_ATTRIBUTES: |
1016 | @@ -298,26 +307,34 @@ | |||
1017 | 298 | self.assertEquals(_proxy_page, None) | 307 | self.assertEquals(_proxy_page, None) |
1018 | 299 | 308 | ||
1019 | 300 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') | 309 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') |
1021 | 301 | def test_determine_packages_quantum(self, subcontext): | 310 | @patch.object(utils, 'git_install_requested') |
1022 | 311 | def test_determine_packages_quantum(self, git_requested, subcontext): | ||
1023 | 312 | git_requested.return_value = False | ||
1024 | 302 | self._resource_map(network_manager='quantum') | 313 | self._resource_map(network_manager='quantum') |
1025 | 303 | pkgs = utils.determine_packages() | 314 | pkgs = utils.determine_packages() |
1026 | 304 | self.assertIn('quantum-server', pkgs) | 315 | self.assertIn('quantum-server', pkgs) |
1027 | 305 | 316 | ||
1028 | 306 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') | 317 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') |
1030 | 307 | def test_determine_packages_neutron(self, subcontext): | 318 | @patch.object(utils, 'git_install_requested') |
1031 | 319 | def test_determine_packages_neutron(self, git_requested, subcontext): | ||
1032 | 320 | git_requested.return_value = False | ||
1033 | 308 | self.is_relation_made.return_value = False | 321 | self.is_relation_made.return_value = False |
1034 | 309 | self._resource_map(network_manager='neutron') | 322 | self._resource_map(network_manager='neutron') |
1035 | 310 | pkgs = utils.determine_packages() | 323 | pkgs = utils.determine_packages() |
1036 | 311 | self.assertIn('neutron-server', pkgs) | 324 | self.assertIn('neutron-server', pkgs) |
1037 | 312 | 325 | ||
1038 | 313 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') | 326 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') |
1040 | 314 | def test_determine_packages_nova_volume(self, subcontext): | 327 | @patch.object(utils, 'git_install_requested') |
1041 | 328 | def test_determine_packages_nova_volume(self, git_requested, subcontext): | ||
1042 | 329 | git_requested.return_value = False | ||
1043 | 315 | self.relation_ids.return_value = ['nova-volume-service:0'] | 330 | self.relation_ids.return_value = ['nova-volume-service:0'] |
1044 | 316 | pkgs = utils.determine_packages() | 331 | pkgs = utils.determine_packages() |
1045 | 317 | self.assertIn('nova-api-os-volume', pkgs) | 332 | self.assertIn('nova-api-os-volume', pkgs) |
1046 | 318 | 333 | ||
1047 | 319 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') | 334 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') |
1049 | 320 | def test_determine_packages_console(self, subcontext): | 335 | @patch.object(utils, 'git_install_requested') |
1050 | 336 | def test_determine_packages_console(self, git_requested, subcontext): | ||
1051 | 337 | git_requested.return_value = False | ||
1052 | 321 | self.test_config.set('console-access-protocol', 'spice') | 338 | self.test_config.set('console-access-protocol', 'spice') |
1053 | 322 | self.relation_ids.return_value = [] | 339 | self.relation_ids.return_value = [] |
1054 | 323 | pkgs = utils.determine_packages() | 340 | pkgs = utils.determine_packages() |
1055 | @@ -326,7 +343,9 @@ | |||
1056 | 326 | self.assertIn(console_pkg, pkgs) | 343 | self.assertIn(console_pkg, pkgs) |
1057 | 327 | 344 | ||
1058 | 328 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') | 345 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') |
1060 | 329 | def test_determine_packages_base(self, subcontext): | 346 | @patch.object(utils, 'git_install_requested') |
1061 | 347 | def test_determine_packages_base(self, git_requested, subcontext): | ||
1062 | 348 | git_requested.return_value = False | ||
1063 | 330 | self.relation_ids.return_value = [] | 349 | self.relation_ids.return_value = [] |
1064 | 331 | self.os_release.return_value = 'folsom' | 350 | self.os_release.return_value = 'folsom' |
1065 | 332 | pkgs = utils.determine_packages() | 351 | pkgs = utils.determine_packages() |
1066 | @@ -334,7 +353,10 @@ | |||
1067 | 334 | self.assertEquals(ex, pkgs) | 353 | self.assertEquals(ex, pkgs) |
1068 | 335 | 354 | ||
1069 | 336 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') | 355 | @patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext') |
1071 | 337 | def test_determine_packages_base_grizzly_beyond(self, subcontext): | 356 | @patch.object(utils, 'git_install_requested') |
1072 | 357 | def test_determine_packages_base_grizzly_beyond(self, git_requested, | ||
1073 | 358 | subcontext): | ||
1074 | 359 | git_requested.return_value = False | ||
1075 | 338 | self.relation_ids.return_value = [] | 360 | self.relation_ids.return_value = [] |
1076 | 339 | self.os_release.return_value = 'grizzly' | 361 | self.os_release.return_value = 'grizzly' |
1077 | 340 | pkgs = utils.determine_packages() | 362 | pkgs = utils.determine_packages() |
1078 | @@ -847,3 +869,264 @@ | |||
1079 | 847 | self.assertFalse(self.service_running.called) | 869 | self.assertFalse(self.service_running.called) |
1080 | 848 | self.assertFalse(self.service_stop.called) | 870 | self.assertFalse(self.service_stop.called) |
1081 | 849 | self.assertTrue(contexts.complete_contexts.called) | 871 | self.assertTrue(contexts.complete_contexts.called) |
1082 | 872 | |||
1083 | 873 | @patch.object(utils, 'git_install_requested') | ||
1084 | 874 | @patch.object(utils, 'git_clone_and_install') | ||
1085 | 875 | @patch.object(utils, 'git_post_install') | ||
1086 | 876 | @patch.object(utils, 'git_pre_install') | ||
1087 | 877 | def test_git_install(self, git_pre, git_post, git_clone_and_install, | ||
1088 | 878 | git_requested): | ||
1089 | 879 | projects_yaml = openstack_origin_git | ||
1090 | 880 | git_requested.return_value = True | ||
1091 | 881 | utils.git_install(projects_yaml) | ||
1092 | 882 | self.assertTrue(git_pre.called) | ||
1093 | 883 | git_clone_and_install.assert_called_with(openstack_origin_git, | ||
1094 | 884 | core_project='nova') | ||
1095 | 885 | self.assertTrue(git_post.called) | ||
1096 | 886 | |||
1097 | 887 | @patch.object(utils, 'mkdir') | ||
1098 | 888 | @patch.object(utils, 'add_user_to_group') | ||
1099 | 889 | @patch.object(utils, 'add_group') | ||
1100 | 890 | @patch.object(utils, 'adduser') | ||
1101 | 891 | @patch('subprocess.check_call') | ||
1102 | 892 | def test_git_pre_install(self, check_call, adduser, add_group, | ||
1103 | 893 | add_user_to_group, mkdir): | ||
1104 | 894 | utils.git_pre_install() | ||
1105 | 895 | expected = [ | ||
1106 | 896 | call('nova', shell='/bin/bash', system_user=True), | ||
1107 | 897 | call('neutron', shell='/bin/bash', system_user=True), | ||
1108 | 898 | ] | ||
1109 | 899 | self.assertEquals(adduser.call_args_list, expected) | ||
1110 | 900 | check_call.assert_called_with(['usermod', '--home', '/var/lib/nova', | ||
1111 | 901 | 'nova']) | ||
1112 | 902 | expected = [ | ||
1113 | 903 | call('nova', system_group=True), | ||
1114 | 904 | call('neutron', system_group=True), | ||
1115 | 905 | ] | ||
1116 | 906 | self.assertEquals(add_group.call_args_list, expected) | ||
1117 | 907 | expected = [ | ||
1118 | 908 | call('nova', 'nova'), | ||
1119 | 909 | call('neutron', 'neutron'), | ||
1120 | 910 | ] | ||
1121 | 911 | self.assertEquals(add_user_to_group.call_args_list, expected) | ||
1122 | 912 | expected = [ | ||
1123 | 913 | call('/var/lib/nova', owner='nova', | ||
1124 | 914 | group='nova', perms=0755, force=False), | ||
1125 | 915 | call('/var/lib/nova/buckets', owner='nova', | ||
1126 | 916 | group='nova', perms=0755, force=False), | ||
1127 | 917 | call('/var/lib/nova/CA', owner='nova', | ||
1128 | 918 | group='nova', perms=0755, force=False), | ||
1129 | 919 | call('/var/lib/nova/CA/INTER', owner='nova', | ||
1130 | 920 | group='nova', perms=0755, force=False), | ||
1131 | 921 | call('/var/lib/nova/CA/newcerts', owner='nova', | ||
1132 | 922 | group='nova', perms=0755, force=False), | ||
1133 | 923 | call('/var/lib/nova/CA/private', owner='nova', | ||
1134 | 924 | group='nova', perms=0755, force=False), | ||
1135 | 925 | call('/var/lib/nova/CA/reqs', owner='nova', | ||
1136 | 926 | group='nova', perms=0755, force=False), | ||
1137 | 927 | call('/var/lib/nova/images', owner='nova', | ||
1138 | 928 | group='nova', perms=0755, force=False), | ||
1139 | 929 | call('/var/lib/nova/instances', owner='nova', | ||
1140 | 930 | group='nova', perms=0755, force=False), | ||
1141 | 931 | call('/var/lib/nova/keys', owner='nova', | ||
1142 | 932 | group='nova', perms=0755, force=False), | ||
1143 | 933 | call('/var/lib/nova/networks', owner='nova', | ||
1144 | 934 | group='nova', perms=0755, force=False), | ||
1145 | 935 | call('/var/lib/nova/tmp', owner='nova', | ||
1146 | 936 | group='nova', perms=0755, force=False), | ||
1147 | 937 | call('/var/lib/neutron', owner='nova', | ||
1148 | 938 | group='nova', perms=0755, force=False), | ||
1149 | 939 | call('/var/lib/neutron/lock', owner='nova', | ||
1150 | 940 | group='nova', perms=0755, force=False), | ||
1151 | 941 | call('/var/log/nova', owner='nova', | ||
1152 | 942 | group='nova', perms=0755, force=False), | ||
1153 | 943 | call('/etc/neutron', owner='nova', | ||
1154 | 944 | group='nova', perms=0755, force=False), | ||
1155 | 945 | call('/etc/neutron/plugins', owner='nova', | ||
1156 | 946 | group='nova', perms=0755, force=False), | ||
1157 | 947 | call('/etc/neutron/plugins/ml2', owner='nova', | ||
1158 | 948 | group='nova', perms=0755, force=False), | ||
1159 | 949 | ] | ||
1160 | 950 | self.assertEquals(mkdir.call_args_list, expected) | ||
1161 | 951 | |||
1162 | 952 | @patch.object(utils, 'git_src_dir') | ||
1163 | 953 | @patch.object(utils, 'render') | ||
1164 | 954 | @patch.object(utils, 'git_pip_venv_dir') | ||
1165 | 955 | @patch.object(utils, 'pip_install') | ||
1166 | 956 | @patch('os.path.join') | ||
1167 | 957 | @patch('os.path.exists') | ||
1168 | 958 | @patch('os.symlink') | ||
1169 | 959 | @patch('shutil.copytree') | ||
1170 | 960 | @patch('shutil.rmtree') | ||
1171 | 961 | def test_git_post_install(self, rmtree, copytree, symlink, | ||
1172 | 962 | exists, join, pip_install, venv, render, | ||
1173 | 963 | git_src_dir): | ||
1174 | 964 | projects_yaml = openstack_origin_git | ||
1175 | 965 | join.return_value = 'joined-string' | ||
1176 | 966 | venv.return_value = '/mnt/openstack-git/venv' | ||
1177 | 967 | utils.git_post_install(projects_yaml) | ||
1178 | 968 | expected = [ | ||
1179 | 969 | call('joined-string', '/etc/nova'), | ||
1180 | 970 | ] | ||
1181 | 971 | copytree.assert_has_calls(expected) | ||
1182 | 972 | expected = [ | ||
1183 | 973 | call('joined-string', '/usr/local/bin/nova-manage'), | ||
1184 | 974 | call('joined-string', '/usr/local/bin/nova-rootwrap'), | ||
1185 | 975 | ] | ||
1186 | 976 | |||
1187 | 977 | nova_cc = 'nova-cloud-controller' | ||
1188 | 978 | nova_user = 'nova' | ||
1189 | 979 | start_dir = '/var/lib/nova' | ||
1190 | 980 | nova_conf = '/etc/nova/nova.conf' | ||
1191 | 981 | nova_ec2_api_context = { | ||
1192 | 982 | 'service_description': 'Nova EC2 API server', | ||
1193 | 983 | 'service_name': nova_cc, | ||
1194 | 984 | 'user_name': nova_user, | ||
1195 | 985 | 'start_dir': start_dir, | ||
1196 | 986 | 'process_name': 'nova-api-ec2', | ||
1197 | 987 | 'executable_name': 'joined-string', | ||
1198 | 988 | 'config_files': [nova_conf], | ||
1199 | 989 | } | ||
1200 | 990 | nova_api_os_compute_context = { | ||
1201 | 991 | 'service_description': 'Nova OpenStack Compute API server', | ||
1202 | 992 | 'service_name': nova_cc, | ||
1203 | 993 | 'user_name': nova_user, | ||
1204 | 994 | 'start_dir': start_dir, | ||
1205 | 995 | 'process_name': 'nova-api-os-compute', | ||
1206 | 996 | 'executable_name': 'joined-string', | ||
1207 | 997 | 'config_files': [nova_conf], | ||
1208 | 998 | } | ||
1209 | 999 | nova_cells_context = { | ||
1210 | 1000 | 'service_description': 'Nova cells', | ||
1211 | 1001 | 'service_name': nova_cc, | ||
1212 | 1002 | 'user_name': nova_user, | ||
1213 | 1003 | 'start_dir': start_dir, | ||
1214 | 1004 | 'process_name': 'nova-cells', | ||
1215 | 1005 | 'executable_name': 'joined-string', | ||
1216 | 1006 | 'config_files': [nova_conf], | ||
1217 | 1007 | } | ||
1218 | 1008 | nova_cert_context = { | ||
1219 | 1009 | 'service_description': 'Nova cert', | ||
1220 | 1010 | 'service_name': nova_cc, | ||
1221 | 1011 | 'user_name': nova_user, | ||
1222 | 1012 | 'start_dir': start_dir, | ||
1223 | 1013 | 'process_name': 'nova-cert', | ||
1224 | 1014 | 'executable_name': 'joined-string', | ||
1225 | 1015 | 'config_files': [nova_conf], | ||
1226 | 1016 | } | ||
1227 | 1017 | nova_conductor_context = { | ||
1228 | 1018 | 'service_description': 'Nova conductor', | ||
1229 | 1019 | 'service_name': nova_cc, | ||
1230 | 1020 | 'user_name': nova_user, | ||
1231 | 1021 | 'start_dir': start_dir, | ||
1232 | 1022 | 'process_name': 'nova-conductor', | ||
1233 | 1023 | 'executable_name': 'joined-string', | ||
1234 | 1024 | 'config_files': [nova_conf], | ||
1235 | 1025 | } | ||
1236 | 1026 | nova_consoleauth_context = { | ||
1237 | 1027 | 'service_description': 'Nova console auth', | ||
1238 | 1028 | 'service_name': nova_cc, | ||
1239 | 1029 | 'user_name': nova_user, | ||
1240 | 1030 | 'start_dir': start_dir, | ||
1241 | 1031 | 'process_name': 'nova-consoleauth', | ||
1242 | 1032 | 'executable_name': 'joined-string', | ||
1243 | 1033 | 'config_files': [nova_conf], | ||
1244 | 1034 | } | ||
1245 | 1035 | nova_console_context = { | ||
1246 | 1036 | 'service_description': 'Nova console', | ||
1247 | 1037 | 'service_name': nova_cc, | ||
1248 | 1038 | 'user_name': nova_user, | ||
1249 | 1039 | 'start_dir': start_dir, | ||
1250 | 1040 | 'process_name': 'nova-console', | ||
1251 | 1041 | 'executable_name': 'joined-string', | ||
1252 | 1042 | 'config_files': [nova_conf], | ||
1253 | 1043 | } | ||
1254 | 1044 | nova_novncproxy_context = { | ||
1255 | 1045 | 'service_description': 'Nova NoVNC proxy', | ||
1256 | 1046 | 'service_name': nova_cc, | ||
1257 | 1047 | 'user_name': nova_user, | ||
1258 | 1048 | 'start_dir': start_dir, | ||
1259 | 1049 | 'process_name': 'nova-novncproxy', | ||
1260 | 1050 | 'executable_name': 'joined-string', | ||
1261 | 1051 | 'config_files': [nova_conf], | ||
1262 | 1052 | } | ||
1263 | 1053 | nova_objectstore_context = { | ||
1264 | 1054 | 'service_description': 'Nova object store', | ||
1265 | 1055 | 'service_name': nova_cc, | ||
1266 | 1056 | 'user_name': nova_user, | ||
1267 | 1057 | 'start_dir': start_dir, | ||
1268 | 1058 | 'process_name': 'nova-objectstore', | ||
1269 | 1059 | 'executable_name': 'joined-string', | ||
1270 | 1060 | 'config_files': [nova_conf], | ||
1271 | 1061 | } | ||
1272 | 1062 | nova_scheduler_context = { | ||
1273 | 1063 | 'service_description': 'Nova scheduler', | ||
1274 | 1064 | 'service_name': nova_cc, | ||
1275 | 1065 | 'user_name': nova_user, | ||
1276 | 1066 | 'start_dir': start_dir, | ||
1277 | 1067 | 'process_name': 'nova-scheduler', | ||
1278 | 1068 | 'executable_name': 'joined-string', | ||
1279 | 1069 | 'config_files': [nova_conf], | ||
1280 | 1070 | } | ||
1281 | 1071 | nova_spiceproxy_context = { | ||
1282 | 1072 | 'service_description': 'Nova spice proxy', | ||
1283 | 1073 | 'service_name': nova_cc, | ||
1284 | 1074 | 'user_name': nova_user, | ||
1285 | 1075 | 'start_dir': start_dir, | ||
1286 | 1076 | 'process_name': 'nova-spicehtml5proxy', | ||
1287 | 1077 | 'executable_name': 'joined-string', | ||
1288 | 1078 | 'config_files': [nova_conf], | ||
1289 | 1079 | } | ||
1290 | 1080 | nova_xvpvncproxy_context = { | ||
1291 | 1081 | 'service_description': 'Nova XVPVNC proxy', | ||
1292 | 1082 | 'service_name': nova_cc, | ||
1293 | 1083 | 'user_name': nova_user, | ||
1294 | 1084 | 'start_dir': start_dir, | ||
1295 | 1085 | 'process_name': 'nova-xvpvncproxy', | ||
1296 | 1086 | 'executable_name': 'joined-string', | ||
1297 | 1087 | 'config_files': [nova_conf], | ||
1298 | 1088 | } | ||
1299 | 1089 | expected = [ | ||
1300 | 1090 | call('git/nova_sudoers', '/etc/sudoers.d/nova_sudoers', | ||
1301 | 1091 | {}, perms=0o440), | ||
1302 | 1092 | call('git.upstart', '/etc/init/nova-api-ec2.conf', | ||
1303 | 1093 | nova_ec2_api_context, perms=0o644, | ||
1304 | 1094 | templates_dir='joined-string'), | ||
1305 | 1095 | call('git.upstart', '/etc/init/nova-api-os-compute.conf', | ||
1306 | 1096 | nova_api_os_compute_context, perms=0o644, | ||
1307 | 1097 | templates_dir='joined-string'), | ||
1308 | 1098 | call('git.upstart', '/etc/init/nova-cells.conf', | ||
1309 | 1099 | nova_cells_context, perms=0o644, | ||
1310 | 1100 | templates_dir='joined-string'), | ||
1311 | 1101 | call('git.upstart', '/etc/init/nova-cert.conf', | ||
1312 | 1102 | nova_cert_context, perms=0o644, | ||
1313 | 1103 | templates_dir='joined-string'), | ||
1314 | 1104 | call('git.upstart', '/etc/init/nova-conductor.conf', | ||
1315 | 1105 | nova_conductor_context, perms=0o644, | ||
1316 | 1106 | templates_dir='joined-string'), | ||
1317 | 1107 | call('git.upstart', '/etc/init/nova-consoleauth.conf', | ||
1318 | 1108 | nova_consoleauth_context, perms=0o644, | ||
1319 | 1109 | templates_dir='joined-string'), | ||
1320 | 1110 | call('git.upstart', '/etc/init/nova-console.conf', | ||
1321 | 1111 | nova_console_context, perms=0o644, | ||
1322 | 1112 | templates_dir='joined-string'), | ||
1323 | 1113 | call('git.upstart', '/etc/init/nova-novncproxy.conf', | ||
1324 | 1114 | nova_novncproxy_context, perms=0o644, | ||
1325 | 1115 | templates_dir='joined-string'), | ||
1326 | 1116 | call('git.upstart', '/etc/init/nova-objectstore.conf', | ||
1327 | 1117 | nova_objectstore_context, perms=0o644, | ||
1328 | 1118 | templates_dir='joined-string'), | ||
1329 | 1119 | call('git.upstart', '/etc/init/nova-scheduler.conf', | ||
1330 | 1120 | nova_scheduler_context, perms=0o644, | ||
1331 | 1121 | templates_dir='joined-string'), | ||
1332 | 1122 | call('git.upstart', '/etc/init/nova-spiceproxy.conf', | ||
1333 | 1123 | nova_spiceproxy_context, perms=0o644, | ||
1334 | 1124 | templates_dir='joined-string'), | ||
1335 | 1125 | call('git.upstart', '/etc/init/nova-xvpvncproxy.conf', | ||
1336 | 1126 | nova_xvpvncproxy_context, perms=0o644, | ||
1337 | 1127 | templates_dir='joined-string'), | ||
1338 | 1128 | ] | ||
1339 | 1129 | self.assertEquals(render.call_args_list, expected) | ||
1340 | 1130 | self.assertTrue(self.apt_update.called) | ||
1341 | 1131 | self.apt_install.assert_called_with(['novnc', 'spice-html5', | ||
1342 | 1132 | 'websockify'], fatal=True) |
charm_lint_check #4463 nova-cloud- controller- next for corey.bryant mp258923
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/4463/