Merge lp:~corey.bryant/charms/trusty/neutron-openvswitch/git into lp:~openstack-charmers-archive/charms/trusty/neutron-openvswitch/next
- Trusty Tahr (14.04)
- git
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 59 |
Proposed branch: | lp:~corey.bryant/charms/trusty/neutron-openvswitch/git |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/neutron-openvswitch/next |
Diff against target: |
1087 lines (+702/-53) (has conflicts) 24 files modified
.bzrignore (+1/-0) Makefile (+4/-3) README.md (+87/-0) actions.yaml (+2/-0) actions/git_reinstall.py (+45/-0) charm-helpers-hooks.yaml (+12/-0) charm-helpers-sync.yaml (+0/-12) config.yaml (+17/-0) hooks/charmhelpers/contrib/openstack/utils.py (+18/-6) hooks/neutron_ovs_hooks.py (+13/-0) hooks/neutron_ovs_utils.py (+123/-2) templates/git/neutron_sudoers (+4/-0) templates/git/upstart/neutron-ovs-cleanup.upstart (+17/-0) templates/git/upstart/neutron-plugin-openvswitch-agent.upstart (+18/-0) tests/16-basic-trusty-icehouse-git (+9/-0) tests/16-basic-trusty-juno (+0/-11) tests/17-basic-trusty-juno (+11/-0) tests/18-basic-trusty-juno-git (+12/-0) tests/basic_deployment.py (+28/-5) unit_tests/__init__.py (+2/-0) unit_tests/test_actions_git_reinstall.py (+105/-0) unit_tests/test_neutron_ovs_context.py (+1/-1) unit_tests/test_neutron_ovs_hooks.py (+71/-12) unit_tests/test_neutron_ovs_utils.py (+102/-1) Text conflict in hooks/charmhelpers/contrib/openstack/utils.py |
To merge this branch: | bzr merge lp:~corey.bryant/charms/trusty/neutron-openvswitch/git |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ryan Beisner (community) | Needs Fixing | ||
OpenStack Charmers | Pending | ||
Review via email: mp+255122@code.launchpad.net |
Commit message
Description of the change
- 50. By Corey Bryant
-
Deploy from source
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #2866 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #2896 neutron-
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://
Ryan Beisner (1chb1n) wrote : | # |
The added amulet test has failed. FYI, the baseline neutron-
01:02:43.260 2015-04-07 05:23:32 Deployment complete in 335.19 seconds
01:04:42.652 juju-test.
- 51. By Corey Bryant
-
Bump amulet propagation test sleep time as it appears to time out on osci
Corey Bryant (corey.bryant) wrote : | # |
I think the propagation tests are taking longer to run than they used to so
I've pushed a new commit to this branch that bumps the sleep time in those
tests.
On Tue, Apr 7, 2015 at 8:52 AM, Ryan Beisner <email address hidden>
wrote:
> Review: Needs Fixing
>
> The added amulet test has failed. FYI, the baseline
> neutron-
>
> 01:02:43.260 2015-04-07 05:23:32 Deployment complete in 335.19 seconds
> 01:04:42.652 juju-test.
> Propagation error, expected l2_population=False
> --
>
> https:/
> You are the owner of
> lp:~corey.bryant/charms/trusty/neutron-openvswitch/git.
>
--
Regards,
Corey
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #2892 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3104 neutron-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #2927 neutron-
AMULET OK: passed
Build: http://
- 52. By Corey Bryant
-
Get http_proxy from AMULET_HTTP_PROXY env var
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3285 neutron-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3073 neutron-
UNIT OK: passed
- 53. By Corey Bryant
-
Move deploy from source template files to templates/git
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3102 neutron-
AMULET OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3292 neutron-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3080 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3109 neutron-
AMULET OK: passed
Build: http://
- 54. By Corey Bryant
-
Bulk copy files to /etc/neutron
- 55. By Corey Bryant
-
Turn DEBUG on by default for amulet tests
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3305 neutron-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3093 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3124 neutron-
AMULET OK: passed
Build: http://
- 56. By Corey Bryant
-
Run config-changed hook after git-reinstall action installs from source
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3317 neutron-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3105 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3138 neutron-
AMULET OK: passed
Build: http://
- 57. By Corey Bryant
-
Fixup test_git_
reinstall_ exception( )
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3396 neutron-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3184 neutron-
UNIT OK: passed
- 58. By Corey Bryant
-
Merge next branch
- 59. By Corey Bryant
-
Sync charm-helpers
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3404 neutron-
LINT FAIL: lint-test failed
LINT Results (max last 2 lines):
make: *** [lint] Error 1
ERROR:root:Make target returned non-zero.
Full lint test output: http://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3192 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3186 neutron-
AMULET OK: passed
Build: http://
- 60. By Corey Bryant
-
Move config_changed into try block
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3412 neutron-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3200 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3197 neutron-
AMULET OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3205 neutron-
AMULET OK: passed
Build: http://
- 61. By Corey Bryant
-
Sync charm-helpers
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #3453 neutron-
LINT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #3241 neutron-
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #3251 neutron-
AMULET OK: passed
Build: http://
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2014-06-24 11:19:07 +0000 |
3 | +++ .bzrignore 2015-04-16 14:43:44 +0000 |
4 | @@ -1,2 +1,3 @@ |
5 | bin |
6 | .coverage |
7 | +tags |
8 | |
9 | === modified file 'Makefile' |
10 | --- Makefile 2015-02-13 12:02:13 +0000 |
11 | +++ Makefile 2015-04-16 14:43:44 +0000 |
12 | @@ -2,7 +2,7 @@ |
13 | PYTHON := /usr/bin/env python |
14 | |
15 | lint: |
16 | - @flake8 --exclude hooks/charmhelpers hooks unit_tests tests |
17 | + @flake8 --exclude hooks/charmhelpers actions hooks unit_tests tests |
18 | @charm proof |
19 | |
20 | unit_test: |
21 | @@ -15,7 +15,7 @@ |
22 | > bin/charm_helpers_sync.py |
23 | |
24 | sync: bin/charm_helpers_sync.py |
25 | - @$(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-sync.yaml |
26 | + @$(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-hooks.yaml |
27 | @$(PYTHON) bin/charm_helpers_sync.py -c charm-helpers-tests.yaml |
28 | |
29 | test: |
30 | @@ -25,7 +25,8 @@ |
31 | # https://bugs.launchpad.net/amulet/+bug/1320357 |
32 | @juju test -v -p AMULET_HTTP_PROXY --timeout 900 \ |
33 | 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse \ |
34 | - 16-basic-trusty-juno |
35 | + 16-basic-trusty-icehouse-git 17-basic-trusty-juno \ |
36 | + 18-basic-trusty-juno-git |
37 | |
38 | publish: lint unit_test |
39 | bzr push lp:charms/neutron-openvswitch |
40 | |
41 | === modified file 'README.md' |
42 | --- README.md 2014-10-14 16:45:46 +0000 |
43 | +++ README.md 2015-04-16 14:43:44 +0000 |
44 | @@ -41,3 +41,90 @@ |
45 | ... |
46 | |
47 | These compute nodes could then be accessed by cloud users via use of host aggregates with specific flavors to target instances to hypervisors with no per-instance security. |
48 | + |
49 | +# Deploying from source |
50 | + |
51 | +The minimum openstack-origin-git config required to deploy from source is: |
52 | + |
53 | + openstack-origin-git: |
54 | + "repositories: |
55 | + - {name: requirements, |
56 | + repository: 'git://git.openstack.org/openstack/requirements', |
57 | + branch: stable/juno} |
58 | + - {name: neutron, |
59 | + repository: 'git://git.openstack.org/openstack/neutron', |
60 | + branch: stable/juno}" |
61 | + |
62 | +Note that there are only two 'name' values the charm knows about: 'requirements' |
63 | +and 'neutron'. These repositories must correspond to these 'name' values. |
64 | +Additionally, the requirements repository must be specified first and the |
65 | +neutron repository must be specified last. All other repostories are installed |
66 | +in the order in which they are specified. |
67 | + |
68 | +The following is a full list of current tip repos (may not be up-to-date): |
69 | + |
70 | + openstack-origin-git: |
71 | + "repositories: |
72 | + - {name: requirements, |
73 | + repository: 'git://git.openstack.org/openstack/requirements', |
74 | + branch: master} |
75 | + - {name: oslo-concurrency, |
76 | + repository: 'git://git.openstack.org/openstack/oslo.concurrency', |
77 | + branch: master} |
78 | + - {name: oslo-config, |
79 | + repository: 'git://git.openstack.org/openstack/oslo.config', |
80 | + branch: master} |
81 | + - {name: oslo-context, |
82 | + repository: 'git://git.openstack.org/openstack/oslo.context.git', |
83 | + branch: master} |
84 | + - {name: oslo-db, |
85 | + repository: 'git://git.openstack.org/openstack/oslo.db', |
86 | + branch: master} |
87 | + - {name: oslo-i18n, |
88 | + repository: 'git://git.openstack.org/openstack/oslo.i18n', |
89 | + branch: master} |
90 | + - {name: oslo-messaging, |
91 | + repository: 'git://git.openstack.org/openstack/oslo.messaging.git', |
92 | + branch: master} |
93 | + - {name: oslo-middleware, |
94 | + repository': 'git://git.openstack.org/openstack/oslo.middleware.git', |
95 | + branch: master} |
96 | + - {name: oslo-rootwrap', |
97 | + repository: 'git://git.openstack.org/openstack/oslo.rootwrap.git', |
98 | + branch: master} |
99 | + - {name: oslo-serialization, |
100 | + repository: 'git://git.openstack.org/openstack/oslo.serialization', |
101 | + branch: master} |
102 | + - {name: oslo-utils, |
103 | + repository: 'git://git.openstack.org/openstack/oslo.utils', |
104 | + branch: master} |
105 | + - {name: pbr, |
106 | + repository: 'git://git.openstack.org/openstack-dev/pbr', |
107 | + branch: master} |
108 | + - {name: stevedore, |
109 | + repository: 'git://git.openstack.org/openstack/stevedore.git', |
110 | + branch: 'master'} |
111 | + - {name: python-keystoneclient, |
112 | + repository: 'git://git.openstack.org/openstack/python-keystoneclient', |
113 | + branch: master} |
114 | + - {name: python-neutronclient, |
115 | + repository: 'git://git.openstack.org/openstack/python-neutronclient.git', |
116 | + branch: master} |
117 | + - {name: python-novaclient, |
118 | + repository': 'git://git.openstack.org/openstack/python-novaclient.git', |
119 | + branch: master} |
120 | + - {name: keystonemiddleware, |
121 | + repository: 'git://git.openstack.org/openstack/keystonemiddleware', |
122 | + branch: master} |
123 | + - {name: neutron-fwaas, |
124 | + repository': 'git://git.openstack.org/openstack/neutron-fwaas.git', |
125 | + branch: master} |
126 | + - {name: neutron-lbaas, |
127 | + repository: 'git://git.openstack.org/openstack/neutron-lbaas.git', |
128 | + branch: master} |
129 | + - {name: neutron-vpnaas, |
130 | + repository: 'git://git.openstack.org/openstack/neutron-vpnaas.git', |
131 | + branch: master} |
132 | + - {name: neutron, |
133 | + repository: 'git://git.openstack.org/openstack/neutron', |
134 | + branch: master}" |
135 | |
136 | === added directory 'actions' |
137 | === added file 'actions.yaml' |
138 | --- actions.yaml 1970-01-01 00:00:00 +0000 |
139 | +++ actions.yaml 2015-04-16 14:43:44 +0000 |
140 | @@ -0,0 +1,2 @@ |
141 | +git-reinstall: |
142 | + description: Reinstall neutron-openvswitch from the openstack-origin-git repositories. |
143 | |
144 | === added symlink 'actions/git-reinstall' |
145 | === target is u'git_reinstall.py' |
146 | === added file 'actions/git_reinstall.py' |
147 | --- actions/git_reinstall.py 1970-01-01 00:00:00 +0000 |
148 | +++ actions/git_reinstall.py 2015-04-16 14:43:44 +0000 |
149 | @@ -0,0 +1,45 @@ |
150 | +#!/usr/bin/python |
151 | +import sys |
152 | +import traceback |
153 | + |
154 | +sys.path.append('hooks/') |
155 | + |
156 | +from charmhelpers.contrib.openstack.utils import ( |
157 | + git_install_requested, |
158 | +) |
159 | + |
160 | +from charmhelpers.core.hookenv import ( |
161 | + action_set, |
162 | + action_fail, |
163 | + config, |
164 | +) |
165 | + |
166 | +from neutron_ovs_utils import ( |
167 | + git_install, |
168 | +) |
169 | + |
170 | +from neutron_ovs_hooks import ( |
171 | + config_changed, |
172 | +) |
173 | + |
174 | + |
175 | +def git_reinstall(): |
176 | + """Reinstall from source and restart services. |
177 | + |
178 | + If the openstack-origin-git config option was used to install openstack |
179 | + from source git repositories, then this action can be used to reinstall |
180 | + from updated git repositories, followed by a restart of services.""" |
181 | + if not git_install_requested(): |
182 | + action_fail('openstack-origin-git is not configured') |
183 | + return |
184 | + |
185 | + try: |
186 | + git_install(config('openstack-origin-git')) |
187 | + config_changed() |
188 | + except: |
189 | + action_set({'traceback': traceback.format_exc()}) |
190 | + action_fail('git-reinstall resulted in an unexpected error') |
191 | + |
192 | + |
193 | +if __name__ == '__main__': |
194 | + git_reinstall() |
195 | |
196 | === added file 'charm-helpers-hooks.yaml' |
197 | --- charm-helpers-hooks.yaml 1970-01-01 00:00:00 +0000 |
198 | +++ charm-helpers-hooks.yaml 2015-04-16 14:43:44 +0000 |
199 | @@ -0,0 +1,12 @@ |
200 | +branch: lp:charm-helpers |
201 | +destination: hooks/charmhelpers |
202 | +include: |
203 | + - core |
204 | + - fetch |
205 | + - contrib.openstack|inc=* |
206 | + - contrib.hahelpers |
207 | + - contrib.network.ovs |
208 | + - contrib.storage.linux |
209 | + - payload.execd |
210 | + - contrib.network.ip |
211 | + - contrib.python.packages |
212 | |
213 | === removed file 'charm-helpers-sync.yaml' |
214 | --- charm-helpers-sync.yaml 2015-04-01 14:19:17 +0000 |
215 | +++ charm-helpers-sync.yaml 1970-01-01 00:00:00 +0000 |
216 | @@ -1,12 +0,0 @@ |
217 | -branch: lp:charm-helpers |
218 | -destination: hooks/charmhelpers |
219 | -include: |
220 | - - core |
221 | - - fetch |
222 | - - contrib.openstack|inc=* |
223 | - - contrib.hahelpers |
224 | - - contrib.network.ovs |
225 | - - contrib.storage.linux |
226 | - - payload.execd |
227 | - - contrib.network.ip |
228 | - - contrib.python.packages |
229 | |
230 | === modified file 'config.yaml' |
231 | --- config.yaml 2015-03-25 09:49:01 +0000 |
232 | +++ config.yaml 2015-04-16 14:43:44 +0000 |
233 | @@ -1,4 +1,21 @@ |
234 | options: |
235 | + openstack-origin-git: |
236 | + default: |
237 | + type: string |
238 | + description: | |
239 | + Specifies a YAML-formatted dictionary listing the git |
240 | + repositories and branches from which to install OpenStack and |
241 | + its dependencies. |
242 | + |
243 | + When openstack-origin-git is specified, openstack-specific |
244 | + packages will be installed from source rather than from the |
245 | + the nova-compute charm's openstack-origin repository. |
246 | + |
247 | + Note that the installed config files will be determined based on |
248 | + the OpenStack release of the nova-compute charm's openstack-origin |
249 | + option. |
250 | + |
251 | + For more details see README.md. |
252 | rabbit-user: |
253 | default: neutron |
254 | type: string |
255 | |
256 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' |
257 | --- hooks/charmhelpers/contrib/openstack/utils.py 2015-04-16 10:30:12 +0000 |
258 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2015-04-16 14:43:44 +0000 |
259 | @@ -524,12 +524,22 @@ |
260 | projects = yaml.load(projects_yaml) |
261 | _git_validate_projects_yaml(projects, core_project) |
262 | |
263 | - if 'http_proxy' in projects.keys(): |
264 | - os.environ['http_proxy'] = projects['http_proxy'] |
265 | - |
266 | - if 'https_proxy' in projects.keys(): |
267 | - os.environ['https_proxy'] = projects['https_proxy'] |
268 | - |
269 | +<<<<<<< TREE |
270 | + if 'http_proxy' in projects.keys(): |
271 | + os.environ['http_proxy'] = projects['http_proxy'] |
272 | + |
273 | + if 'https_proxy' in projects.keys(): |
274 | + os.environ['https_proxy'] = projects['https_proxy'] |
275 | + |
276 | +======= |
277 | + old_environ = dict(os.environ) |
278 | + |
279 | + if 'http_proxy' in projects.keys(): |
280 | + os.environ['http_proxy'] = projects['http_proxy'] |
281 | + if 'https_proxy' in projects.keys(): |
282 | + os.environ['https_proxy'] = projects['https_proxy'] |
283 | + |
284 | +>>>>>>> MERGE-SOURCE |
285 | if 'directory' in projects.keys(): |
286 | parent_dir = projects['directory'] |
287 | |
288 | @@ -544,6 +554,8 @@ |
289 | repo_dir = _git_clone_and_install_single(repo, branch, parent_dir, |
290 | update_requirements=True) |
291 | |
292 | + os.environ = old_environ |
293 | + |
294 | |
295 | def _git_validate_projects_yaml(projects, core_project): |
296 | """ |
297 | |
298 | === modified file 'hooks/neutron_ovs_hooks.py' |
299 | --- hooks/neutron_ovs_hooks.py 2015-04-01 14:19:17 +0000 |
300 | +++ hooks/neutron_ovs_hooks.py 2015-04-16 14:43:44 +0000 |
301 | @@ -2,6 +2,11 @@ |
302 | |
303 | import sys |
304 | |
305 | +from charmhelpers.contrib.openstack.utils import ( |
306 | + config_value_changed, |
307 | + git_install_requested, |
308 | +) |
309 | + |
310 | from charmhelpers.core.hookenv import ( |
311 | Hooks, |
312 | UnregisteredHookError, |
313 | @@ -27,6 +32,7 @@ |
314 | DVR_PACKAGES, |
315 | configure_ovs, |
316 | determine_packages, |
317 | + git_install, |
318 | get_topics, |
319 | determine_dvr_packages, |
320 | get_shared_secret, |
321 | @@ -46,6 +52,8 @@ |
322 | for pkg in pkgs: |
323 | apt_install(pkg, fatal=True) |
324 | |
325 | + git_install(config('openstack-origin-git')) |
326 | + |
327 | |
328 | @hooks.hook('neutron-plugin-relation-changed') |
329 | @hooks.hook('config-changed') |
330 | @@ -54,6 +62,11 @@ |
331 | if determine_dvr_packages(): |
332 | apt_update() |
333 | apt_install(determine_dvr_packages(), fatal=True) |
334 | + |
335 | + if git_install_requested(): |
336 | + if config_value_changed('openstack-origin-git'): |
337 | + git_install(config('openstack-origin-git')) |
338 | + |
339 | configure_ovs() |
340 | CONFIGS.write_all() |
341 | for rid in relation_ids('zeromq-configuration'): |
342 | |
343 | === modified file 'hooks/neutron_ovs_utils.py' |
344 | --- hooks/neutron_ovs_utils.py 2015-04-01 14:19:17 +0000 |
345 | +++ hooks/neutron_ovs_utils.py 2015-04-16 14:43:44 +0000 |
346 | @@ -1,7 +1,15 @@ |
347 | +import os |
348 | +import shutil |
349 | + |
350 | from charmhelpers.contrib.openstack.neutron import neutron_plugin_attribute |
351 | from copy import deepcopy |
352 | |
353 | from charmhelpers.contrib.openstack import context, templating |
354 | +from charmhelpers.contrib.openstack.utils import ( |
355 | + git_install_requested, |
356 | + git_clone_and_install, |
357 | + git_src_dir, |
358 | +) |
359 | from collections import OrderedDict |
360 | from charmhelpers.contrib.openstack.utils import ( |
361 | os_release, |
362 | @@ -23,10 +31,36 @@ |
363 | DataPortContext, |
364 | ) |
365 | from charmhelpers.core.host import ( |
366 | + adduser, |
367 | + add_group, |
368 | + add_user_to_group, |
369 | + mkdir, |
370 | service_restart, |
371 | service_running, |
372 | + write_file, |
373 | ) |
374 | |
375 | +from charmhelpers.core.templating import render |
376 | + |
377 | +BASE_GIT_PACKAGES = [ |
378 | + 'libxml2-dev', |
379 | + 'libxslt1-dev', |
380 | + 'openvswitch-switch', |
381 | + 'python-dev', |
382 | + 'python-pip', |
383 | + 'python-setuptools', |
384 | + 'zlib1g-dev', |
385 | +] |
386 | + |
387 | +# ubuntu packages that should not be installed when deploying from git |
388 | +GIT_PACKAGE_BLACKLIST = [ |
389 | + 'neutron-l3-agent', |
390 | + 'neutron-metadata-agent', |
391 | + 'neutron-server', |
392 | + 'neutron-plugin-openvswitch', |
393 | + 'neutron-plugin-openvswitch-agent', |
394 | +] |
395 | + |
396 | NOVA_CONF_DIR = "/etc/nova" |
397 | NEUTRON_CONF_DIR = "/etc/neutron" |
398 | NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR |
399 | @@ -83,14 +117,23 @@ |
400 | |
401 | |
402 | def determine_dvr_packages(): |
403 | - if use_dvr(): |
404 | - return DVR_PACKAGES |
405 | + if not git_install_requested(): |
406 | + if use_dvr(): |
407 | + return DVR_PACKAGES |
408 | return [] |
409 | |
410 | |
411 | def determine_packages(): |
412 | pkgs = neutron_plugin_attribute('ovs', 'packages', 'neutron') |
413 | pkgs.extend(determine_dvr_packages()) |
414 | + |
415 | + if git_install_requested(): |
416 | + pkgs.extend(BASE_GIT_PACKAGES) |
417 | + # don't include packages that will be installed from git |
418 | + for p in GIT_PACKAGE_BLACKLIST: |
419 | + if p in pkgs: |
420 | + pkgs.remove(p) |
421 | + |
422 | return pkgs |
423 | |
424 | |
425 | @@ -169,3 +212,81 @@ |
426 | |
427 | def use_dvr(): |
428 | return context.NeutronAPIContext()()['enable_dvr'] |
429 | + |
430 | + |
431 | +def git_install(projects_yaml): |
432 | + """Perform setup, and install git repos specified in yaml parameter.""" |
433 | + if git_install_requested(): |
434 | + git_pre_install() |
435 | + git_clone_and_install(projects_yaml, core_project='neutron') |
436 | + git_post_install(projects_yaml) |
437 | + |
438 | + |
439 | +def git_pre_install(): |
440 | + """Perform pre-install setup.""" |
441 | + dirs = [ |
442 | + '/var/lib/neutron', |
443 | + '/var/lib/neutron/lock', |
444 | + '/var/log/neutron', |
445 | + ] |
446 | + |
447 | + logs = [ |
448 | + '/var/log/neutron/server.log', |
449 | + ] |
450 | + |
451 | + adduser('neutron', shell='/bin/bash', system_user=True) |
452 | + add_group('neutron', system_group=True) |
453 | + add_user_to_group('neutron', 'neutron') |
454 | + |
455 | + for d in dirs: |
456 | + mkdir(d, owner='neutron', group='neutron', perms=0700, force=False) |
457 | + |
458 | + for l in logs: |
459 | + write_file(l, '', owner='neutron', group='neutron', perms=0600) |
460 | + |
461 | + |
462 | +def git_post_install(projects_yaml): |
463 | + """Perform post-install setup.""" |
464 | + src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc') |
465 | + configs = [ |
466 | + {'src': src_etc, |
467 | + 'dest': '/etc/neutron'}, |
468 | + {'src': os.path.join(src_etc, 'neutron/plugins'), |
469 | + 'dest': '/etc/neutron/plugins'}, |
470 | + {'src': os.path.join(src_etc, 'neutron/rootwrap.d'), |
471 | + 'dest': '/etc/neutron/rootwrap.d'}, |
472 | + ] |
473 | + |
474 | + for c in configs: |
475 | + if os.path.exists(c['dest']): |
476 | + shutil.rmtree(c['dest']) |
477 | + shutil.copytree(c['src'], c['dest']) |
478 | + |
479 | + render('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {}, |
480 | + perms=0o440) |
481 | + |
482 | + neutron_ovs_agent_context = { |
483 | + 'service_description': 'Neutron OpenvSwitch Plugin Agent', |
484 | + 'charm_name': 'neutron-openvswitch', |
485 | + 'process_name': 'neutron-openvswitch-agent', |
486 | + 'cleanup_process_name': 'neutron-ovs-cleanup', |
487 | + 'plugin_config': '/etc/neutron/plugins/ml2/ml2_conf.ini', |
488 | + 'log_file': '/var/log/neutron/openvswitch-agent.log', |
489 | + } |
490 | + |
491 | + neutron_ovs_cleanup_context = { |
492 | + 'service_description': 'Neutron OpenvSwitch Cleanup', |
493 | + 'charm_name': 'neutron-openvswitch', |
494 | + 'process_name': 'neutron-ovs-cleanup', |
495 | + 'log_file': '/var/log/neutron/ovs-cleanup.log', |
496 | + } |
497 | + |
498 | + # NOTE(coreycb): Needs systemd support |
499 | + render('git/upstart/neutron-plugin-openvswitch-agent.upstart', |
500 | + '/etc/init/neutron-plugin-openvswitch-agent.conf', |
501 | + neutron_ovs_agent_context, perms=0o644) |
502 | + render('git/upstart/neutron-ovs-cleanup.upstart', |
503 | + '/etc/init/neutron-ovs-cleanup.conf', |
504 | + neutron_ovs_cleanup_context, perms=0o644) |
505 | + |
506 | + service_restart('neutron-plugin-openvswitch-agent') |
507 | |
508 | === added directory 'templates/git' |
509 | === added file 'templates/git/neutron_sudoers' |
510 | --- templates/git/neutron_sudoers 1970-01-01 00:00:00 +0000 |
511 | +++ templates/git/neutron_sudoers 2015-04-16 14:43:44 +0000 |
512 | @@ -0,0 +1,4 @@ |
513 | +Defaults:neutron !requiretty |
514 | + |
515 | +neutron ALL = (root) NOPASSWD: /usr/local/bin/neutron-rootwrap /etc/neutron/rootwrap.conf * |
516 | + |
517 | |
518 | === added directory 'templates/git/upstart' |
519 | === added file 'templates/git/upstart/neutron-ovs-cleanup.upstart' |
520 | --- templates/git/upstart/neutron-ovs-cleanup.upstart 1970-01-01 00:00:00 +0000 |
521 | +++ templates/git/upstart/neutron-ovs-cleanup.upstart 2015-04-16 14:43:44 +0000 |
522 | @@ -0,0 +1,17 @@ |
523 | +description "{{ service_description }}" |
524 | +author "Juju {{ charm_name }} Charm <juju@localhost>" |
525 | + |
526 | +start on started openvswitch-switch |
527 | +stop on runlevel [!2345] |
528 | + |
529 | +pre-start script |
530 | + mkdir -p /var/run/neutron |
531 | + chown neutron:root /var/run/neutron |
532 | +end script |
533 | + |
534 | +pre-start script |
535 | + [ ! -x /usr/bin/{{ process_name }} ] && exit 0 |
536 | + start-stop-daemon --start --chuid neutron --exec /usr/local/bin/{{ process_name }} -- \ |
537 | + --log-file /var/log/neutron/{{ log_file }} \ |
538 | + --config-file /etc/neutron/neutron.conf --verbose |
539 | +end script |
540 | |
541 | === added file 'templates/git/upstart/neutron-plugin-openvswitch-agent.upstart' |
542 | --- templates/git/upstart/neutron-plugin-openvswitch-agent.upstart 1970-01-01 00:00:00 +0000 |
543 | +++ templates/git/upstart/neutron-plugin-openvswitch-agent.upstart 2015-04-16 14:43:44 +0000 |
544 | @@ -0,0 +1,18 @@ |
545 | +description "{{ service_description }}" |
546 | +author "Juju {{ charm_name }} Charm <juju@localhost>" |
547 | + |
548 | +start on runlevel [2345] and started {{ cleanup_process_name}} |
549 | +stop on runlevel [!2345] |
550 | + |
551 | +respawn |
552 | + |
553 | +chdir /var/run |
554 | + |
555 | +pre-start script |
556 | + mkdir -p /var/run/neutron |
557 | + chown neutron:root /var/run/neutron |
558 | +end script |
559 | + |
560 | +exec start-stop-daemon --start --chuid neutron --exec /usr/local/bin/{{ process_name }} -- \ |
561 | + --config-file=/etc/neutron/neutron.conf --config-file={{ plugin_config }} \ |
562 | + --log-file={{ log_file }} |
563 | |
564 | === added file 'tests/16-basic-trusty-icehouse-git' |
565 | --- tests/16-basic-trusty-icehouse-git 1970-01-01 00:00:00 +0000 |
566 | +++ tests/16-basic-trusty-icehouse-git 2015-04-16 14:43:44 +0000 |
567 | @@ -0,0 +1,9 @@ |
568 | +#!/usr/bin/python |
569 | + |
570 | +"""Amulet tests on a basic neutron-openvswitch git deployment on trusty-icehouse.""" |
571 | + |
572 | +from basic_deployment import NeutronOVSBasicDeployment |
573 | + |
574 | +if __name__ == '__main__': |
575 | + deployment = NeutronOVSBasicDeployment(series='trusty', git=True) |
576 | + deployment.run_tests() |
577 | |
578 | === removed file 'tests/16-basic-trusty-juno' |
579 | --- tests/16-basic-trusty-juno 2015-02-13 12:02:13 +0000 |
580 | +++ tests/16-basic-trusty-juno 1970-01-01 00:00:00 +0000 |
581 | @@ -1,11 +0,0 @@ |
582 | -#!/usr/bin/python |
583 | - |
584 | -"""Amulet tests on a basic neutron-openvswitch deployment on trusty-juno.""" |
585 | - |
586 | -from basic_deployment import NeutronOVSBasicDeployment |
587 | - |
588 | -if __name__ == '__main__': |
589 | - deployment = NeutronOVSBasicDeployment(series='trusty', |
590 | - openstack='cloud:trusty-juno', |
591 | - source='cloud:trusty-updates/juno') |
592 | - deployment.run_tests() |
593 | |
594 | === added file 'tests/17-basic-trusty-juno' |
595 | --- tests/17-basic-trusty-juno 1970-01-01 00:00:00 +0000 |
596 | +++ tests/17-basic-trusty-juno 2015-04-16 14:43:44 +0000 |
597 | @@ -0,0 +1,11 @@ |
598 | +#!/usr/bin/python |
599 | + |
600 | +"""Amulet tests on a basic neutron-openvswitch deployment on trusty-juno.""" |
601 | + |
602 | +from basic_deployment import NeutronOVSBasicDeployment |
603 | + |
604 | +if __name__ == '__main__': |
605 | + deployment = NeutronOVSBasicDeployment(series='trusty', |
606 | + openstack='cloud:trusty-juno', |
607 | + source='cloud:trusty-updates/juno') |
608 | + deployment.run_tests() |
609 | |
610 | === added file 'tests/18-basic-trusty-juno-git' |
611 | --- tests/18-basic-trusty-juno-git 1970-01-01 00:00:00 +0000 |
612 | +++ tests/18-basic-trusty-juno-git 2015-04-16 14:43:44 +0000 |
613 | @@ -0,0 +1,12 @@ |
614 | +#!/usr/bin/python |
615 | + |
616 | +"""Amulet tests on a basic neutron-openvswitch git deployment on trusty-juno.""" |
617 | + |
618 | +from basic_deployment import NeutronOVSBasicDeployment |
619 | + |
620 | +if __name__ == '__main__': |
621 | + deployment = NeutronOVSBasicDeployment(series='trusty', |
622 | + openstack='cloud:trusty-juno', |
623 | + source='cloud:trusty-updates/juno', |
624 | + git=True) |
625 | + deployment.run_tests() |
626 | |
627 | === modified file 'tests/basic_deployment.py' |
628 | --- tests/basic_deployment.py 2015-02-19 20:52:35 +0000 |
629 | +++ tests/basic_deployment.py 2015-04-16 14:43:44 +0000 |
630 | @@ -1,7 +1,9 @@ |
631 | #!/usr/bin/python |
632 | |
633 | import amulet |
634 | +import os |
635 | import time |
636 | +import yaml |
637 | |
638 | from charmhelpers.contrib.openstack.amulet.deployment import ( |
639 | OpenStackAmuletDeployment |
640 | @@ -14,7 +16,7 @@ |
641 | ) |
642 | |
643 | # Use DEBUG to turn on debug logging |
644 | -u = OpenStackAmuletUtils(ERROR) |
645 | +u = OpenStackAmuletUtils(DEBUG) |
646 | |
647 | # XXX Tests inspecting relation data from the perspective of the |
648 | # neutron-openvswitch are missing because amulet sentries aren't created for |
649 | @@ -24,10 +26,12 @@ |
650 | class NeutronOVSBasicDeployment(OpenStackAmuletDeployment): |
651 | """Amulet tests on a basic neutron-openvswtich deployment.""" |
652 | |
653 | - def __init__(self, series, openstack=None, source=None, stable=False): |
654 | + def __init__(self, series, openstack=None, source=None, git=False, |
655 | + stable=False): |
656 | """Deploy the entire test environment.""" |
657 | super(NeutronOVSBasicDeployment, self).__init__(series, openstack, |
658 | source, stable) |
659 | + self.git = git |
660 | self._add_services() |
661 | self._add_relations() |
662 | self._configure_services() |
663 | @@ -61,7 +65,25 @@ |
664 | |
665 | def _configure_services(self): |
666 | """Configure all of the services.""" |
667 | - configs = {} |
668 | + neutron_ovs_config = {} |
669 | + if self.git: |
670 | + branch = 'stable/' + self._get_openstack_release_string() |
671 | + amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY') |
672 | + openstack_origin_git = { |
673 | + 'repositories': [ |
674 | + {'name': 'requirements', |
675 | + 'repository': 'git://git.openstack.org/openstack/requirements', |
676 | + 'branch': branch}, |
677 | + {'name': 'neutron', |
678 | + 'repository': 'git://git.openstack.org/openstack/neutron', |
679 | + 'branch': branch}, |
680 | + ], |
681 | + 'directory': '/mnt/openstack-git', |
682 | + 'http_proxy': amulet_http_proxy, |
683 | + 'https_proxy': amulet_http_proxy, |
684 | + } |
685 | + neutron_ovs_config['openstack-origin-git'] = yaml.dump(openstack_origin_git) |
686 | + configs = {'neutron-openvswitch': neutron_ovs_config} |
687 | super(NeutronOVSBasicDeployment, self)._configure_services(configs) |
688 | |
689 | def _initialize_tests(self): |
690 | @@ -76,7 +98,8 @@ |
691 | service units.""" |
692 | |
693 | commands = { |
694 | - self.compute_sentry: ['status nova-compute'], |
695 | + self.compute_sentry: ['status nova-compute', |
696 | + 'status neutron-plugin-openvswitch-agent'], |
697 | self.rabbitmq_sentry: ['service rabbitmq-server status'], |
698 | self.neutron_api_sentry: ['status neutron-server'], |
699 | } |
700 | @@ -138,7 +161,7 @@ |
701 | conf = "/etc/neutron/plugins/ml2/ml2_conf.ini" |
702 | for value in vpair: |
703 | self.d.configure(service, {charm_key: value}) |
704 | - time.sleep(30) |
705 | + time.sleep(60) |
706 | ret = u.validate_config_data(unit, conf, section, |
707 | {config_file_key: value}) |
708 | msg = "Propagation error, expected %s=%s" % (config_file_key, |
709 | |
710 | === modified file 'unit_tests/__init__.py' |
711 | --- unit_tests/__init__.py 2014-06-19 09:56:25 +0000 |
712 | +++ unit_tests/__init__.py 2015-04-16 14:43:44 +0000 |
713 | @@ -1,2 +1,4 @@ |
714 | import sys |
715 | + |
716 | +sys.path.append('actions/') |
717 | sys.path.append('hooks/') |
718 | |
719 | === added file 'unit_tests/test_actions_git_reinstall.py' |
720 | --- unit_tests/test_actions_git_reinstall.py 1970-01-01 00:00:00 +0000 |
721 | +++ unit_tests/test_actions_git_reinstall.py 2015-04-16 14:43:44 +0000 |
722 | @@ -0,0 +1,105 @@ |
723 | +from mock import patch, MagicMock |
724 | + |
725 | +with patch('charmhelpers.core.hookenv.config') as config: |
726 | + config.return_value = 'neutron' |
727 | + import neutron_ovs_utils as utils # noqa |
728 | + |
729 | +# Need to do some early patching to get the module loaded. |
730 | +_reg = utils.register_configs |
731 | +_map = utils.restart_map |
732 | + |
733 | +utils.register_configs = MagicMock() |
734 | +utils.restart_map = MagicMock() |
735 | + |
736 | +import git_reinstall |
737 | + |
738 | +# Unpatch it now that its loaded. |
739 | +utils.register_configs = _reg |
740 | +utils.restart_map = _map |
741 | + |
742 | +from test_utils import ( |
743 | + CharmTestCase |
744 | +) |
745 | + |
746 | +TO_PATCH = [ |
747 | + 'config', |
748 | +] |
749 | + |
750 | + |
751 | +openstack_origin_git = \ |
752 | + """repositories: |
753 | + - {name: requirements, |
754 | + repository: 'git://git.openstack.org/openstack/requirements', |
755 | + branch: stable/juno} |
756 | + - {name: neutron, |
757 | + repository: 'git://git.openstack.org/openstack/neutron', |
758 | + branch: stable/juno}""" |
759 | + |
760 | + |
761 | +class TestNeutronOVSActions(CharmTestCase): |
762 | + |
763 | + def setUp(self): |
764 | + super(TestNeutronOVSActions, self).setUp(git_reinstall, TO_PATCH) |
765 | + self.config.side_effect = self.test_config.get |
766 | + |
767 | + @patch.object(git_reinstall, 'action_set') |
768 | + @patch.object(git_reinstall, 'action_fail') |
769 | + @patch.object(git_reinstall, 'git_install') |
770 | + @patch.object(git_reinstall, 'config_changed') |
771 | + def test_git_reinstall(self, config_changed, git_install, action_fail, |
772 | + action_set): |
773 | + self.test_config.set('openstack-origin-git', openstack_origin_git) |
774 | + |
775 | + git_reinstall.git_reinstall() |
776 | + |
777 | + git_install.assert_called_with(openstack_origin_git) |
778 | + self.assertTrue(git_install.called) |
779 | + self.assertTrue(config_changed.called) |
780 | + self.assertFalse(action_set.called) |
781 | + self.assertFalse(action_fail.called) |
782 | + |
783 | + @patch.object(git_reinstall, 'action_set') |
784 | + @patch.object(git_reinstall, 'action_fail') |
785 | + @patch.object(git_reinstall, 'git_install') |
786 | + @patch.object(git_reinstall, 'config_changed') |
787 | + @patch('charmhelpers.contrib.openstack.utils.config') |
788 | + def test_git_reinstall_not_configured(self, _config, config_changed, |
789 | + git_install, action_fail, |
790 | + action_set): |
791 | + _config.return_value = None |
792 | + |
793 | + git_reinstall.git_reinstall() |
794 | + |
795 | + msg = 'openstack-origin-git is not configured' |
796 | + action_fail.assert_called_with(msg) |
797 | + self.assertFalse(git_install.called) |
798 | + self.assertFalse(action_set.called) |
799 | + |
800 | + @patch.object(git_reinstall, 'action_set') |
801 | + @patch.object(git_reinstall, 'action_fail') |
802 | + @patch.object(git_reinstall, 'git_install') |
803 | + @patch.object(git_reinstall, 'config_changed') |
804 | + @patch('traceback.format_exc') |
805 | + @patch('charmhelpers.contrib.openstack.utils.config') |
806 | + def test_git_reinstall_exception(self, _config, format_exc, |
807 | + config_changed, git_install, action_fail, |
808 | + action_set): |
809 | + _config.return_value = openstack_origin_git |
810 | + e = OSError('something bad happened') |
811 | + git_install.side_effect = e |
812 | + traceback = ( |
813 | + "Traceback (most recent call last):\n" |
814 | + " File \"actions/git_reinstall.py\", line 37, in git_reinstall\n" |
815 | + " git_install(config(\'openstack-origin-git\'))\n" |
816 | + " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 964, in __call__\n" # noqa |
817 | + " return _mock_self._mock_call(*args, **kwargs)\n" |
818 | + " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 1019, in _mock_call\n" # noqa |
819 | + " raise effect\n" |
820 | + "OSError: something bad happened\n") |
821 | + format_exc.return_value = traceback |
822 | + |
823 | + git_reinstall.git_reinstall() |
824 | + |
825 | + msg = 'git-reinstall resulted in an unexpected error' |
826 | + action_fail.assert_called_with(msg) |
827 | + action_set.assert_called_with({'traceback': traceback}) |
828 | |
829 | === modified file 'unit_tests/test_neutron_ovs_context.py' |
830 | --- unit_tests/test_neutron_ovs_context.py 2015-04-10 16:21:20 +0000 |
831 | +++ unit_tests/test_neutron_ovs_context.py 2015-04-16 14:43:44 +0000 |
832 | @@ -101,7 +101,7 @@ |
833 | return config |
834 | |
835 | self.maxDiff = None |
836 | - self.config.side_effect = mock_config |
837 | + self.config.side_effect = mock_config |
838 | _npa.side_effect = mock_npa |
839 | _unit_get.return_value = '127.0.0.13' |
840 | _unit_priv_ip.return_value = '127.0.0.14' |
841 | |
842 | === modified file 'unit_tests/test_neutron_ovs_hooks.py' |
843 | --- unit_tests/test_neutron_ovs_hooks.py 2015-04-01 14:19:17 +0000 |
844 | +++ unit_tests/test_neutron_ovs_hooks.py 2015-04-16 14:43:44 +0000 |
845 | @@ -1,5 +1,6 @@ |
846 | - |
847 | from mock import MagicMock, patch, call |
848 | +import yaml |
849 | + |
850 | from test_utils import CharmTestCase |
851 | |
852 | with patch('charmhelpers.core.hookenv.config') as config: |
853 | @@ -26,6 +27,7 @@ |
854 | 'determine_packages', |
855 | 'determine_dvr_packages', |
856 | 'get_shared_secret', |
857 | + 'git_install', |
858 | 'log', |
859 | 'relation_ids', |
860 | 'relation_set', |
861 | @@ -49,7 +51,9 @@ |
862 | hooks.hooks.execute([ |
863 | 'hooks/{}'.format(hookname)]) |
864 | |
865 | - def test_install_hook(self): |
866 | + @patch.object(hooks, 'git_install_requested') |
867 | + def test_install_hook(self, git_requested): |
868 | + git_requested.return_value = False |
869 | _pkgs = ['foo', 'bar'] |
870 | self.determine_packages.return_value = [_pkgs] |
871 | self._call_hook('install') |
872 | @@ -58,15 +62,68 @@ |
873 | call(_pkgs, fatal=True), |
874 | ]) |
875 | |
876 | - def test_config_changed(self): |
877 | - self.relation_ids.return_value = ['relid'] |
878 | - _zmq_joined = self.patch('zeromq_configuration_relation_joined') |
879 | - self._call_hook('config-changed') |
880 | - self.assertTrue(self.CONFIGS.write_all.called) |
881 | - self.assertTrue(_zmq_joined.called_with('relid')) |
882 | - self.configure_ovs.assert_called_with() |
883 | - |
884 | - def test_config_changed_dvr(self): |
885 | + @patch.object(hooks, 'git_install_requested') |
886 | + def test_install_hook_git(self, git_requested): |
887 | + git_requested.return_value = True |
888 | + _pkgs = ['foo', 'bar'] |
889 | + self.determine_packages.return_value = _pkgs |
890 | + openstack_origin_git = { |
891 | + 'repositories': [ |
892 | + {'name': 'requirements', |
893 | + 'repository': 'git://git.openstack.org/openstack/requirements', # noqa |
894 | + 'branch': 'stable/juno'}, |
895 | + {'name': 'neutron', |
896 | + 'repository': 'git://git.openstack.org/openstack/neutron', |
897 | + 'branch': 'stable/juno'} |
898 | + ], |
899 | + 'directory': '/mnt/openstack-git', |
900 | + } |
901 | + projects_yaml = yaml.dump(openstack_origin_git) |
902 | + self.test_config.set('openstack-origin-git', projects_yaml) |
903 | + self._call_hook('install') |
904 | + self.apt_update.assert_called_with() |
905 | + self.assertTrue(self.determine_packages) |
906 | + self.git_install.assert_called_with(projects_yaml) |
907 | + |
908 | + @patch.object(hooks, 'git_install_requested') |
909 | + def test_config_changed(self, git_requested): |
910 | + git_requested.return_value = False |
911 | + self.relation_ids.return_value = ['relid'] |
912 | + _zmq_joined = self.patch('zeromq_configuration_relation_joined') |
913 | + self._call_hook('config-changed') |
914 | + self.assertTrue(self.CONFIGS.write_all.called) |
915 | + self.assertTrue(_zmq_joined.called_with('relid')) |
916 | + self.configure_ovs.assert_called_with() |
917 | + |
918 | + @patch.object(hooks, 'git_install_requested') |
919 | + @patch.object(hooks, 'config_value_changed') |
920 | + def test_config_changed_git(self, config_val_changed, git_requested): |
921 | + git_requested.return_value = True |
922 | + self.relation_ids.return_value = ['relid'] |
923 | + _zmq_joined = self.patch('zeromq_configuration_relation_joined') |
924 | + openstack_origin_git = { |
925 | + 'repositories': [ |
926 | + {'name': 'requirements', |
927 | + 'repository': |
928 | + 'git://git.openstack.org/openstack/requirements', |
929 | + 'branch': 'stable/juno'}, |
930 | + {'name': 'neutron', |
931 | + 'repository': 'git://git.openstack.org/openstack/neutron', |
932 | + 'branch': 'stable/juno'} |
933 | + ], |
934 | + 'directory': '/mnt/openstack-git', |
935 | + } |
936 | + projects_yaml = yaml.dump(openstack_origin_git) |
937 | + self.test_config.set('openstack-origin-git', projects_yaml) |
938 | + self._call_hook('config-changed') |
939 | + self.git_install.assert_called_with(projects_yaml) |
940 | + self.assertTrue(self.CONFIGS.write_all.called) |
941 | + self.assertTrue(_zmq_joined.called_with('relid')) |
942 | + self.configure_ovs.assert_called_with() |
943 | + |
944 | + @patch.object(hooks, 'git_install_requested') |
945 | + def test_config_changed_dvr(self, git_requested): |
946 | + git_requested.return_value = False |
947 | self.determine_dvr_packages.return_value = ['dvr'] |
948 | self._call_hook('config-changed') |
949 | self.apt_update.assert_called_with() |
950 | @@ -84,7 +141,9 @@ |
951 | self.assertTrue(self.CONFIGS.write_all.called) |
952 | _plugin_joined.assert_called_with(relation_id='rid') |
953 | |
954 | - def test_neutron_plugin_joined(self): |
955 | + @patch.object(hooks, 'git_install_requested') |
956 | + def test_neutron_plugin_joined(self, git_requested): |
957 | + git_requested.return_value = False |
958 | self.get_shared_secret.return_value = 'secret' |
959 | self._call_hook('neutron-plugin-relation-joined') |
960 | rel_data = { |
961 | |
962 | === modified file 'unit_tests/test_neutron_ovs_utils.py' |
963 | --- unit_tests/test_neutron_ovs_utils.py 2015-04-01 08:57:10 +0000 |
964 | +++ unit_tests/test_neutron_ovs_utils.py 2015-04-16 14:43:44 +0000 |
965 | @@ -29,6 +29,15 @@ |
966 | |
967 | head_pkg = 'linux-headers-3.15.0-5-generic' |
968 | |
969 | +openstack_origin_git = \ |
970 | + """repositories: |
971 | + - {name: requirements, |
972 | + repository: 'git://git.openstack.org/openstack/requirements', |
973 | + branch: stable/juno} |
974 | + - {name: neutron, |
975 | + repository: 'git://git.openstack.org/openstack/neutron', |
976 | + branch: stable/juno}""" |
977 | + |
978 | |
979 | def _mock_npa(plugin, attr, net_manager=None): |
980 | plugins = { |
981 | @@ -67,9 +76,12 @@ |
982 | hookenv.cache = {} |
983 | |
984 | @patch.object(nutils, 'use_dvr') |
985 | + @patch.object(nutils, 'git_install_requested') |
986 | @patch.object(charmhelpers.contrib.openstack.neutron, 'os_release') |
987 | @patch.object(charmhelpers.contrib.openstack.neutron, 'headers_package') |
988 | - def test_determine_packages(self, _head_pkgs, _os_rel, _use_dvr): |
989 | + def test_determine_packages(self, _head_pkgs, _os_rel, _git_requested, |
990 | + _use_dvr): |
991 | + _git_requested.return_value = False |
992 | _use_dvr.return_value = False |
993 | _os_rel.return_value = 'trusty' |
994 | _head_pkgs.return_value = head_pkg |
995 | @@ -206,3 +218,92 @@ |
996 | _dvr_secret_ctxt.return_value = \ |
997 | DummyContext(return_value={'shared_secret': 'supersecret'}) |
998 | self.assertEqual(nutils.get_shared_secret(), 'supersecret') |
999 | + |
1000 | + @patch.object(nutils, 'git_install_requested') |
1001 | + @patch.object(nutils, 'git_clone_and_install') |
1002 | + @patch.object(nutils, 'git_post_install') |
1003 | + @patch.object(nutils, 'git_pre_install') |
1004 | + def test_git_install(self, git_pre, git_post, git_clone_and_install, |
1005 | + git_requested): |
1006 | + projects_yaml = openstack_origin_git |
1007 | + git_requested.return_value = True |
1008 | + nutils.git_install(projects_yaml) |
1009 | + self.assertTrue(git_pre.called) |
1010 | + git_clone_and_install.assert_called_with(openstack_origin_git, |
1011 | + core_project='neutron') |
1012 | + self.assertTrue(git_post.called) |
1013 | + |
1014 | + @patch.object(nutils, 'mkdir') |
1015 | + @patch.object(nutils, 'write_file') |
1016 | + @patch.object(nutils, 'add_user_to_group') |
1017 | + @patch.object(nutils, 'add_group') |
1018 | + @patch.object(nutils, 'adduser') |
1019 | + def test_git_pre_install(self, adduser, add_group, add_user_to_group, |
1020 | + write_file, mkdir): |
1021 | + nutils.git_pre_install() |
1022 | + adduser.assert_called_with('neutron', shell='/bin/bash', |
1023 | + system_user=True) |
1024 | + add_group.assert_called_with('neutron', system_group=True) |
1025 | + add_user_to_group.assert_called_with('neutron', 'neutron') |
1026 | + expected = [ |
1027 | + call('/var/lib/neutron', owner='neutron', |
1028 | + group='neutron', perms=0700, force=False), |
1029 | + call('/var/lib/neutron/lock', owner='neutron', |
1030 | + group='neutron', perms=0700, force=False), |
1031 | + call('/var/log/neutron', owner='neutron', |
1032 | + group='neutron', perms=0700, force=False), |
1033 | + ] |
1034 | + self.assertEquals(mkdir.call_args_list, expected) |
1035 | + expected = [ |
1036 | + call('/var/log/neutron/server.log', '', owner='neutron', |
1037 | + group='neutron', perms=0600), |
1038 | + ] |
1039 | + self.assertEquals(write_file.call_args_list, expected) |
1040 | + |
1041 | + @patch.object(nutils, 'git_src_dir') |
1042 | + @patch.object(nutils, 'service_restart') |
1043 | + @patch.object(nutils, 'render') |
1044 | + @patch('os.path.join') |
1045 | + @patch('os.path.exists') |
1046 | + @patch('shutil.copytree') |
1047 | + @patch('shutil.rmtree') |
1048 | + def test_git_post_install(self, rmtree, copytree, exists, join, render, |
1049 | + service_restart, git_src_dir): |
1050 | + projects_yaml = openstack_origin_git |
1051 | + join.return_value = 'joined-string' |
1052 | + nutils.git_post_install(projects_yaml) |
1053 | + expected = [ |
1054 | + call('joined-string', '/etc/neutron'), |
1055 | + call('joined-string', '/etc/neutron/plugins'), |
1056 | + call('joined-string', '/etc/neutron/rootwrap.d'), |
1057 | + ] |
1058 | + copytree.assert_has_calls(expected) |
1059 | + neutron_ovs_agent_context = { |
1060 | + 'service_description': 'Neutron OpenvSwitch Plugin Agent', |
1061 | + 'charm_name': 'neutron-openvswitch', |
1062 | + 'process_name': 'neutron-openvswitch-agent', |
1063 | + 'cleanup_process_name': 'neutron-ovs-cleanup', |
1064 | + 'plugin_config': '/etc/neutron/plugins/ml2/ml2_conf.ini', |
1065 | + 'log_file': '/var/log/neutron/openvswitch-agent.log', |
1066 | + } |
1067 | + neutron_ovs_cleanup_context = { |
1068 | + 'service_description': 'Neutron OpenvSwitch Cleanup', |
1069 | + 'charm_name': 'neutron-openvswitch', |
1070 | + 'process_name': 'neutron-ovs-cleanup', |
1071 | + 'log_file': '/var/log/neutron/ovs-cleanup.log', |
1072 | + } |
1073 | + expected = [ |
1074 | + call('git/neutron_sudoers', '/etc/sudoers.d/neutron_sudoers', {}, |
1075 | + perms=0o440), |
1076 | + call('git/upstart/neutron-plugin-openvswitch-agent.upstart', |
1077 | + '/etc/init/neutron-plugin-openvswitch-agent.conf', |
1078 | + neutron_ovs_agent_context, perms=0o644), |
1079 | + call('git/upstart/neutron-ovs-cleanup.upstart', |
1080 | + '/etc/init/neutron-ovs-cleanup.conf', |
1081 | + neutron_ovs_cleanup_context, perms=0o644), |
1082 | + ] |
1083 | + self.assertEquals(render.call_args_list, expected) |
1084 | + expected = [ |
1085 | + call('neutron-plugin-openvswitch-agent'), |
1086 | + ] |
1087 | + self.assertEquals(service_restart.call_args_list, expected) |
charm_lint_check #3078 neutron- openvswitch- next for corey.bryant mp255122
LINT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_lint_ check/3078/