Merge lp:~corey.bryant/charms/trusty/quantum-gateway/git into lp:~openstack-charmers/charms/trusty/quantum-gateway/next

Proposed by Corey Bryant
Status: Merged
Merged at revision: 100
Proposed branch: lp:~corey.bryant/charms/trusty/quantum-gateway/git
Merge into: lp:~openstack-charmers/charms/trusty/quantum-gateway/next
Diff against target: 1787 lines (+1333/-58) (has conflicts)
26 files modified
.bzrignore (+1/-0)
Makefile (+4/-2)
README.md (+88/-0)
actions.yaml (+2/-0)
actions/git_reinstall.py (+45/-0)
config.yaml (+16/-0)
hooks/charmhelpers/contrib/openstack/utils.py (+18/-6)
hooks/quantum_hooks.py (+18/-6)
hooks/quantum_utils.py (+398/-7)
templates/git/cron.d/neutron-dhcp-agent-netns-cleanup (+4/-0)
templates/git/cron.d/neutron-l3-agent-netns-cleanup (+4/-0)
templates/git/cron.d/neutron-lbaas-agent-netns-cleanup (+4/-0)
templates/git/neutron_sudoers (+4/-0)
templates/git/upstart/neutron-agent.upstart (+25/-0)
templates/git/upstart/neutron-ovs-cleanup.upstart (+13/-0)
templates/git/upstart/neutron-server.upstart (+22/-0)
tests/12-basic-precise-grizzly (+0/-11)
tests/13-basic-precise-havana (+0/-11)
tests/16-basic-trusty-icehouse-git (+9/-0)
tests/17-basic-trusty-juno (+11/-0)
tests/18-basic-trusty-juno-git (+12/-0)
tests/basic_deployment.py (+27/-4)
unit_tests/__init__.py (+2/-0)
unit_tests/test_actions_git_reinstall.py (+105/-0)
unit_tests/test_quantum_hooks.py (+91/-4)
unit_tests/test_quantum_utils.py (+410/-7)
Text conflict in hooks/charmhelpers/contrib/openstack/utils.py
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/quantum-gateway/git
Reviewer Review Type Date Requested Status
James Page Needs Fixing
Review via email: mp+255573@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #2979 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/2979/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3191 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3191/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3001 quantum-gateway-next for corey.bryant mp255573
    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://paste.ubuntu.com/10783595/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3001/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3209 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3209/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #2997 quantum-gateway-next for corey.bryant mp255573
    UNIT FAIL: unit-test failed

UNIT Results (max last 2 lines):
make: *** [unit_test] Error 1
ERROR:root:Make target returned non-zero.

Full unit test output: http://paste.ubuntu.com/10791391/
Build: http://10.245.162.77:8080/job/charm_unit_test/2997/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3026 quantum-gateway-next for corey.bryant mp255573
    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://paste.ubuntu.com/10791831/
Build: http://10.245.162.77:8080/job/charm_amulet_test/3026/

96. By Corey Bryant

Deploy from source

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3212 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3212/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3000 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3000/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3029 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3029/

97. By Corey Bryant

Get http_proxy from AMULET_HTTP_PROXY env var

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3287 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3287/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3075 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3075/

Revision history for this message
James Page (james-page) :
review: Needs Fixing
98. By Corey Bryant

Move deploy from source template files to templates/git

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3104 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3104/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3294 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3294/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3082 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3082/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3111 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3111/

99. By Corey Bryant

Bulk copy files to /etc/neutron

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3307 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3307/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3095 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3095/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3309 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3309/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3097 quantum-gateway-next for corey.bryant mp255573
    UNIT FAIL: unit-test failed

UNIT Results (max last 2 lines):
make: *** [unit_test] Error 1
ERROR:root:Make target returned non-zero.

Full unit test output: http://paste.ubuntu.com/10818316/
Build: http://10.245.162.77:8080/job/charm_unit_test/3097/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3126 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3126/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3128 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3128/

100. By Corey Bryant

Defer starting of services to config-changed when deploying from source

101. By Corey Bryant

Run config-changed hook after git-reinstall action installs from source

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3318 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3318/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3106 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3106/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3139 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3139/

102. By Corey Bryant

Fixup test_git_reinstall_exception()

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3398 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3398/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3186 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3186/

103. By Corey Bryant

Merge next branch

104. By Corey Bryant

Sync charm-helpers

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3405 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3405/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3193 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3193/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3188 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3188/

105. By Corey Bryant

Move config_changed into try block

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3414 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3414/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3202 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3202/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3198 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3198/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3207 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3207/

106. By Corey Bryant

Sync charm-helpers

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #3455 quantum-gateway-next for corey.bryant mp255573
    LINT OK: passed

Build: http://10.245.162.77:8080/job/charm_lint_check/3455/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #3243 quantum-gateway-next for corey.bryant mp255573
    UNIT OK: passed

Build: http://10.245.162.77:8080/job/charm_unit_test/3243/

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #3253 quantum-gateway-next for corey.bryant mp255573
    AMULET OK: passed

Build: http://10.245.162.77:8080/job/charm_amulet_test/3253/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2014-07-02 08:25:12 +0000
3+++ .bzrignore 2015-04-16 14:48:42 +0000
4@@ -1,2 +1,3 @@
5 bin
6 .coverage
7+tags
8
9=== modified file 'Makefile'
10--- Makefile 2014-10-07 21:19:29 +0000
11+++ Makefile 2015-04-16 14:48:42 +0000
12@@ -2,7 +2,7 @@
13 PYTHON := /usr/bin/env python
14
15 lint:
16- @flake8 --exclude hooks/charmhelpers hooks unit_tests tests
17+ @flake8 --exclude hooks/charmhelpers actions hooks unit_tests tests
18 @charm proof
19
20 unit_test:
21@@ -24,7 +24,9 @@
22 # raise_status() messages to stderr:
23 # https://bugs.launchpad.net/amulet/+bug/1320357
24 @juju test -v -p AMULET_HTTP_PROXY --timeout 900 \
25- 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse
26+ 00-setup 14-basic-precise-icehouse 15-basic-trusty-icehouse \
27+ 16-basic-trusty-icehouse-git 17-basic-trusty-juno \
28+ 18-basic-trusty-juno-git
29
30 publish: lint unit_test
31 bzr push lp:charms/quantum-gateway
32
33=== modified file 'README.md'
34--- README.md 2014-03-14 13:24:39 +0000
35+++ README.md 2015-04-16 14:48:42 +0000
36@@ -109,6 +109,94 @@
37
38 Note that this option was added in Havana and will be ignored in older releases.
39
40+Deploying from source
41+=====================
42+
43+The minimum openstack-origin-git config required to deploy from source is:
44+
45+ openstack-origin-git:
46+ "repositories:
47+ - {name: requirements,
48+ repository: 'git://git.openstack.org/openstack/requirements',
49+ branch: stable/juno}
50+ - {name: neutron,
51+ repository: 'git://git.openstack.org/openstack/neutron',
52+ branch: stable/juno}"
53+
54+Note that there are only two 'name' values the charm knows about: 'requirements'
55+and 'neutron'. These repositories must correspond to these 'name' values.
56+Additionally, the requirements repository must be specified first and the
57+neutron repository must be specified last. All other repostories are installed
58+in the order in which they are specified.
59+
60+The following is a full list of current tip repos (may not be up-to-date):
61+
62+ openstack-origin-git:
63+ "repositories:
64+ - {name: requirements,
65+ repository: 'git://git.openstack.org/openstack/requirements',
66+ branch: master}
67+ - {name: oslo-concurrency,
68+ repository: 'git://git.openstack.org/openstack/oslo.concurrency',
69+ branch: master}
70+ - {name: oslo-config,
71+ repository: 'git://git.openstack.org/openstack/oslo.config',
72+ branch: master}
73+ - {name: oslo-context,
74+ repository: 'git://git.openstack.org/openstack/oslo.context.git',
75+ branch: master}
76+ - {name: oslo-db,
77+ repository: 'git://git.openstack.org/openstack/oslo.db',
78+ branch: master}
79+ - {name: oslo-i18n,
80+ repository: 'git://git.openstack.org/openstack/oslo.i18n',
81+ branch: master}
82+ - {name: oslo-messaging,
83+ repository: 'git://git.openstack.org/openstack/oslo.messaging.git',
84+ branch: master}
85+ - {name: oslo-middleware,
86+ repository': 'git://git.openstack.org/openstack/oslo.middleware.git',
87+ branch: master}
88+ - {name: oslo-rootwrap',
89+ repository: 'git://git.openstack.org/openstack/oslo.rootwrap.git',
90+ branch: master}
91+ - {name: oslo-serialization,
92+ repository: 'git://git.openstack.org/openstack/oslo.serialization',
93+ branch: master}
94+ - {name: oslo-utils,
95+ repository: 'git://git.openstack.org/openstack/oslo.utils',
96+ branch: master}
97+ - {name: pbr,
98+ repository: 'git://git.openstack.org/openstack-dev/pbr',
99+ branch: master}
100+ - {name: stevedore,
101+ repository: 'git://git.openstack.org/openstack/stevedore.git',
102+ branch: 'master'}
103+ - {name: python-keystoneclient,
104+ repository: 'git://git.openstack.org/openstack/python-keystoneclient',
105+ branch: master}
106+ - {name: python-neutronclient,
107+ repository: 'git://git.openstack.org/openstack/python-neutronclient.git',
108+ branch: master}
109+ - {name: python-novaclient,
110+ repository': 'git://git.openstack.org/openstack/python-novaclient.git',
111+ branch: master}
112+ - {name: keystonemiddleware,
113+ repository: 'git://git.openstack.org/openstack/keystonemiddleware',
114+ branch: master}
115+ - {name: neutron-fwaas,
116+ repository': 'git://git.openstack.org/openstack/neutron-fwaas.git',
117+ branch: master}
118+ - {name: neutron-lbaas,
119+ repository: 'git://git.openstack.org/openstack/neutron-lbaas.git',
120+ branch: master}
121+ - {name: neutron-vpnaas,
122+ repository: 'git://git.openstack.org/openstack/neutron-vpnaas.git',
123+ branch: master}
124+ - {name: neutron,
125+ repository: 'git://git.openstack.org/openstack/neutron',
126+ branch: master}"
127+
128 TODO
129 ----
130
131
132=== added directory 'actions'
133=== added file 'actions.yaml'
134--- actions.yaml 1970-01-01 00:00:00 +0000
135+++ actions.yaml 2015-04-16 14:48:42 +0000
136@@ -0,0 +1,2 @@
137+git-reinstall:
138+ description: Reinstall quantum-gateway from the openstack-origin-git repositories.
139
140=== added symlink 'actions/git-reinstall'
141=== target is u'git_reinstall.py'
142=== added file 'actions/git_reinstall.py'
143--- actions/git_reinstall.py 1970-01-01 00:00:00 +0000
144+++ actions/git_reinstall.py 2015-04-16 14:48:42 +0000
145@@ -0,0 +1,45 @@
146+#!/usr/bin/python
147+import sys
148+import traceback
149+
150+sys.path.append('hooks/')
151+
152+from charmhelpers.contrib.openstack.utils import (
153+ git_install_requested,
154+)
155+
156+from charmhelpers.core.hookenv import (
157+ action_set,
158+ action_fail,
159+ config,
160+)
161+
162+from quantum_utils import (
163+ git_install,
164+)
165+
166+from quantum_hooks import (
167+ config_changed,
168+)
169+
170+
171+def git_reinstall():
172+ """Reinstall from source and restart services.
173+
174+ If the openstack-origin-git config option was used to install openstack
175+ from source git repositories, then this action can be used to reinstall
176+ from updated git repositories, followed by a restart of services."""
177+ if not git_install_requested():
178+ action_fail('openstack-origin-git is not configured')
179+ return
180+
181+ try:
182+ git_install(config('openstack-origin-git'))
183+ config_changed()
184+ except:
185+ action_set({'traceback': traceback.format_exc()})
186+ action_fail('git-reinstall resulted in an unexpected error')
187+
188+
189+if __name__ == '__main__':
190+ git_reinstall()
191
192=== modified file 'config.yaml'
193--- config.yaml 2015-03-12 10:33:36 +0000
194+++ config.yaml 2015-04-16 14:48:42 +0000
195@@ -37,6 +37,22 @@
196 - deb http://my.archive.com/ubuntu main|KEYID
197 .
198 Note that quantum/neutron is only supported >= Folsom.
199+
200+ Note that when openstack-origin-git is specified, openstack
201+ specific packages will be installed from source rather than
202+ from the openstack-origin repository.
203+ openstack-origin-git:
204+ default:
205+ type: string
206+ description: |
207+ Specifies a YAML-formatted dictionary listing the git
208+ repositories and branches from which to install OpenStack and
209+ its dependencies.
210+
211+ Note that the installed config files will be determined based on
212+ the OpenStack release of the openstack-origin option.
213+
214+ For more details see README.md.
215 run-internal-router:
216 type: string
217 default: all
218
219=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
220--- hooks/charmhelpers/contrib/openstack/utils.py 2015-04-16 10:28:18 +0000
221+++ hooks/charmhelpers/contrib/openstack/utils.py 2015-04-16 14:48:42 +0000
222@@ -524,12 +524,22 @@
223 projects = yaml.load(projects_yaml)
224 _git_validate_projects_yaml(projects, core_project)
225
226- if 'http_proxy' in projects.keys():
227- os.environ['http_proxy'] = projects['http_proxy']
228-
229- if 'https_proxy' in projects.keys():
230- os.environ['https_proxy'] = projects['https_proxy']
231-
232+<<<<<<< TREE
233+ if 'http_proxy' in projects.keys():
234+ os.environ['http_proxy'] = projects['http_proxy']
235+
236+ if 'https_proxy' in projects.keys():
237+ os.environ['https_proxy'] = projects['https_proxy']
238+
239+=======
240+ old_environ = dict(os.environ)
241+
242+ if 'http_proxy' in projects.keys():
243+ os.environ['http_proxy'] = projects['http_proxy']
244+ if 'https_proxy' in projects.keys():
245+ os.environ['https_proxy'] = projects['https_proxy']
246+
247+>>>>>>> MERGE-SOURCE
248 if 'directory' in projects.keys():
249 parent_dir = projects['directory']
250
251@@ -544,6 +554,8 @@
252 repo_dir = _git_clone_and_install_single(repo, branch, parent_dir,
253 update_requirements=True)
254
255+ os.environ = old_environ
256+
257
258 def _git_validate_projects_yaml(projects, core_project):
259 """
260
261=== modified file 'hooks/quantum_hooks.py'
262--- hooks/quantum_hooks.py 2015-03-31 15:13:53 +0000
263+++ hooks/quantum_hooks.py 2015-04-16 14:48:42 +0000
264@@ -30,6 +30,7 @@
265 install_ca_cert
266 )
267 from charmhelpers.contrib.openstack.utils import (
268+ config_value_changed,
269 configure_installation_source,
270 openstack_upgrade_available,
271 os_requires_version,
272@@ -50,6 +51,8 @@
273 get_early_packages,
274 get_common_package,
275 get_topics,
276+ git_install,
277+ git_install_requested,
278 valid_plugin,
279 configure_ovs,
280 stop_services,
281@@ -82,6 +85,7 @@
282 fatal=True)
283 apt_install(filter_installed_packages(get_packages()),
284 fatal=True)
285+ git_install(config('openstack-origin-git'))
286 else:
287 log('Please provide a valid plugin config', level=ERROR)
288 sys.exit(1)
289@@ -94,8 +98,15 @@
290 @restart_on_change(restart_map())
291 def config_changed():
292 global CONFIGS
293- if openstack_upgrade_available(get_common_package()):
294- CONFIGS = do_openstack_upgrade()
295+ if git_install_requested():
296+ if config_value_changed('openstack-origin-git'):
297+ git_install(config('openstack-origin-git'))
298+ CONFIGS.write_all()
299+ else:
300+ if openstack_upgrade_available(get_common_package()):
301+ do_openstack_upgrade()
302+ CONFIGS.write_all()
303+
304 update_nrpe_config()
305
306 sysctl_dict = config('sysctl')
307@@ -120,10 +131,11 @@
308 log('Please provide a valid plugin config', level=ERROR)
309 sys.exit(1)
310 if config('plugin') == 'n1kv':
311- if config('enable-l3-agent'):
312- apt_install(filter_installed_packages('neutron-l3-agent'))
313- else:
314- apt_purge('neutron-l3-agent')
315+ if not git_install_requested():
316+ if config('enable-l3-agent'):
317+ apt_install(filter_installed_packages('neutron-l3-agent'))
318+ else:
319+ apt_purge('neutron-l3-agent')
320
321 # Setup legacy ha configurations
322 update_legacy_ha_files()
323
324=== modified file 'hooks/quantum_utils.py'
325--- hooks/quantum_utils.py 2015-03-31 15:13:53 +0000
326+++ hooks/quantum_utils.py 2015-04-16 14:48:42 +0000
327@@ -1,14 +1,20 @@
328 import os
329+import shutil
330 import subprocess
331 from shutil import copy2
332 from charmhelpers.core.host import (
333+ adduser,
334+ add_group,
335+ add_user_to_group,
336+ lsb_release,
337 mkdir,
338 service_running,
339 service_stop,
340 service_restart,
341- lsb_release,
342+ write_file,
343 )
344 from charmhelpers.core.hookenv import (
345+ charm_dir,
346 log,
347 DEBUG,
348 INFO,
349@@ -18,6 +24,7 @@
350 unit_private_ip,
351 is_relation_made,
352 )
353+from charmhelpers.core.templating import render
354 from charmhelpers.fetch import (
355 apt_upgrade,
356 apt_update,
357@@ -32,6 +39,9 @@
358 configure_installation_source,
359 get_os_codename_install_source,
360 get_os_codename_package,
361+ git_install_requested,
362+ git_clone_and_install,
363+ git_src_dir,
364 get_hostname
365 )
366
367@@ -174,6 +184,39 @@
368 LEGACY_RES_MAP = ['res_monitor']
369 L3HA_PACKAGES = ['keepalived']
370
371+BASE_GIT_PACKAGES = [
372+ 'dnsmasq',
373+ 'libxml2-dev',
374+ 'libxslt1-dev',
375+ 'python-dev',
376+ 'python-pip',
377+ 'python-setuptools',
378+ 'zlib1g-dev',
379+]
380+
381+# ubuntu packages that should not be installed when deploying from git
382+GIT_PACKAGE_BLACKLIST = [
383+ 'nova-api-metadata',
384+ 'neutron-common',
385+ 'neutron-dhcp-agent',
386+ 'neutron-l3-agent',
387+ 'neutron-lbaas-agent',
388+ 'neutron-metadata-agent',
389+ 'neutron-metering-agent',
390+ 'neutron-plugin-cisco',
391+ 'neutron-plugin-metering-agent',
392+ 'neutron-plugin-openvswitch-agent',
393+ 'neutron-plugin-vpn-agent',
394+ 'neutron-vpn-agent',
395+ 'python-neutron-fwaas',
396+ 'python-oslo.config',
397+ 'quantum-common',
398+ 'quantum-dhcp-agent',
399+ 'quantum-l3-agent',
400+ 'quantum-metadata-agent',
401+ 'quantum-plugin-openvswitch-agent',
402+]
403+
404
405 def get_early_packages():
406 '''Return a list of package for pre-install based on configured plugin'''
407@@ -204,6 +247,15 @@
408 if source >= 'kilo':
409 packages.append('python-neutron-fwaas')
410 packages.extend(determine_l3ha_packages())
411+
412+ if git_install_requested():
413+ packages = list(set(packages))
414+ packages.extend(BASE_GIT_PACKAGES)
415+ # don't include packages that will be installed from git
416+ for p in GIT_PACKAGE_BLACKLIST:
417+ if p in packages:
418+ packages.remove(p)
419+
420 return packages
421
422
423@@ -612,12 +664,6 @@
424 apt_install(get_early_packages(), fatal=True)
425 apt_install(get_packages(), fatal=True)
426
427- # set CONFIGS to load templates from new release
428- configs = register_configs()
429- configs.write_all()
430- [service_restart(s) for s in services()]
431- return configs
432-
433
434 def configure_ovs():
435 if config('plugin') == OVS:
436@@ -760,3 +806,348 @@
437 topics.append('q-agent-notifier-dvr-update')
438 topics.append('q-agent-notifier-l2population-update')
439 return topics
440+
441+
442+def git_install(projects_yaml):
443+ """Perform setup, and install git repos specified in yaml parameter."""
444+ if git_install_requested():
445+ git_pre_install()
446+ git_clone_and_install(projects_yaml, core_project='neutron')
447+ git_post_install(projects_yaml)
448+
449+
450+def git_pre_install():
451+ """Perform pre-install setup."""
452+ dirs = [
453+ '/etc/neutron',
454+ '/etc/neutron/rootwrap.d',
455+ '/etc/neutron/plugins',
456+ '/etc/nova',
457+ '/var/lib/neutron',
458+ '/var/lib/neutron/lock',
459+ '/var/log/neutron',
460+ ]
461+
462+ logs = [
463+ '/var/log/neutron/bigswitch-agent.log',
464+ '/var/log/neutron/dhcp-agent.log',
465+ '/var/log/neutron/l3-agent.log',
466+ '/var/log/neutron/lbaas-agent.log',
467+ '/var/log/neutron/ibm-agent.log',
468+ '/var/log/neutron/linuxbridge-agent.log',
469+ '/var/log/neutron/metadata-agent.log',
470+ '/var/log/neutron/metering_agent.log',
471+ '/var/log/neutron/mlnx-agent.log',
472+ '/var/log/neutron/nec-agent.log',
473+ '/var/log/neutron/nvsd-agent.log',
474+ '/var/log/neutron/openflow-agent.log',
475+ '/var/log/neutron/openvswitch-agent.log',
476+ '/var/log/neutron/ovs-cleanup.log',
477+ '/var/log/neutron/ryu-agent.log',
478+ '/var/log/neutron/server.log',
479+ '/var/log/neutron/sriov-agent.log',
480+ '/var/log/neutron/vpn_agent.log',
481+ ]
482+
483+ adduser('neutron', shell='/bin/bash', system_user=True)
484+ add_group('neutron', system_group=True)
485+ add_user_to_group('neutron', 'neutron')
486+
487+ for d in dirs:
488+ mkdir(d, owner='neutron', group='neutron', perms=0700, force=False)
489+
490+ for l in logs:
491+ write_file(l, '', owner='neutron', group='neutron', perms=0644)
492+
493+
494+def git_post_install(projects_yaml):
495+ """Perform post-install setup."""
496+ src_etc = os.path.join(git_src_dir(projects_yaml, 'neutron'), 'etc')
497+ configs = [
498+ {'src': src_etc,
499+ 'dest': '/etc/neutron'},
500+ {'src': os.path.join(src_etc, 'neutron/plugins'),
501+ 'dest': '/etc/neutron/plugins'},
502+ {'src': os.path.join(src_etc, 'neutron/rootwrap.d'),
503+ 'dest': '/etc/neutron/rootwrap.d'},
504+ ]
505+
506+ for c in configs:
507+ if os.path.exists(c['dest']):
508+ shutil.rmtree(c['dest'])
509+ shutil.copytree(c['src'], c['dest'])
510+
511+ symlinks = [
512+ {'src': '/usr/local/bin/neutron-rootwrap',
513+ 'link': '/usr/bin/neutron-rootwrap'},
514+ ]
515+
516+ for s in symlinks:
517+ if os.path.lexists(s['link']):
518+ os.remove(s['link'])
519+ os.symlink(s['src'], s['link'])
520+
521+ render('git/neutron_sudoers',
522+ '/etc/sudoers.d/neutron_sudoers', {}, perms=0o440)
523+ render('git/cron.d/neutron-dhcp-agent-netns-cleanup',
524+ '/etc/cron.d/neutron-dhcp-agent-netns-cleanup', {}, perms=0o755)
525+ render('git/cron.d/neutron-l3-agent-netns-cleanup',
526+ '/etc/cron.d/neutron-l3-agent-netns-cleanup', {}, perms=0o755)
527+ render('git/cron.d/neutron-lbaas-agent-netns-cleanup',
528+ '/etc/cron.d/neutron-lbaas-agent-netns-cleanup', {}, perms=0o755)
529+
530+ service_name = 'quantum-gateway'
531+ user_name = 'neutron'
532+ neutron_api_context = {
533+ 'service_description': 'Neutron API server',
534+ 'service_name': service_name,
535+ 'process_name': 'neutron-server',
536+ }
537+ neutron_dhcp_agent_context = {
538+ 'service_description': 'Neutron DHCP Agent',
539+ 'service_name': service_name,
540+ 'process_name': 'neutron-dhcp-agent',
541+ 'config_files': ['/etc/neutron/neutron.conf',
542+ '/etc/neutron/dhcp_agent.ini'],
543+ 'log_file': '/var/log/neutron/dhcp-agent.log',
544+ }
545+ neutron_l3_agent_context = {
546+ 'service_description': 'Neutron L3 Agent',
547+ 'service_name': service_name,
548+ 'process_name': 'neutron-l3-agent',
549+ 'config_files': ['/etc/neutron/neutron.conf',
550+ '/etc/neutron/l3_agent.ini',
551+ '/etc/neutron/fwaas_driver.ini'],
552+ 'log_file': '/var/log/neutron/l3-agent.log',
553+ }
554+ neutron_lbaas_agent_context = {
555+ 'service_description': 'Neutron LBaaS Agent',
556+ 'service_name': service_name,
557+ 'user_name': user_name,
558+ 'start_dir': '/var/lib/neutron',
559+ 'process_name': 'neutron-lbaas-agent',
560+ 'executable_name': '/usr/local/bin/neutron-lbaas-agent',
561+ 'config_files': ['/etc/neutron/neutron.conf',
562+ '/etc/neutron/lbaas_agent.ini'],
563+ 'log_file': '/var/log/neutron/lbaas-agent.log',
564+ }
565+ neutron_metadata_agent_context = {
566+ 'service_description': 'Neutron Metadata Agent',
567+ 'service_name': service_name,
568+ 'user_name': user_name,
569+ 'start_dir': '/var/lib/neutron',
570+ 'process_name': 'neutron-metadata-agent',
571+ 'executable_name': '/usr/local/bin/neutron-metadata-agent',
572+ 'config_files': ['/etc/neutron/neutron.conf',
573+ '/etc/neutron/metadata_agent.ini'],
574+ 'log_file': '/var/log/neutron/metadata-agent.log',
575+ }
576+ neutron_metering_agent_context = {
577+ 'service_description': 'Neutron Metering Agent',
578+ 'service_name': service_name,
579+ 'user_name': user_name,
580+ 'start_dir': '/var/lib/neutron',
581+ 'process_name': 'neutron-metering-agent',
582+ 'executable_name': '/usr/local/bin/neutron-metering-agent',
583+ 'config_files': ['/etc/neutron/neutron.conf',
584+ '/etc/neutron/metering_agent.ini'],
585+ 'log_file': '/var/log/neutron/metering-agent.log',
586+ }
587+ neutron_ovs_cleanup_context = {
588+ 'service_description': 'Neutron OVS cleanup',
589+ 'service_name': service_name,
590+ 'process_name': 'neutron-ovs-cleanup',
591+ 'config_file': '/etc/neutron/neutron.conf',
592+ 'log_file': '/var/log/neutron/ovs-cleanup.log',
593+ }
594+ neutron_plugin_bigswitch_context = {
595+ 'service_description': 'Neutron BigSwitch Plugin Agent',
596+ 'service_name': service_name,
597+ 'user_name': user_name,
598+ 'start_dir': '/var/lib/neutron',
599+ 'process_name': 'neutron-restproxy-agent',
600+ 'executable_name': '/usr/local/bin/neutron-restproxy-agent',
601+ 'config_files': ['/etc/neutron/neutron.conf',
602+ '/etc/neutron/plugins/bigswitch/restproxy.ini'],
603+ 'log_file': '/var/log/neutron/bigswitch-agent.log',
604+ }
605+ neutron_plugin_ibm_context = {
606+ 'service_description': 'Neutron IBM SDN Plugin Agent',
607+ 'service_name': service_name,
608+ 'user_name': user_name,
609+ 'start_dir': '/var/lib/neutron',
610+ 'process_name': 'neutron-ibm-agent',
611+ 'executable_name': '/usr/local/bin/neutron-ibm-agent',
612+ 'config_files': ['/etc/neutron/neutron.conf',
613+ '/etc/neutron/plugins/ibm/sdnve_neutron_plugin.ini'],
614+ 'log_file': '/var/log/neutron/ibm-agent.log',
615+ }
616+ neutron_plugin_linuxbridge_context = {
617+ 'service_description': 'Neutron Linux Bridge Plugin Agent',
618+ 'service_name': service_name,
619+ 'user_name': user_name,
620+ 'start_dir': '/var/lib/neutron',
621+ 'process_name': 'neutron-linuxbridge-agent',
622+ 'executable_name': '/usr/local/bin/neutron-linuxbridge-agent',
623+ 'config_files': ['/etc/neutron/neutron.conf',
624+ '/etc/neutron/plugins/ml2/ml2_conf.ini'],
625+ 'log_file': '/var/log/neutron/linuxbridge-agent.log',
626+ }
627+ neutron_plugin_mlnx_context = {
628+ 'service_description': 'Neutron MLNX Plugin Agent',
629+ 'service_name': service_name,
630+ 'user_name': user_name,
631+ 'start_dir': '/var/lib/neutron',
632+ 'process_name': 'neutron-mlnx-agent',
633+ 'executable_name': '/usr/local/bin/neutron-mlnx-agent',
634+ 'config_files': ['/etc/neutron/neutron.conf',
635+ '/etc/neutron/plugins/mlnx/mlnx_conf.ini'],
636+ 'log_file': '/var/log/neutron/mlnx-agent.log',
637+ }
638+ neutron_plugin_nec_context = {
639+ 'service_description': 'Neutron NEC Plugin Agent',
640+ 'service_name': service_name,
641+ 'start_dir': '/var/lib/neutron',
642+ 'process_name': 'neutron-nec-agent',
643+ 'executable_name': '/usr/local/bin/neutron-nec-agent',
644+ 'config_files': ['/etc/neutron/neutron.conf',
645+ '/etc/neutron/plugins/nec/nec.ini'],
646+ 'log_file': '/var/log/neutron/nec-agent.log',
647+ }
648+ neutron_plugin_oneconvergence_context = {
649+ 'service_description': 'Neutron One Convergence Plugin Agent',
650+ 'service_name': service_name,
651+ 'user_name': user_name,
652+ 'start_dir': '/var/lib/neutron',
653+ 'process_name': 'neutron-nvsd-agent',
654+ 'executable_name': '/usr/local/bin/neutron-nvsd-agent',
655+ 'config_files': ['/etc/neutron/neutron.conf',
656+ '/etc/neutron/plugins/oneconvergence/nvsdplugin.ini'],
657+ 'log_file': '/var/log/neutron/nvsd-agent.log',
658+ }
659+ neutron_plugin_openflow_context = {
660+ 'service_description': 'Neutron OpenFlow Plugin Agent',
661+ 'service_name': service_name,
662+ 'user_name': user_name,
663+ 'start_dir': '/var/lib/neutron',
664+ 'process_name': 'neutron-ofagent-agent',
665+ 'executable_name': '/usr/local/bin/neutron-ofagent-agent',
666+ 'config_files': ['/etc/neutron/neutron.conf',
667+ '/etc/neutron/plugins/ml2/ml2_conf_ofa.ini'],
668+ 'log_file': '/var/log/neutron/openflow-agent.log',
669+ }
670+ neutron_plugin_openvswitch_context = {
671+ 'service_description': 'Neutron OpenvSwitch Plugin Agent',
672+ 'service_name': service_name,
673+ 'user_name': user_name,
674+ 'start_dir': '/var/lib/neutron',
675+ 'process_name': 'neutron-openvswitch-agent',
676+ 'executable_name': '/usr/local/bin/neutron-openvswitch-agent',
677+ 'config_files': ['/etc/neutron/neutron.conf',
678+ '/etc/neutron/plugins/ml2/ml2_conf.ini'],
679+ 'log_file': '/var/log/neutron/openvswitch-agent.log',
680+ }
681+ neutron_plugin_ryu_context = {
682+ 'service_description': 'Neutron RYU Plugin Agent',
683+ 'service_name': service_name,
684+ 'user_name': user_name,
685+ 'start_dir': '/var/lib/neutron',
686+ 'process_name': 'neutron-ryu-agent',
687+ 'executable_name': '/usr/local/bin/neutron-ryu-agent',
688+ 'config_files': ['/etc/neutron/neutron.conf',
689+ '/etc/neutron/plugins/ryu/ryu.ini'],
690+ 'log_file': '/var/log/neutron/ryu-agent.log',
691+ }
692+ neutron_plugin_sriov_context = {
693+ 'service_description': 'Neutron SRIOV SDN Plugin Agent',
694+ 'service_name': service_name,
695+ 'user_name': user_name,
696+ 'start_dir': '/var/lib/neutron',
697+ 'process_name': 'neutron-sriov-nic-agent',
698+ 'executable_name': '/usr/local/bin/neutron-sriov-nic-agent',
699+ 'config_files': ['/etc/neutron/neutron.conf',
700+ '/etc/neutron/plugins/ml2/ml2_conf_sriov'],
701+ 'log_file': '/var/log/neutron/sriov-agent.log',
702+ }
703+ neutron_vpn_agent_context = {
704+ 'service_description': 'Neutron VPN Agent',
705+ 'service_name': service_name,
706+ 'process_name': 'neutron-vpn-agent',
707+ 'config_files': ['/etc/neutron/neutron.conf',
708+ '/etc/neutron/vpn_agent.ini',
709+ '/etc/neutron/l3_agent.ini',
710+ '/etc/neutron/fwaas_driver.ini'],
711+ 'log_file': '/var/log/neutron/vpn_agent.log',
712+ }
713+
714+ # NOTE(coreycb): Needs systemd support
715+ templates_dir = 'hooks/charmhelpers/contrib/openstack/templates'
716+ templates_dir = os.path.join(charm_dir(), templates_dir)
717+ render('git/upstart/neutron-agent.upstart',
718+ '/etc/init/neutron-dhcp-agent.conf',
719+ neutron_dhcp_agent_context, perms=0o644)
720+ render('git/upstart/neutron-agent.upstart',
721+ '/etc/init/neutron-l3-agent.conf',
722+ neutron_l3_agent_context, perms=0o644)
723+ render('git.upstart',
724+ '/etc/init/neutron-lbaas-agent.conf',
725+ neutron_lbaas_agent_context, perms=0o644,
726+ templates_dir=templates_dir)
727+ render('git.upstart',
728+ '/etc/init/neutron-metadata-agent.conf',
729+ neutron_metadata_agent_context, perms=0o644,
730+ templates_dir=templates_dir)
731+ render('git.upstart',
732+ '/etc/init/neutron-metering-agent.conf',
733+ neutron_metering_agent_context, perms=0o644,
734+ templates_dir=templates_dir)
735+ render('git.upstart',
736+ '/etc/init/neutron-ovs-cleanup.conf',
737+ neutron_ovs_cleanup_context, perms=0o644,
738+ templates_dir=templates_dir)
739+ render('git.upstart',
740+ '/etc/init/neutron-plugin-bigswitch-agent.conf',
741+ neutron_plugin_bigswitch_context, perms=0o644,
742+ templates_dir=templates_dir)
743+ render('git.upstart',
744+ '/etc/init/neutron-plugin-ibm-agent.conf',
745+ neutron_plugin_ibm_context, perms=0o644,
746+ templates_dir=templates_dir)
747+ render('git.upstart',
748+ '/etc/init/neutron-plugin-linuxbridge-agent.conf',
749+ neutron_plugin_linuxbridge_context, perms=0o644,
750+ templates_dir=templates_dir)
751+ render('git.upstart',
752+ '/etc/init/neutron-plugin-mlnx-agent.conf',
753+ neutron_plugin_mlnx_context, perms=0o644,
754+ templates_dir=templates_dir)
755+ render('git.upstart',
756+ '/etc/init/neutron-plugin-nec-agent.conf',
757+ neutron_plugin_nec_context, perms=0o644,
758+ templates_dir=templates_dir)
759+ render('git.upstart',
760+ '/etc/init/neutron-plugin-oneconvergence-agent.conf',
761+ neutron_plugin_oneconvergence_context, perms=0o644,
762+ templates_dir=templates_dir)
763+ render('git.upstart',
764+ '/etc/init/neutron-plugin-openflow-agent.conf',
765+ neutron_plugin_openflow_context, perms=0o644,
766+ templates_dir=templates_dir)
767+ render('git.upstart',
768+ '/etc/init/neutron-plugin-openvswitch-agent.conf',
769+ neutron_plugin_openvswitch_context, perms=0o644,
770+ templates_dir=templates_dir)
771+ render('git.upstart',
772+ '/etc/init/neutron-plugin-ryu-agent.conf',
773+ neutron_plugin_ryu_context, perms=0o644,
774+ templates_dir=templates_dir)
775+ render('git.upstart',
776+ '/etc/init/neutron-plugin-sriov-agent.conf',
777+ neutron_plugin_sriov_context, perms=0o644,
778+ templates_dir=templates_dir)
779+ render('git/upstart/neutron-server.upstart',
780+ '/etc/init/neutron-server.conf',
781+ neutron_api_context, perms=0o644)
782+ render('git/upstart/neutron-agent.upstart',
783+ '/etc/init/neutron-vpn-agent.conf',
784+ neutron_vpn_agent_context, perms=0o644)
785
786=== added directory 'templates/git'
787=== added directory 'templates/git/cron.d'
788=== added file 'templates/git/cron.d/neutron-dhcp-agent-netns-cleanup'
789--- templates/git/cron.d/neutron-dhcp-agent-netns-cleanup 1970-01-01 00:00:00 +0000
790+++ templates/git/cron.d/neutron-dhcp-agent-netns-cleanup 2015-04-16 14:48:42 +0000
791@@ -0,0 +1,4 @@
792+# vim: set filetype=crontab:
793+# Periodically cleans Neutron's network namespaces on behalf of the Neutron
794+# DHCP agent.
795+30 * * * * neutron if [ -x /usr/local/bin/neutron-netns-cleanup ] ; then /usr/local/bin/neutron-netns-cleanup --config-file=/etc/neutron/neutron.conf --config-file=/etc/neutron/dhcp_agent.ini >/dev/null 2>&1; fi
796
797=== added file 'templates/git/cron.d/neutron-l3-agent-netns-cleanup'
798--- templates/git/cron.d/neutron-l3-agent-netns-cleanup 1970-01-01 00:00:00 +0000
799+++ templates/git/cron.d/neutron-l3-agent-netns-cleanup 2015-04-16 14:48:42 +0000
800@@ -0,0 +1,4 @@
801+# vim: set filetype=crontab:
802+# Periodically cleans Neutron's network namespaces on behalf of the Neutron
803+# L3 agent.
804+0 * * * * neutron if [ -x /usr/local/bin/neutron-netns-cleanup ] ; then /usr/local/bin/neutron-netns-cleanup --config-file=/etc/neutron/neutron.conf --config-file=/etc/neutron/l3_agent.ini >/dev/null 2>&1; fi
805
806=== added file 'templates/git/cron.d/neutron-lbaas-agent-netns-cleanup'
807--- templates/git/cron.d/neutron-lbaas-agent-netns-cleanup 1970-01-01 00:00:00 +0000
808+++ templates/git/cron.d/neutron-lbaas-agent-netns-cleanup 2015-04-16 14:48:42 +0000
809@@ -0,0 +1,4 @@
810+# vim: set filetype=crontab:
811+# Periodically cleans Neutron's network namespaces on behalf of the Neutron
812+# L3 agent.
813+0 * * * * neutron if [ -x /usr/local/bin/neutron-netns-cleanup ] ; then /usr/local/bin/neutron-netns-cleanup --config-file=/etc/neutron/neutron.conf --config-file=/etc/neutron/lbaas_agent.ini >/dev/null 2>&1; fi
814
815=== added file 'templates/git/neutron_sudoers'
816--- templates/git/neutron_sudoers 1970-01-01 00:00:00 +0000
817+++ templates/git/neutron_sudoers 2015-04-16 14:48:42 +0000
818@@ -0,0 +1,4 @@
819+Defaults:neutron !requiretty
820+
821+neutron ALL = (root) NOPASSWD: /usr/local/bin/neutron-rootwrap /etc/neutron/rootwrap.conf *
822+
823
824=== added directory 'templates/git/upstart'
825=== added file 'templates/git/upstart/neutron-agent.upstart'
826--- templates/git/upstart/neutron-agent.upstart 1970-01-01 00:00:00 +0000
827+++ templates/git/upstart/neutron-agent.upstart 2015-04-16 14:48:42 +0000
828@@ -0,0 +1,25 @@
829+description "{{ service_description }}"
830+author "Juju {{ service_name }} Charm <juju@localhost>"
831+
832+start on runlevel [2345]
833+stop on runlevel [!2345]
834+
835+respawn
836+
837+chdir /var/run
838+
839+pre-start script
840+ mkdir -p /var/run/neutron
841+ chown neutron:root /var/run/neutron
842+ # Check to see if openvswitch plugin in use by checking
843+ # status of cleanup upstart configuration
844+ if status neutron-ovs-cleanup; then
845+ start wait-for-state WAIT_FOR=neutron-ovs-cleanup WAIT_STATE=running WAITER={{ process_name }}
846+ fi
847+end script
848+
849+exec start-stop-daemon --start --chuid neutron --exec /usr/local/bin/{{ process_name }} -- \
850+ {% for config_file in config_files -%}
851+ --config-file={{ config_file }} \
852+ {% endfor -%}
853+ --log-file={{ log_file }}
854
855=== added file 'templates/git/upstart/neutron-ovs-cleanup.upstart'
856--- templates/git/upstart/neutron-ovs-cleanup.upstart 1970-01-01 00:00:00 +0000
857+++ templates/git/upstart/neutron-ovs-cleanup.upstart 2015-04-16 14:48:42 +0000
858@@ -0,0 +1,13 @@
859+description "{{ service_description }}"
860+author "Juju {{ service_name }} Charm <juju@localhost>"
861+
862+start on started openvswitch-switch
863+stop on runlevel [!2345]
864+
865+pre-start script
866+ [ ! -x /usr/local/bin/{{ process_name }} ] && exit 0
867+ start-stop-daemon --start --chuid neutron \
868+ --exec /usr/local/bin/{{ process_name }} -- \
869+ --log-file {{ log_file }} \
870+ --config-file {{ config_file }} --verbose
871+end script
872
873=== added file 'templates/git/upstart/neutron-server.upstart'
874--- templates/git/upstart/neutron-server.upstart 1970-01-01 00:00:00 +0000
875+++ templates/git/upstart/neutron-server.upstart 2015-04-16 14:48:42 +0000
876@@ -0,0 +1,22 @@
877+description "{{ service_description }}"
878+author "Juju {{ service_name }} Charm <juju@localhost>"
879+
880+start on runlevel [2345]
881+stop on runlevel [!2345]
882+
883+respawn
884+
885+chdir /var/run
886+
887+pre-start script
888+ mkdir -p /var/run/neutron
889+ chown neutron:root /var/run/neutron
890+end script
891+
892+script
893+ [ -r /etc/default/{{ process_name }} ] && . /etc/default/{{ process_name }}
894+ [ -r "$NEUTRON_PLUGIN_CONFIG" ] && CONF_ARG="--config-file $NEUTRON_PLUGIN_CONFIG"
895+ exec start-stop-daemon --start --chuid neutron --exec /usr/local/bin/neutron-server -- \
896+ --config-file /etc/neutron/neutron.conf \
897+ --log-file /var/log/neutron/server.log $CONF_ARG
898+end script
899
900=== removed file 'tests/12-basic-precise-grizzly'
901--- tests/12-basic-precise-grizzly 2014-07-17 15:16:21 +0000
902+++ tests/12-basic-precise-grizzly 1970-01-01 00:00:00 +0000
903@@ -1,11 +0,0 @@
904-#!/usr/bin/python
905-
906-"""Amulet tests on a basic quantum-gateway deployment on precise-grizzly."""
907-
908-from basic_deployment import QuantumGatewayBasicDeployment
909-
910-if __name__ == '__main__':
911- deployment = QuantumGatewayBasicDeployment(series='precise',
912- openstack='cloud:precise-grizzly',
913- source='cloud:precise-updates/grizzly')
914- deployment.run_tests()
915
916=== removed file 'tests/13-basic-precise-havana'
917--- tests/13-basic-precise-havana 2014-07-17 15:16:21 +0000
918+++ tests/13-basic-precise-havana 1970-01-01 00:00:00 +0000
919@@ -1,11 +0,0 @@
920-#!/usr/bin/python
921-
922-"""Amulet tests on a basic quantum-gateway deployment on precise-havana."""
923-
924-from basic_deployment import QuantumGatewayBasicDeployment
925-
926-if __name__ == '__main__':
927- deployment = QuantumGatewayBasicDeployment(series='precise',
928- openstack='cloud:precise-havana',
929- source='cloud:precise-updates/havana')
930- deployment.run_tests()
931
932=== added file 'tests/16-basic-trusty-icehouse-git'
933--- tests/16-basic-trusty-icehouse-git 1970-01-01 00:00:00 +0000
934+++ tests/16-basic-trusty-icehouse-git 2015-04-16 14:48:42 +0000
935@@ -0,0 +1,9 @@
936+#!/usr/bin/python
937+
938+"""Amulet tests on a basic quantum-gateway git deployment on trusty-icehouse."""
939+
940+from basic_deployment import QuantumGatewayBasicDeployment
941+
942+if __name__ == '__main__':
943+ deployment = QuantumGatewayBasicDeployment(series='trusty', git=True)
944+ deployment.run_tests()
945
946=== added file 'tests/17-basic-trusty-juno'
947--- tests/17-basic-trusty-juno 1970-01-01 00:00:00 +0000
948+++ tests/17-basic-trusty-juno 2015-04-16 14:48:42 +0000
949@@ -0,0 +1,11 @@
950+#!/usr/bin/python
951+
952+"""Amulet tests on a basic quantum-gateway deployment on trusty-juno."""
953+
954+from basic_deployment import QuantumGatewayBasicDeployment
955+
956+if __name__ == '__main__':
957+ deployment = QuantumGatewayBasicDeployment(series='trusty',
958+ openstack='cloud:trusty-juno',
959+ source='cloud:trusty-updates/juno')
960+ deployment.run_tests()
961
962=== added file 'tests/18-basic-trusty-juno-git'
963--- tests/18-basic-trusty-juno-git 1970-01-01 00:00:00 +0000
964+++ tests/18-basic-trusty-juno-git 2015-04-16 14:48:42 +0000
965@@ -0,0 +1,12 @@
966+#!/usr/bin/python
967+
968+"""Amulet tests on a basic quantum-gateway git deployment on trusty-juno."""
969+
970+from basic_deployment import QuantumGatewayBasicDeployment
971+
972+if __name__ == '__main__':
973+ deployment = QuantumGatewayBasicDeployment(series='trusty',
974+ openstack='cloud:trusty-juno',
975+ source='cloud:trusty-updates/juno',
976+ git=True)
977+ deployment.run_tests()
978
979=== modified file 'tests/basic_deployment.py'
980--- tests/basic_deployment.py 2015-04-09 16:22:27 +0000
981+++ tests/basic_deployment.py 2015-04-16 14:48:42 +0000
982@@ -1,7 +1,9 @@
983 #!/usr/bin/python
984
985 import amulet
986+import os
987 import time
988+import yaml
989 try:
990 from quantumclient.v2_0 import client as neutronclient
991 except ImportError:
992@@ -18,16 +20,18 @@
993 )
994
995 # Use DEBUG to turn on debug logging
996-u = OpenStackAmuletUtils(ERROR)
997+u = OpenStackAmuletUtils(DEBUG)
998
999
1000 class QuantumGatewayBasicDeployment(OpenStackAmuletDeployment):
1001 """Amulet tests on a basic quantum-gateway deployment."""
1002
1003- def __init__(self, series, openstack=None, source=None, stable=False):
1004+ def __init__(self, series, openstack=None, source=None, git=False,
1005+ stable=False):
1006 """Deploy the entire test environment."""
1007 super(QuantumGatewayBasicDeployment, self).__init__(series, openstack,
1008 source, stable)
1009+ self.git = git
1010 self._add_services()
1011 self._add_relations()
1012 self._configure_services()
1013@@ -64,11 +68,30 @@
1014
1015 def _configure_services(self):
1016 """Configure all of the services."""
1017+ quantum_gateway_config = {}
1018+ if self.git:
1019+ branch = 'stable/' + self._get_openstack_release_string()
1020+ amulet_http_proxy = os.environ.get('AMULET_HTTP_PROXY')
1021+ openstack_origin_git = {
1022+ 'repositories': [
1023+ {'name': 'requirements',
1024+ 'repository': 'git://git.openstack.org/openstack/requirements',
1025+ 'branch': branch},
1026+ {'name': 'neutron',
1027+ 'repository': 'git://git.openstack.org/openstack/neutron',
1028+ 'branch': branch},
1029+ ],
1030+ 'directory': '/mnt/openstack-git',
1031+ 'http_proxy': amulet_http_proxy,
1032+ 'https_proxy': amulet_http_proxy,
1033+ }
1034+ quantum_gateway_config['openstack-origin-git'] = yaml.dump(openstack_origin_git)
1035 keystone_config = {'admin-password': 'openstack',
1036 'admin-token': 'ubuntutesting'}
1037 nova_cc_config = {'network-manager': 'Quantum',
1038 'quantum-security-groups': 'yes'}
1039- configs = {'keystone': keystone_config,
1040+ configs = {'quantum-gateway': quantum_gateway_config,
1041+ 'keystone': keystone_config,
1042 'nova-cloud-controller': nova_cc_config}
1043 super(QuantumGatewayBasicDeployment, self)._configure_services(configs)
1044
1045@@ -269,7 +292,7 @@
1046
1047 self.d.configure('quantum-gateway', {'debug': 'True'})
1048
1049- time = 20
1050+ time = 40
1051 for s in services:
1052 if not u.service_restarted(self.quantum_gateway_sentry, s, conf,
1053 pgrep_full=True, sleep_time=time):
1054
1055=== modified file 'unit_tests/__init__.py'
1056--- unit_tests/__init__.py 2013-07-22 15:39:07 +0000
1057+++ unit_tests/__init__.py 2015-04-16 14:48:42 +0000
1058@@ -1,2 +1,4 @@
1059 import sys
1060+
1061+sys.path.append('actions')
1062 sys.path.append('hooks')
1063
1064=== added file 'unit_tests/test_actions_git_reinstall.py'
1065--- unit_tests/test_actions_git_reinstall.py 1970-01-01 00:00:00 +0000
1066+++ unit_tests/test_actions_git_reinstall.py 2015-04-16 14:48:42 +0000
1067@@ -0,0 +1,105 @@
1068+from mock import patch, MagicMock
1069+
1070+with patch('charmhelpers.core.hookenv.config') as config:
1071+ config.return_value = 'neutron'
1072+ import quantum_utils as utils # noqa
1073+
1074+# Need to do some early patching to get the module loaded.
1075+_register_configs = utils.register_configs
1076+_restart_map = utils.restart_map
1077+
1078+utils.register_configs = MagicMock()
1079+utils.restart_map = MagicMock()
1080+
1081+import git_reinstall
1082+
1083+# Unpatch it now that its loaded.
1084+utils.register_configs = _register_configs
1085+utils.restart_map = _restart_map
1086+
1087+from test_utils import (
1088+ CharmTestCase
1089+)
1090+
1091+TO_PATCH = [
1092+ 'config',
1093+]
1094+
1095+
1096+openstack_origin_git = \
1097+ """repositories:
1098+ - {name: requirements,
1099+ repository: 'git://git.openstack.org/openstack/requirements',
1100+ branch: stable/juno}
1101+ - {name: neutron,
1102+ repository: 'git://git.openstack.org/openstack/neutron',
1103+ branch: stable/juno}"""
1104+
1105+
1106+class TestNeutronAPIActions(CharmTestCase):
1107+
1108+ def setUp(self):
1109+ super(TestNeutronAPIActions, self).setUp(git_reinstall, TO_PATCH)
1110+ self.config.side_effect = self.test_config.get
1111+
1112+ @patch.object(git_reinstall, 'action_set')
1113+ @patch.object(git_reinstall, 'action_fail')
1114+ @patch.object(git_reinstall, 'git_install')
1115+ @patch.object(git_reinstall, 'config_changed')
1116+ def test_git_reinstall(self, config_changed, git_install, action_fail,
1117+ action_set):
1118+ self.test_config.set('openstack-origin-git', openstack_origin_git)
1119+
1120+ git_reinstall.git_reinstall()
1121+
1122+ git_install.assert_called_with(openstack_origin_git)
1123+ self.assertTrue(git_install.called)
1124+ self.assertTrue(config_changed.called)
1125+ self.assertFalse(action_set.called)
1126+ self.assertFalse(action_fail.called)
1127+
1128+ @patch.object(git_reinstall, 'action_set')
1129+ @patch.object(git_reinstall, 'action_fail')
1130+ @patch.object(git_reinstall, 'git_install')
1131+ @patch.object(git_reinstall, 'config_changed')
1132+ @patch('charmhelpers.contrib.openstack.utils.config')
1133+ def test_git_reinstall_not_configured(self, _config, config_changed,
1134+ git_install, action_fail,
1135+ action_set):
1136+ _config.return_value = None
1137+
1138+ git_reinstall.git_reinstall()
1139+
1140+ msg = 'openstack-origin-git is not configured'
1141+ action_fail.assert_called_with(msg)
1142+ self.assertFalse(git_install.called)
1143+ self.assertFalse(action_set.called)
1144+
1145+ @patch.object(git_reinstall, 'action_set')
1146+ @patch.object(git_reinstall, 'action_fail')
1147+ @patch.object(git_reinstall, 'git_install')
1148+ @patch.object(git_reinstall, 'config_changed')
1149+ @patch('traceback.format_exc')
1150+ @patch('charmhelpers.contrib.openstack.utils.config')
1151+ def test_git_reinstall_exception(self, _config, format_exc,
1152+ config_changed, git_install, action_fail,
1153+ action_set):
1154+ _config.return_value = openstack_origin_git
1155+ e = OSError('something bad happened')
1156+ git_install.side_effect = e
1157+ traceback = (
1158+ "Traceback (most recent call last):\n"
1159+ " File \"actions/git_reinstall.py\", line 37, in git_reinstall\n"
1160+ " git_install(config(\'openstack-origin-git\'))\n"
1161+ " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 964, in __call__\n" # noqa
1162+ " return _mock_self._mock_call(*args, **kwargs)\n"
1163+ " File \"/usr/lib/python2.7/dist-packages/mock.py\", line 1019, in _mock_call\n" # noqa
1164+ " raise effect\n"
1165+ "OSError: something bad happened\n")
1166+ format_exc.return_value = traceback
1167+
1168+ git_reinstall.git_reinstall()
1169+
1170+ msg = 'git-reinstall resulted in an unexpected error'
1171+ action_fail.assert_called_with(msg)
1172+ action_set.assert_called_with({'traceback': traceback})
1173
1174=== modified file 'unit_tests/test_quantum_hooks.py'
1175--- unit_tests/test_quantum_hooks.py 2015-03-31 15:13:53 +0000
1176+++ unit_tests/test_quantum_hooks.py 2015-04-16 14:48:42 +0000
1177@@ -1,4 +1,5 @@
1178 from mock import MagicMock, patch, call
1179+import yaml
1180 import charmhelpers.core.hookenv as hookenv
1181 hookenv.config = MagicMock()
1182 import quantum_utils as utils
1183@@ -23,6 +24,7 @@
1184 'filter_installed_packages',
1185 'get_early_packages',
1186 'get_packages',
1187+ 'git_install',
1188 'log',
1189 'do_openstack_upgrade',
1190 'openstack_upgrade_available',
1191@@ -103,9 +105,46 @@
1192 self.assertTrue(self.log.called)
1193 _exit.assert_called_with(1)
1194
1195- def test_config_changed(self):
1196+ @patch.object(utils, 'git_install_requested')
1197+ def test_install_hook_git(self, git_requested):
1198+ git_requested.return_value = True
1199+ self.valid_plugin.return_value = True
1200+ _pkgs = ['foo', 'bar']
1201+ self.filter_installed_packages.return_value = _pkgs
1202+ repo = 'cloud:trusty-juno'
1203+ openstack_origin_git = {
1204+ 'repositories': [
1205+ {'name': 'requirements',
1206+ 'repository': 'git://git.openstack.org/openstack/requirements', # noqa
1207+ 'branch': 'stable/juno'},
1208+ {'name': 'neutron',
1209+ 'repository': 'git://git.openstack.org/openstack/neutron',
1210+ 'branch': 'stable/juno'}
1211+ ],
1212+ 'directory': '/mnt/openstack-git',
1213+ }
1214+ projects_yaml = yaml.dump(openstack_origin_git)
1215+ self.test_config.set('openstack-origin', repo)
1216+ self.test_config.set('openstack-origin-git', projects_yaml)
1217+ self._call_hook('install')
1218+ self.configure_installation_source.assert_called_with(
1219+ 'cloud:trusty-juno'
1220+ )
1221+ self.apt_update.assert_called_with(fatal=True)
1222+ self.apt_install.assert_has_calls([
1223+ call(_pkgs, fatal=True),
1224+ call(_pkgs, fatal=True),
1225+ ])
1226+ self.assertTrue(self.get_early_packages.called)
1227+ self.assertTrue(self.get_packages.called)
1228+ self.git_install.assert_called_with(projects_yaml)
1229+ self.assertTrue(self.execd_preinstall.called)
1230+
1231+ @patch.object(hooks, 'git_install_requested')
1232+ def test_config_changed(self, git_requested):
1233 def mock_relids(rel):
1234 return ['relid']
1235+ git_requested.return_value = False
1236 self.test_config.set('sysctl', '{ kernel.max_pid: "1337"}')
1237 self.openstack_upgrade_available.return_value = True
1238 self.valid_plugin.return_value = True
1239@@ -125,14 +164,18 @@
1240 self.assertTrue(_zmq_joined.called)
1241 self.create_sysctl.assert_called()
1242
1243- def test_config_changed_upgrade(self):
1244+ @patch.object(hooks, 'git_install_requested')
1245+ def test_config_changed_upgrade(self, git_requested):
1246+ git_requested.return_value = False
1247 self.openstack_upgrade_available.return_value = True
1248 self.valid_plugin.return_value = True
1249 self._call_hook('config-changed')
1250 self.assertTrue(self.do_openstack_upgrade.called)
1251 self.assertTrue(self.configure_ovs.called)
1252
1253- def test_config_changed_n1kv(self):
1254+ @patch.object(hooks, 'git_install_requested')
1255+ def test_config_changed_n1kv(self, git_requested):
1256+ git_requested.return_value = False
1257 self.openstack_upgrade_available.return_value = False
1258 self.valid_plugin.return_value = True
1259 self.filter_installed_packages.side_effect = lambda p: p
1260@@ -144,12 +187,56 @@
1261 self.apt_purge.assert_called_with('neutron-l3-agent')
1262
1263 @patch('sys.exit')
1264- def test_config_changed_invalid_plugin(self, _exit):
1265+ @patch.object(hooks, 'git_install_requested')
1266+ def test_config_changed_invalid_plugin(self, git_requested, _exit):
1267+ git_requested.return_value = False
1268 self.valid_plugin.return_value = False
1269 self._call_hook('config-changed')
1270 self.assertTrue(self.log.called)
1271 _exit.assert_called_with(1)
1272
1273+ @patch.object(hooks, 'git_install_requested')
1274+ @patch.object(hooks, 'config_value_changed')
1275+ def test_config_changed_git(self, config_val_changed, git_requested):
1276+ def mock_relids(rel):
1277+ return ['relid']
1278+ git_requested.return_value = True
1279+ self.test_config.set('sysctl', '{ kernel.max_pid: "1337"}')
1280+ self.openstack_upgrade_available.return_value = True
1281+ self.valid_plugin.return_value = True
1282+ self.relation_ids.side_effect = mock_relids
1283+ _db_joined = self.patch('db_joined')
1284+ _pgsql_db_joined = self.patch('pgsql_db_joined')
1285+ _amqp_joined = self.patch('amqp_joined')
1286+ _amqp_nova_joined = self.patch('amqp_nova_joined')
1287+ _zmq_joined = self.patch('zeromq_configuration_relation_joined')
1288+ repo = 'cloud:trusty-juno'
1289+ openstack_origin_git = {
1290+ 'repositories': [
1291+ {'name': 'requirements',
1292+ 'repository':
1293+ 'git://git.openstack.org/openstack/requirements',
1294+ 'branch': 'stable/juno'},
1295+ {'name': 'neutron',
1296+ 'repository': 'git://git.openstack.org/openstack/neutron',
1297+ 'branch': 'stable/juno'}
1298+ ],
1299+ 'directory': '/mnt/openstack-git',
1300+ }
1301+ projects_yaml = yaml.dump(openstack_origin_git)
1302+ self.test_config.set('openstack-origin', repo)
1303+ self.test_config.set('openstack-origin-git', projects_yaml)
1304+ self._call_hook('config-changed')
1305+ self.git_install.assert_called_with(projects_yaml)
1306+ self.assertFalse(self.do_openstack_upgrade.called)
1307+ self.assertTrue(self.configure_ovs.called)
1308+ self.assertTrue(_db_joined.called)
1309+ self.assertTrue(_pgsql_db_joined.called)
1310+ self.assertTrue(_amqp_joined.called)
1311+ self.assertTrue(_amqp_nova_joined.called)
1312+ self.assertTrue(_zmq_joined.called)
1313+ self.create_sysctl.assert_called()
1314+
1315 def test_upgrade_charm(self):
1316 _install = self.patch('install')
1317 _config_changed = self.patch('config_changed')
1318
1319=== modified file 'unit_tests/test_quantum_utils.py'
1320--- unit_tests/test_quantum_utils.py 2015-03-25 08:14:45 +0000
1321+++ unit_tests/test_quantum_utils.py 2015-04-16 14:48:42 +0000
1322@@ -49,6 +49,15 @@
1323 'NeutronAPIContext',
1324 ]
1325
1326+openstack_origin_git = \
1327+ """repositories:
1328+ - {name: requirements,
1329+ repository: 'git://git.openstack.org/openstack/requirements',
1330+ branch: stable/juno}
1331+ - {name: neutron,
1332+ repository: 'git://git.openstack.org/openstack/neutron',
1333+ branch: stable/juno}"""
1334+
1335
1336 class TestQuantumUtils(CharmTestCase):
1337
1338@@ -110,36 +119,48 @@
1339 self.assertEquals(quantum_utils.get_early_packages(),
1340 [])
1341
1342- def test_get_packages_ovs(self):
1343+ @patch.object(quantum_utils, 'git_install_requested')
1344+ def test_get_packages_ovs(self, git_requested):
1345+ git_requested.return_value = False
1346 self.config.return_value = 'ovs'
1347 self.get_os_codename_install_source.return_value = 'havana'
1348 self.assertNotEqual(quantum_utils.get_packages(), [])
1349
1350- def test_get_packages_ovs_icehouse(self):
1351+ @patch.object(quantum_utils, 'git_install_requested')
1352+ def test_get_packages_ovs_icehouse(self, git_requested):
1353+ git_requested.return_value = False
1354 self.config.return_value = 'ovs'
1355 self.get_os_codename_install_source.return_value = 'icehouse'
1356 self.assertTrue('neutron-vpn-agent' in quantum_utils.get_packages())
1357 self.assertFalse('neutron-l3-agent' in quantum_utils.get_packages())
1358
1359- def test_get_packages_ovs_juno_utopic(self):
1360+ @patch.object(quantum_utils, 'git_install_requested')
1361+ def test_get_packages_ovs_juno_utopic(self, git_requested):
1362+ git_requested.return_value = False
1363 self.config.return_value = 'ovs'
1364 self.get_os_codename_install_source.return_value = 'juno'
1365 self._set_distrib_codename('utopic')
1366 self.assertFalse('neutron-vpn-agent' in quantum_utils.get_packages())
1367 self.assertTrue('neutron-l3-agent' in quantum_utils.get_packages())
1368
1369- def test_get_packages_ovs_juno_trusty(self):
1370+ @patch.object(quantum_utils, 'git_install_requested')
1371+ def test_get_packages_ovs_juno_trusty(self, git_requested):
1372+ git_requested.return_value = False
1373 self.config.return_value = 'ovs'
1374 self.get_os_codename_install_source.return_value = 'juno'
1375 self.assertTrue('neutron-vpn-agent' in quantum_utils.get_packages())
1376 self.assertFalse('neutron-l3-agent' in quantum_utils.get_packages())
1377
1378- def test_get_packages_ovs_kilo(self):
1379+ @patch.object(quantum_utils, 'git_install_requested')
1380+ def test_get_packages_ovs_kilo(self, git_requested):
1381+ git_requested.return_value = False
1382 self.config.return_value = 'ovs'
1383 self.get_os_codename_install_source.return_value = 'kilo'
1384 self.assertTrue('python-neutron-fwaas' in quantum_utils.get_packages())
1385
1386- def test_get_packages_l3ha(self):
1387+ @patch.object(quantum_utils, 'git_install_requested')
1388+ def test_get_packages_l3ha(self, git_requested):
1389+ git_requested.return_value = False
1390 self.config.return_value = 'ovs'
1391 self.get_os_codename_install_source.return_value = 'juno'
1392 self.assertTrue('keepalived' in quantum_utils.get_packages())
1393@@ -204,7 +225,9 @@
1394 # Not called since we have a bogus bridge in data-ports
1395 self.assertFalse(self.add_bridge_port.called)
1396
1397- def test_do_openstack_upgrade(self):
1398+ @patch.object(quantum_utils, 'git_install_requested')
1399+ def test_do_openstack_upgrade(self, git_requested):
1400+ git_requested.return_value = False
1401 self.config.side_effect = self.test_config.get
1402 self.is_relation_made.return_value = False
1403 self.test_config.set('openstack-origin', 'cloud:precise-havana')
1404@@ -671,3 +694,383 @@
1405 self.assertTrue(self.log.called)
1406 assert not dummy_client.remove_router_from_l3_agent.called
1407 assert not dummy_client.remove_network_from_dhcp_agent.called
1408+
1409+ @patch.object(quantum_utils, 'git_install_requested')
1410+ @patch.object(quantum_utils, 'git_clone_and_install')
1411+ @patch.object(quantum_utils, 'git_post_install')
1412+ @patch.object(quantum_utils, 'git_pre_install')
1413+ def test_git_install(self, git_pre, git_post, git_clone_and_install,
1414+ git_requested):
1415+ projects_yaml = openstack_origin_git
1416+ git_requested.return_value = True
1417+ quantum_utils.git_install(projects_yaml)
1418+ self.assertTrue(git_pre.called)
1419+ git_clone_and_install.assert_called_with(openstack_origin_git,
1420+ core_project='neutron')
1421+ self.assertTrue(git_post.called)
1422+
1423+ @patch.object(quantum_utils, 'mkdir')
1424+ @patch.object(quantum_utils, 'write_file')
1425+ @patch.object(quantum_utils, 'add_user_to_group')
1426+ @patch.object(quantum_utils, 'add_group')
1427+ @patch.object(quantum_utils, 'adduser')
1428+ def test_git_pre_install(self, adduser, add_group, add_user_to_group,
1429+ write_file, mkdir):
1430+ quantum_utils.git_pre_install()
1431+ adduser.assert_called_with('neutron', shell='/bin/bash',
1432+ system_user=True)
1433+ add_group.assert_called_with('neutron', system_group=True)
1434+ add_user_to_group.assert_called_with('neutron', 'neutron')
1435+ expected = [
1436+ call('/etc/neutron', owner='neutron',
1437+ group='neutron', perms=0700, force=False),
1438+ call('/etc/neutron/rootwrap.d', owner='neutron',
1439+ group='neutron', perms=0700, force=False),
1440+ call('/etc/neutron/plugins', owner='neutron',
1441+ group='neutron', perms=0700, force=False),
1442+ call('/etc/nova', owner='neutron',
1443+ group='neutron', perms=0700, force=False),
1444+ call('/var/lib/neutron', owner='neutron',
1445+ group='neutron', perms=0700, force=False),
1446+ call('/var/lib/neutron/lock', owner='neutron',
1447+ group='neutron', perms=0700, force=False),
1448+ call('/var/log/neutron', owner='neutron',
1449+ group='neutron', perms=0700, force=False),
1450+ ]
1451+ self.assertEquals(mkdir.call_args_list, expected)
1452+ expected = [
1453+ call('/var/log/neutron/bigswitch-agent.log', '', owner='neutron',
1454+ group='neutron', perms=0644),
1455+ call('/var/log/neutron/dhcp-agent.log', '', owner='neutron',
1456+ group='neutron', perms=0644),
1457+ call('/var/log/neutron/l3-agent.log', '', owner='neutron',
1458+ group='neutron', perms=0644),
1459+ call('/var/log/neutron/lbaas-agent.log', '', owner='neutron',
1460+ group='neutron', perms=0644),
1461+ call('/var/log/neutron/ibm-agent.log', '', owner='neutron',
1462+ group='neutron', perms=0644),
1463+ call('/var/log/neutron/linuxbridge-agent.log', '', owner='neutron',
1464+ group='neutron', perms=0644),
1465+ call('/var/log/neutron/metadata-agent.log', '', owner='neutron',
1466+ group='neutron', perms=0644),
1467+ call('/var/log/neutron/metering_agent.log', '', owner='neutron',
1468+ group='neutron', perms=0644),
1469+ call('/var/log/neutron/mlnx-agent.log', '', owner='neutron',
1470+ group='neutron', perms=0644),
1471+ call('/var/log/neutron/nec-agent.log', '', owner='neutron',
1472+ group='neutron', perms=0644),
1473+ call('/var/log/neutron/nvsd-agent.log', '', owner='neutron',
1474+ group='neutron', perms=0644),
1475+ call('/var/log/neutron/openflow-agent.log', '', owner='neutron',
1476+ group='neutron', perms=0644),
1477+ call('/var/log/neutron/openvswitch-agent.log', '', owner='neutron',
1478+ group='neutron', perms=0644),
1479+ call('/var/log/neutron/ovs-cleanup.log', '', owner='neutron',
1480+ group='neutron', perms=0644),
1481+ call('/var/log/neutron/ryu-agent.log', '', owner='neutron',
1482+ group='neutron', perms=0644),
1483+ call('/var/log/neutron/server.log', '', owner='neutron',
1484+ group='neutron', perms=0644),
1485+ call('/var/log/neutron/sriov-agent.log', '', owner='neutron',
1486+ group='neutron', perms=0644),
1487+ call('/var/log/neutron/vpn_agent.log', '', owner='neutron',
1488+ group='neutron', perms=0644),
1489+ ]
1490+ self.assertEquals(write_file.call_args_list, expected)
1491+
1492+ @patch.object(quantum_utils, 'git_src_dir')
1493+ @patch.object(quantum_utils, 'render')
1494+ @patch('os.path.join')
1495+ @patch('os.path.exists')
1496+ @patch('os.symlink')
1497+ @patch('shutil.rmtree')
1498+ @patch('shutil.copyfile')
1499+ @patch('shutil.copytree')
1500+ def test_git_post_install(self, copytree, copyfile, rmtree, symlink,
1501+ exists, join, render, git_src_dir):
1502+ projects_yaml = openstack_origin_git
1503+ join.return_value = 'joined-string'
1504+ quantum_utils.git_post_install(projects_yaml)
1505+ expected = [
1506+ call('joined-string', '/etc/neutron'),
1507+ call('joined-string', '/etc/neutron/plugins'),
1508+ call('joined-string', '/etc/neutron/rootwrap.d'),
1509+ ]
1510+ copytree.assert_has_calls(expected)
1511+ expected = [
1512+ call('/usr/local/bin/neutron-rootwrap',
1513+ '/usr/bin/neutron-rootwrap'),
1514+ ]
1515+ symlink.assert_has_calls(expected)
1516+ service_name = 'quantum-gateway'
1517+ user_name = 'neutron'
1518+ neutron_api_context = {
1519+ 'service_description': 'Neutron API server',
1520+ 'charm_name': 'neutron-api',
1521+ 'process_name': 'neutron-server',
1522+ }
1523+ neutron_dhcp_agent_context = {
1524+ 'service_description': 'Neutron DHCP Agent',
1525+ 'service_name': service_name,
1526+ 'process_name': 'neutron-dhcp-agent',
1527+ 'config_files': ['/etc/neutron/neutron.conf',
1528+ '/etc/neutron/dhcp_agent.ini'],
1529+ 'log_file': '/var/log/neutron/dhcp-agent.log',
1530+ }
1531+ neutron_l3_agent_context = {
1532+ 'service_description': 'Neutron L3 Agent',
1533+ 'service_name': service_name,
1534+ 'process_name': 'neutron-l3-agent',
1535+ 'config_files': ['/etc/neutron/neutron.conf',
1536+ '/etc/neutron/l3_agent.ini',
1537+ '/etc/neutron/fwaas_driver.ini'],
1538+ 'log_file': '/var/log/neutron/l3-agent.log',
1539+ }
1540+ neutron_lbaas_agent_context = {
1541+ 'service_description': 'Neutron LBaaS Agent',
1542+ 'service_name': service_name,
1543+ 'user_name': user_name,
1544+ 'start_dir': '/var/lib/neutron',
1545+ 'process_name': 'neutron-lbaas-agent',
1546+ 'executable_name': '/usr/local/bin/neutron-lbaas-agent',
1547+ 'config_files': ['/etc/neutron/neutron.conf',
1548+ '/etc/neutron/lbaas_agent.ini'],
1549+ 'log_file': '/var/log/neutron/lbaas-agent.log',
1550+ }
1551+ neutron_metadata_agent_context = {
1552+ 'service_description': 'Neutron Metadata Agent',
1553+ 'service_name': service_name,
1554+ 'user_name': user_name,
1555+ 'start_dir': '/var/lib/neutron',
1556+ 'process_name': 'neutron-metadata-agent',
1557+ 'executable_name': '/usr/local/bin/neutron-metadata-agent',
1558+ 'config_files': ['/etc/neutron/neutron.conf',
1559+ '/etc/neutron/metadata_agent.ini'],
1560+ 'log_file': '/var/log/neutron/metadata-agent.log',
1561+ }
1562+ neutron_metering_agent_context = {
1563+ 'service_description': 'Neutron Metering Agent',
1564+ 'service_name': service_name,
1565+ 'user_name': user_name,
1566+ 'start_dir': '/var/lib/neutron',
1567+ 'process_name': 'neutron-metering-agent',
1568+ 'executable_name': '/usr/local/bin/neutron-metering-agent',
1569+ 'config_files': ['/etc/neutron/neutron.conf',
1570+ '/etc/neutron/metering_agent.ini'],
1571+ 'log_file': '/var/log/neutron/metering-agent.log',
1572+ }
1573+ neutron_ovs_cleanup_context = {
1574+ 'service_description': 'Neutron OVS cleanup',
1575+ 'service_name': service_name,
1576+ 'process_name': 'neutron-ovs-cleanup',
1577+ 'config_file': '/etc/neutron/neutron.conf',
1578+ 'log_file': '/var/log/neutron/ovs-cleanup.log',
1579+ }
1580+ neutron_plugin_bigswitch_context = {
1581+ 'service_description': 'Neutron BigSwitch Plugin Agent',
1582+ 'service_name': service_name,
1583+ 'user_name': user_name,
1584+ 'start_dir': '/var/lib/neutron',
1585+ 'process_name': 'neutron-restproxy-agent',
1586+ 'executable_name': '/usr/local/bin/neutron-restproxy-agent',
1587+ 'config_files': ['/etc/neutron/neutron.conf',
1588+ '/etc/neutron/plugins/bigswitch/restproxy.ini'],
1589+ 'log_file': '/var/log/neutron/bigswitch-agent.log',
1590+ }
1591+ neutron_plugin_ibm_context = {
1592+ 'service_description': 'Neutron IBM SDN Plugin Agent',
1593+ 'service_name': service_name,
1594+ 'user_name': user_name,
1595+ 'start_dir': '/var/lib/neutron',
1596+ 'process_name': 'neutron-ibm-agent',
1597+ 'executable_name': '/usr/local/bin/neutron-ibm-agent',
1598+ 'config_files':
1599+ ['/etc/neutron/neutron.conf',
1600+ '/etc/neutron/plugins/ibm/sdnve_neutron_plugin.ini'],
1601+ 'log_file': '/var/log/neutron/ibm-agent.log',
1602+ }
1603+ neutron_plugin_linuxbridge_context = {
1604+ 'service_description': 'Neutron Linux Bridge Plugin Agent',
1605+ 'service_name': service_name,
1606+ 'user_name': user_name,
1607+ 'start_dir': '/var/lib/neutron',
1608+ 'process_name': 'neutron-linuxbridge-agent',
1609+ 'executable_name': '/usr/local/bin/neutron-linuxbridge-agent',
1610+ 'config_files': ['/etc/neutron/neutron.conf',
1611+ '/etc/neutron/plugins/ml2/ml2_conf.ini'],
1612+ 'log_file': '/var/log/neutron/linuxbridge-agent.log',
1613+ }
1614+ neutron_plugin_mlnx_context = {
1615+ 'service_description': 'Neutron MLNX Plugin Agent',
1616+ 'service_name': service_name,
1617+ 'user_name': user_name,
1618+ 'start_dir': '/var/lib/neutron',
1619+ 'process_name': 'neutron-mlnx-agent',
1620+ 'executable_name': '/usr/local/bin/neutron-mlnx-agent',
1621+ 'config_files': ['/etc/neutron/neutron.conf',
1622+ '/etc/neutron/plugins/mlnx/mlnx_conf.ini'],
1623+ 'log_file': '/var/log/neutron/mlnx-agent.log',
1624+ }
1625+ neutron_plugin_nec_context = {
1626+ 'service_description': 'Neutron NEC Plugin Agent',
1627+ 'service_name': service_name,
1628+ 'start_dir': '/var/lib/neutron',
1629+ 'process_name': 'neutron-nec-agent',
1630+ 'executable_name': '/usr/local/bin/neutron-nec-agent',
1631+ 'config_files': ['/etc/neutron/neutron.conf',
1632+ '/etc/neutron/plugins/nec/nec.ini'],
1633+ 'log_file': '/var/log/neutron/nec-agent.log',
1634+ }
1635+ neutron_plugin_oneconvergence_context = {
1636+ 'service_description': 'Neutron One Convergence Plugin Agent',
1637+ 'service_name': service_name,
1638+ 'user_name': user_name,
1639+ 'start_dir': '/var/lib/neutron',
1640+ 'process_name': 'neutron-nvsd-agent',
1641+ 'executable_name': '/usr/local/bin/neutron-nvsd-agent',
1642+ 'config_files': ['/etc/neutron/neutron.conf',
1643+ '/etc/neutron/plugins/oneconvergence/nvsdplugin.ini'],
1644+ 'log_file': '/var/log/neutron/nvsd-agent.log',
1645+ }
1646+ neutron_plugin_openflow_context = {
1647+ 'service_description': 'Neutron OpenFlow Plugin Agent',
1648+ 'service_name': service_name,
1649+ 'user_name': user_name,
1650+ 'start_dir': '/var/lib/neutron',
1651+ 'process_name': 'neutron-ofagent-agent',
1652+ 'executable_name': '/usr/local/bin/neutron-ofagent-agent',
1653+ 'config_files': ['/etc/neutron/neutron.conf',
1654+ '/etc/neutron/plugins/ml2/ml2_conf_ofa.ini'],
1655+ 'log_file': '/var/log/neutron/openflow-agent.log',
1656+ }
1657+ neutron_plugin_openvswitch_context = {
1658+ 'service_description': 'Neutron OpenvSwitch Plugin Agent',
1659+ 'service_name': service_name,
1660+ 'user_name': user_name,
1661+ 'start_dir': '/var/lib/neutron',
1662+ 'process_name': 'neutron-openvswitch-agent',
1663+ 'executable_name': '/usr/local/bin/neutron-openvswitch-agent',
1664+ 'config_files': ['/etc/neutron/neutron.conf',
1665+ '/etc/neutron/plugins/ml2/ml2_conf.ini'],
1666+ 'log_file': '/var/log/neutron/openvswitch-agent.log',
1667+ }
1668+ neutron_plugin_ryu_context = {
1669+ 'service_description': 'Neutron RYU Plugin Agent',
1670+ 'service_name': service_name,
1671+ 'user_name': user_name,
1672+ 'start_dir': '/var/lib/neutron',
1673+ 'process_name': 'neutron-ryu-agent',
1674+ 'executable_name': '/usr/local/bin/neutron-ryu-agent',
1675+ 'config_files': ['/etc/neutron/neutron.conf',
1676+ '/etc/neutron/plugins/ryu/ryu.ini'],
1677+ 'log_file': '/var/log/neutron/ryu-agent.log',
1678+ }
1679+ neutron_plugin_sriov_context = {
1680+ 'service_description': 'Neutron SRIOV SDN Plugin Agent',
1681+ 'service_name': service_name,
1682+ 'user_name': user_name,
1683+ 'start_dir': '/var/lib/neutron',
1684+ 'process_name': 'neutron-sriov-nic-agent',
1685+ 'executable_name': '/usr/local/bin/neutron-sriov-nic-agent',
1686+ 'config_files': ['/etc/neutron/neutron.conf',
1687+ '/etc/neutron/plugins/ml2/ml2_conf_sriov'],
1688+ 'log_file': '/var/log/neutron/sriov-agent.log',
1689+ }
1690+ neutron_api_context = {
1691+ 'service_description': 'Neutron API server',
1692+ 'service_name': service_name,
1693+ 'process_name': 'neutron-server',
1694+ }
1695+ neutron_vpn_agent_context = {
1696+ 'service_description': 'Neutron VPN Agent',
1697+ 'service_name': service_name,
1698+ 'process_name': 'neutron-vpn-agent',
1699+ 'config_files': ['/etc/neutron/neutron.conf',
1700+ '/etc/neutron/vpn_agent.ini',
1701+ '/etc/neutron/l3_agent.ini',
1702+ '/etc/neutron/fwaas_driver.ini'],
1703+ 'log_file': '/var/log/neutron/vpn_agent.log',
1704+ }
1705+ expected = [
1706+ call('git/neutron_sudoers',
1707+ '/etc/sudoers.d/neutron_sudoers',
1708+ {}, perms=0o440),
1709+ call('git/cron.d/neutron-dhcp-agent-netns-cleanup',
1710+ '/etc/cron.d/neutron-dhcp-agent-netns-cleanup',
1711+ {}, perms=0o755),
1712+ call('git/cron.d/neutron-l3-agent-netns-cleanup',
1713+ '/etc/cron.d/neutron-l3-agent-netns-cleanup',
1714+ {}, perms=0o755),
1715+ call('git/cron.d/neutron-lbaas-agent-netns-cleanup',
1716+ '/etc/cron.d/neutron-lbaas-agent-netns-cleanup',
1717+ {}, perms=0o755),
1718+ call('git/upstart/neutron-agent.upstart',
1719+ '/etc/init/neutron-dhcp-agent.conf',
1720+ neutron_dhcp_agent_context, perms=0o644),
1721+ call('git/upstart/neutron-agent.upstart',
1722+ '/etc/init/neutron-l3-agent.conf',
1723+ neutron_l3_agent_context, perms=0o644),
1724+ call('git.upstart',
1725+ '/etc/init/neutron-lbaas-agent.conf',
1726+ neutron_lbaas_agent_context, perms=0o644,
1727+ templates_dir='joined-string'),
1728+ call('git.upstart',
1729+ '/etc/init/neutron-metadata-agent.conf',
1730+ neutron_metadata_agent_context, perms=0o644,
1731+ templates_dir='joined-string'),
1732+ call('git.upstart',
1733+ '/etc/init/neutron-metering-agent.conf',
1734+ neutron_metering_agent_context, perms=0o644,
1735+ templates_dir='joined-string'),
1736+ call('git.upstart',
1737+ '/etc/init/neutron-ovs-cleanup.conf',
1738+ neutron_ovs_cleanup_context, perms=0o644,
1739+ templates_dir='joined-string'),
1740+ call('git.upstart',
1741+ '/etc/init/neutron-plugin-bigswitch-agent.conf',
1742+ neutron_plugin_bigswitch_context, perms=0o644,
1743+ templates_dir='joined-string'),
1744+ call('git.upstart',
1745+ '/etc/init/neutron-plugin-ibm-agent.conf',
1746+ neutron_plugin_ibm_context, perms=0o644,
1747+ templates_dir='joined-string'),
1748+ call('git.upstart',
1749+ '/etc/init/neutron-plugin-linuxbridge-agent.conf',
1750+ neutron_plugin_linuxbridge_context, perms=0o644,
1751+ templates_dir='joined-string'),
1752+ call('git.upstart',
1753+ '/etc/init/neutron-plugin-mlnx-agent.conf',
1754+ neutron_plugin_mlnx_context, perms=0o644,
1755+ templates_dir='joined-string'),
1756+ call('git.upstart',
1757+ '/etc/init/neutron-plugin-nec-agent.conf',
1758+ neutron_plugin_nec_context, perms=0o644,
1759+ templates_dir='joined-string'),
1760+ call('git.upstart',
1761+ '/etc/init/neutron-plugin-oneconvergence-agent.conf',
1762+ neutron_plugin_oneconvergence_context, perms=0o644,
1763+ templates_dir='joined-string'),
1764+ call('git.upstart',
1765+ '/etc/init/neutron-plugin-openflow-agent.conf',
1766+ neutron_plugin_openflow_context, perms=0o644,
1767+ templates_dir='joined-string'),
1768+ call('git.upstart',
1769+ '/etc/init/neutron-plugin-openvswitch-agent.conf',
1770+ neutron_plugin_openvswitch_context, perms=0o644,
1771+ templates_dir='joined-string'),
1772+ call('git.upstart',
1773+ '/etc/init/neutron-plugin-ryu-agent.conf',
1774+ neutron_plugin_ryu_context, perms=0o644,
1775+ templates_dir='joined-string'),
1776+ call('git.upstart',
1777+ '/etc/init/neutron-plugin-sriov-agent.conf',
1778+ neutron_plugin_sriov_context, perms=0o644,
1779+ templates_dir='joined-string'),
1780+ call('git/upstart/neutron-server.upstart',
1781+ '/etc/init/neutron-server.conf',
1782+ neutron_api_context, perms=0o644),
1783+ call('git/upstart/neutron-agent.upstart',
1784+ '/etc/init/neutron-vpn-agent.conf',
1785+ neutron_vpn_agent_context, perms=0o644),
1786+ ]
1787+ self.assertEquals(render.call_args_list, expected)

Subscribers

People subscribed via source and target branches