Merge lp:~plumgrid-team/charms/trusty/neutron-api-plumgrid/trunk into lp:charms/trusty/neutron-api-plumgrid
- Trusty Tahr (14.04)
- trunk
- Merge into trunk
Status: | Superseded | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~plumgrid-team/charms/trusty/neutron-api-plumgrid/trunk | ||||
Merge into: | lp:charms/trusty/neutron-api-plumgrid | ||||
Diff against target: |
471 lines (+240/-43) (has conflicts) 10 files modified
Makefile (+1/-1) README.md (+0/-1) config.yaml (+10/-0) hooks/neutron_plumgrid_hooks.py (+33/-11) hooks/neutron_plumgrid_utils.py (+54/-4) templates/kilo/plumlib.ini (+4/-0) tests/files/neutron-api-plumgrid-dense.yaml (+133/-0) tests/tests.yaml (+3/-0) unit_tests/test_neutron_plumgrid_plugin_hooks.py (+2/-21) unit_tests/test_neutron_plumgrid_plugin_utils.py (+0/-5) Conflict adding file tests/files/neutron-api-plumgrid-dense.yaml. Moved existing file to tests/files/neutron-api-plumgrid-dense.yaml.moved. Conflict adding file tests/tests.yaml. Moved existing file to tests/tests.yaml.moved. |
||||
To merge this branch: | bzr merge lp:~plumgrid-team/charms/trusty/neutron-api-plumgrid/trunk | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Butler | Pending | ||
Review via email: mp+288034@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-05-18.
Commit message
Description of the change
Needs sync
Bilal Baqar (bbaqar) wrote : | # |
- 13. By Bilal Baqar
-
1. Updating plumlib.ini
2. Removed package removal from stop hook - 14. By Bilal Baqar
-
Improved config-changed hook to perform steps according to the config changed
- 15. By Bilal Baqar
-
db-migration for specific networking-plumgrid versions
- 16. By Bilal Baqar
-
Adding status messages in charms - Ticket:[SOL-949]
- 17. By Bilal Baqar
-
Revision update
- 18. By Bilal Baqar
-
Updated readme
- 19. By Bilal Baqar
-
Merge: Liberty/Mitaka support
- 20. By Bilal Baqar
-
Merge: Mitaka support added
- L2 Vtep and ECMP support added
- pip proxy option added
- removed unused charmhelpers modules
- synced latest charmhelpers modules
- updated charm-helpers-sync.yaml
- added connected type config
- getting pg vip and creds from director relation - 21. By Bilal Baqar
-
user-domain-name config added
configure-pg-sources function added - 22. By Junaid Ali
-
Resynced charm-helpers
- 23. By Junaid Ali
-
Changes:
Added config project_domain_name in plumlib.ini for keystone version v3.Ticket: [SOL-1105]
Unmerged revisions
Preview Diff
1 | === modified file 'Makefile' |
2 | --- Makefile 2015-08-24 16:27:30 +0000 |
3 | +++ Makefile 2016-04-08 15:23:08 +0000 |
4 | @@ -7,7 +7,7 @@ |
5 | netaddr jinja2 |
6 | |
7 | lint: virtualenv |
8 | - .venv/bin/flake8 --exclude hooks/charmhelpers hooks unit_tests tests |
9 | + .venv/bin/flake8 --exclude hooks/charmhelpers hooks unit_tests tests --ignore E402 |
10 | @charm proof |
11 | |
12 | unit_test: virtualenv |
13 | |
14 | === modified file 'README.md' |
15 | --- README.md 2015-09-01 02:50:53 +0000 |
16 | +++ README.md 2016-04-08 15:23:08 +0000 |
17 | @@ -44,4 +44,3 @@ |
18 | # Contact Information |
19 | |
20 | Bilal Baqar <bbaqar@plumgrid.com> |
21 | -Bilal Ahmad <bilal@plumgrid.com> |
22 | |
23 | === modified file 'config.yaml' |
24 | --- config.yaml 2015-07-29 18:35:16 +0000 |
25 | +++ config.yaml 2016-04-08 15:23:08 +0000 |
26 | @@ -11,3 +11,13 @@ |
27 | default: null |
28 | type: string |
29 | description: Provide the respective keys of the install sources |
30 | + plumgrid-build: |
31 | + default: 'latest' |
32 | + type: string |
33 | + description: | |
34 | + Provide the build version of PLUMgrid packages that needs to be installed |
35 | + networking-plumgrid-version: |
36 | + default: null |
37 | + type: string |
38 | + description: | |
39 | + Provide the version of networking-plumgrid package that needs to be installed |
40 | |
41 | === modified file 'hooks/neutron_plumgrid_hooks.py' |
42 | --- hooks/neutron_plumgrid_hooks.py 2015-08-09 15:32:44 +0000 |
43 | +++ hooks/neutron_plumgrid_hooks.py 2016-04-08 15:23:08 +0000 |
44 | @@ -6,22 +6,24 @@ |
45 | # in this file. |
46 | |
47 | import sys |
48 | - |
49 | +from charmhelpers.core.host import service_running |
50 | from charmhelpers.core.hookenv import ( |
51 | Hooks, |
52 | UnregisteredHookError, |
53 | log, |
54 | + config, |
55 | + status_set |
56 | ) |
57 | |
58 | from charmhelpers.core.host import ( |
59 | restart_on_change, |
60 | + service_restart |
61 | ) |
62 | |
63 | from charmhelpers.fetch import ( |
64 | apt_install, |
65 | apt_update, |
66 | configure_sources, |
67 | - apt_purge, |
68 | ) |
69 | |
70 | from neutron_plumgrid_utils import ( |
71 | @@ -40,23 +42,37 @@ |
72 | ''' |
73 | Install hook is run when the charm is first deployed on a node. |
74 | ''' |
75 | + status_set('maintenance', 'Executing pre-install') |
76 | configure_sources() |
77 | + status_set('maintenance', 'Installing apt packages') |
78 | apt_update() |
79 | - apt_install(determine_packages(), options=['--force-yes'], fatal=True) |
80 | + pkgs = determine_packages() |
81 | + for pkg in pkgs: |
82 | + apt_install(pkg, options=['--force-yes'], fatal=True) |
83 | ensure_files() |
84 | |
85 | |
86 | @hooks.hook('config-changed') |
87 | +@restart_on_change(restart_map()) |
88 | def config_changed(): |
89 | ''' |
90 | This hook is run when a config parameter is changed. |
91 | It also runs on node reboot. |
92 | ''' |
93 | - stop() |
94 | - configure_sources() |
95 | - apt_update() |
96 | - apt_install(determine_packages(), options=['--force-yes'], fatal=True) |
97 | - ensure_files() |
98 | + charm_config = config() |
99 | + if (charm_config.changed('install_sources') or |
100 | + charm_config.changed('plumgrid-build') or |
101 | + charm_config.changed('install_keys')): |
102 | + status_set('maintenance', 'Upgrading apt packages') |
103 | + configure_sources() |
104 | + apt_update() |
105 | + pkgs = determine_packages() |
106 | + for pkg in pkgs: |
107 | + apt_install(pkg, options=['--force-yes'], fatal=True) |
108 | + service_restart('neutron-server') |
109 | + if charm_config.changed('networking-plumgrid-version'): |
110 | + ensure_files() |
111 | + service_restart('neutron-server') |
112 | CONFIGS.write_all() |
113 | |
114 | |
115 | @@ -78,9 +94,15 @@ |
116 | ''' |
117 | This hook is run when the charm is destroyed. |
118 | ''' |
119 | - pkgs = determine_packages() |
120 | - for pkg in pkgs: |
121 | - apt_purge(pkg, fatal=False) |
122 | + log('Charm stopping without removal of packages') |
123 | + |
124 | + |
125 | +@hooks.hook('update-status') |
126 | +def update_status(): |
127 | + if service_running('neutron-server'): |
128 | + status_set('active', 'Unit is ready') |
129 | + else: |
130 | + status_set('blocked', 'neutron server not running') |
131 | |
132 | |
133 | def main(): |
134 | |
135 | === modified file 'hooks/neutron_plumgrid_utils.py' |
136 | --- hooks/neutron_plumgrid_utils.py 2015-07-29 18:35:16 +0000 |
137 | +++ hooks/neutron_plumgrid_utils.py 2016-04-08 15:23:08 +0000 |
138 | @@ -8,11 +8,17 @@ |
139 | import os |
140 | from charmhelpers.contrib.openstack import templating |
141 | from charmhelpers.contrib.python.packages import pip_install |
142 | - |
143 | +from charmhelpers.fetch import ( |
144 | + apt_cache |
145 | +) |
146 | +from charmhelpers.core.hookenv import ( |
147 | + config, |
148 | + is_leader |
149 | +) |
150 | from charmhelpers.contrib.openstack.utils import ( |
151 | os_release, |
152 | ) |
153 | - |
154 | +import subprocess |
155 | import neutron_plumgrid_context |
156 | |
157 | TEMPLATES = 'templates/' |
158 | @@ -37,13 +43,32 @@ |
159 | }), |
160 | ]) |
161 | |
162 | +NETWORKING_PLUMGRID_VERSION = OrderedDict([ |
163 | + ('kilo', '2015.1.1.1'), |
164 | + ('liberty', '2015.2.1.1'), |
165 | +]) |
166 | + |
167 | |
168 | def determine_packages(): |
169 | ''' |
170 | Returns list of packages required to be installed alongside neutron to |
171 | enable PLUMgrid in Openstack. |
172 | ''' |
173 | - return list(set(PG_PACKAGES)) |
174 | + pkgs = [] |
175 | + tag = config('plumgrid-build') |
176 | + for pkg in PG_PACKAGES: |
177 | + if tag == 'latest': |
178 | + pkgs.append(pkg) |
179 | + else: |
180 | + if tag in [i.ver_str for i in apt_cache()[pkg].version_list]: |
181 | + pkgs.append('%s=%s' % (pkg, tag)) |
182 | + else: |
183 | + error_msg = \ |
184 | + "Build version '%s' for package '%s' not available" \ |
185 | + % (tag, pkg) |
186 | + raise ValueError(error_msg) |
187 | + # return list(set(PG_PACKAGES)) |
188 | + return pkgs |
189 | |
190 | |
191 | def resource_map(): |
192 | @@ -61,6 +86,9 @@ |
193 | the context required for all templates of this charm. |
194 | ''' |
195 | release = release or os_release('neutron-server', base='kilo') |
196 | + if release < 'kilo': |
197 | + raise ValueError('OpenStack %s release not supported' % release) |
198 | + |
199 | configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, |
200 | openstack_release=release) |
201 | for cfg, rscs in resource_map().iteritems(): |
202 | @@ -82,5 +110,27 @@ |
203 | ''' |
204 | Ensures PLUMgrid specific files exist before templates are written. |
205 | ''' |
206 | - pip_install('networking-plumgrid', fatal=True) |
207 | + install_networking_plumgrid() |
208 | os.chmod('/etc/sudoers.d/neutron_sudoers', 0o440) |
209 | + |
210 | + |
211 | +def install_networking_plumgrid(): |
212 | + ''' |
213 | + Installs networking-plumgrid package |
214 | + ''' |
215 | + release = os_release('neutron-server', base='kilo') |
216 | + if config('networking-plumgrid-version') is None: |
217 | + package_version = NETWORKING_PLUMGRID_VERSION[release] |
218 | + else: |
219 | + package_version = config('networking-plumgrid-version') |
220 | + package_name = 'networking-plumgrid==%s' % package_version |
221 | + pip_install(package_name, fatal=True) |
222 | + if is_leader() and package_version != '2015.1.1.1': |
223 | + migrate_neutron_db() |
224 | + |
225 | + |
226 | +def migrate_neutron_db(): |
227 | + release = os_release('neutron-common', base='kilo') |
228 | + cmd = [('plumgrid-db-manage' if release == 'kilo' |
229 | + else 'neutron-db-manage'), 'upgrade', 'heads'] |
230 | + subprocess.check_output(cmd) |
231 | |
232 | === added symlink 'hooks/update-status' |
233 | === target is u'neutron_plumgrid_hooks.py' |
234 | === modified file 'templates/kilo/plumlib.ini' |
235 | --- templates/kilo/plumlib.ini 2015-08-09 15:32:44 +0000 |
236 | +++ templates/kilo/plumlib.ini 2016-04-08 15:23:08 +0000 |
237 | @@ -46,10 +46,14 @@ |
238 | api_key = 162-22O8BEYWO0DQGIM |
239 | secret_key = 171de423af844bad400a98ea5b9fa56d |
240 | |
241 | +[ConnectorType] |
242 | +connector_type = distributed |
243 | + |
244 | {% if admin_user -%} |
245 | [keystone_authtoken] |
246 | admin_user = {{ admin_user }} |
247 | admin_password = {{ admin_password }} |
248 | admin_tenant_name = {{ admin_tenant_name }} |
249 | auth_uri = {{ service_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0/ |
250 | +identity_version = v2.0 |
251 | {% endif -%} |
252 | |
253 | === added file 'tests/files/neutron-api-plumgrid-dense.yaml' |
254 | --- tests/files/neutron-api-plumgrid-dense.yaml 1970-01-01 00:00:00 +0000 |
255 | +++ tests/files/neutron-api-plumgrid-dense.yaml 2016-04-08 15:23:08 +0000 |
256 | @@ -0,0 +1,133 @@ |
257 | +test: |
258 | + series: 'trusty' |
259 | + relations: |
260 | + - - mysql |
261 | + - keystone |
262 | + - - nova-cloud-controller |
263 | + - mysql |
264 | + - - nova-cloud-controller |
265 | + - rabbitmq-server |
266 | + - - nova-cloud-controller |
267 | + - glance |
268 | + - - nova-cloud-controller |
269 | + - keystone |
270 | + - - nova-compute |
271 | + - nova-cloud-controller |
272 | + - - nova-compute |
273 | + - mysql |
274 | + - - nova-compute |
275 | + - rabbitmq-server |
276 | + - - nova-compute |
277 | + - glance |
278 | + - - glance |
279 | + - mysql |
280 | + - - glance |
281 | + - keystone |
282 | + - - glance |
283 | + - cinder |
284 | + - - mysql |
285 | + - cinder |
286 | + - - cinder |
287 | + - rabbitmq-server |
288 | + - - cinder |
289 | + - nova-cloud-controller |
290 | + - - cinder |
291 | + - keystone |
292 | + - - openstack-dashboard |
293 | + - keystone |
294 | + - - neutron-api |
295 | + - mysql |
296 | + - - neutron-api |
297 | + - keystone |
298 | + - - neutron-api |
299 | + - rabbitmq-server |
300 | + - - neutron-api |
301 | + - nova-cloud-controller |
302 | + - - neutron-api |
303 | + - neutron-api-plumgrid |
304 | + - - neutron-api-plumgrid |
305 | + - plumgrid-edge |
306 | + - - plumgrid-director |
307 | + - plumgrid-edge |
308 | + - - nova-compute |
309 | + - plumgrid-edge |
310 | + - - plumgrid-director |
311 | + - plumgrid-gateway |
312 | + services: |
313 | + mysql: |
314 | + charm: cs:trusty/mysql |
315 | + num_units: 1 |
316 | + to: 'lxc:plumgrid-director=0' |
317 | + rabbitmq-server: |
318 | + charm: cs:trusty/rabbitmq-server |
319 | + num_units: 1 |
320 | + to: 'lxc:plumgrid-director=0' |
321 | + keystone: |
322 | + charm: cs:trusty/keystone |
323 | + num_units: 1 |
324 | + options: |
325 | + admin-password: plumgrid |
326 | + openstack-origin: cloud:trusty-kilo |
327 | + to: 'lxc:plumgrid-director=0' |
328 | + nova-cloud-controller: |
329 | + charm: cs:trusty/nova-cloud-controller |
330 | + num_units: 1 |
331 | + options: |
332 | + console-access-protocol: novnc |
333 | + network-manager: Neutron |
334 | + openstack-origin: cloud:trusty-kilo |
335 | + quantum-security-groups: 'yes' |
336 | + to: 'lxc:plumgrid-director=0' |
337 | + glance: |
338 | + charm: cs:trusty/glance |
339 | + num_units: 1 |
340 | + options: |
341 | + openstack-origin: cloud:trusty-kilo |
342 | + to: 'lxc:plumgrid-director=0' |
343 | + openstack-dashboard: |
344 | + charm: cs:trusty/openstack-dashboard |
345 | + num_units: 1 |
346 | + options: |
347 | + openstack-origin: cloud:trusty-kilo |
348 | + to: 'lxc:plumgrid-director=0' |
349 | + cinder: |
350 | + charm: cs:trusty/cinder |
351 | + num_units: 1 |
352 | + options: |
353 | + openstack-origin: cloud:trusty-kilo |
354 | + to: 'lxc:plumgrid-director=0' |
355 | + neutron-api: |
356 | + charm: cs:~plumgrid-team/trusty/neutron-api |
357 | + num_units: 1 |
358 | + options: |
359 | + neutron-plugin: plumgrid |
360 | + neutron-security-groups: false |
361 | + openstack-origin: cloud:trusty-kilo |
362 | + plumgrid-password: plumgrid |
363 | + plumgrid-username: plumgrid |
364 | + plumgrid-virtual-ip: 192.168.100.250 |
365 | + to: 'lxc:plumgrid-director=0' |
366 | + neutron-api-plumgrid: |
367 | + charm: cs:~plumgrid-team/trusty/neutron-api-plumgrid |
368 | + options: |
369 | + enable-metadata: True |
370 | + plumgrid-director: |
371 | + charm: cs:~plumgrid-team/trusty/plumgrid-director |
372 | + num_units: 1 |
373 | + constraints: "root-disk=30000 cpu-cores=8 mem=8G" |
374 | + options: |
375 | + plumgrid-virtual-ip: 192.168.100.250 |
376 | + nova-compute: |
377 | + charm: cs:~plumgrid-team/trusty/nova-compute |
378 | + num_units: 1 |
379 | + options: |
380 | + enable-live-migration: true |
381 | + enable-resize: true |
382 | + migration-auth-type: ssh |
383 | + openstack-origin: cloud:trusty-kilo |
384 | + to: '0' |
385 | + plumgrid-edge: |
386 | + charm: cs:~plumgrid-team/trusty/plumgrid-edge |
387 | + plumgrid-gateway: |
388 | + charm: cs:~plumgrid-team/trusty/plumgrid-gateway |
389 | + num_units: 1 |
390 | |
391 | === renamed file 'tests/files/neutron-api-plumgrid-dense.yaml' => 'tests/files/neutron-api-plumgrid-dense.yaml.moved' |
392 | === added file 'tests/tests.yaml' |
393 | --- tests/tests.yaml 1970-01-01 00:00:00 +0000 |
394 | +++ tests/tests.yaml 2016-04-08 15:23:08 +0000 |
395 | @@ -0,0 +1,3 @@ |
396 | +makefile: |
397 | + - lint |
398 | + |
399 | |
400 | === renamed file 'tests/tests.yaml' => 'tests/tests.yaml.moved' |
401 | === modified file 'unit_tests/test_neutron_plumgrid_plugin_hooks.py' |
402 | --- unit_tests/test_neutron_plumgrid_plugin_hooks.py 2015-08-09 15:32:44 +0000 |
403 | +++ unit_tests/test_neutron_plumgrid_plugin_hooks.py 2016-04-08 15:23:08 +0000 |
404 | @@ -19,11 +19,11 @@ |
405 | TO_PATCH = [ |
406 | 'configure_sources', |
407 | 'apt_update', |
408 | - 'apt_purge', |
409 | 'apt_install', |
410 | 'CONFIGS', |
411 | 'ensure_files', |
412 | 'stop', |
413 | + 'determine_packages', |
414 | ] |
415 | NEUTRON_CONF_DIR = "/etc/neutron" |
416 | |
417 | @@ -42,6 +42,7 @@ |
418 | |
419 | def test_install_hook(self): |
420 | _pkgs = ['plumgrid-pythonlib'] |
421 | + self.determine_packages.return_value = [_pkgs] |
422 | self._call_hook('install') |
423 | self.configure_sources.assert_called_with() |
424 | self.apt_update.assert_called_with() |
425 | @@ -51,19 +52,6 @@ |
426 | ]) |
427 | self.ensure_files.assert_called_with() |
428 | |
429 | - def test_config_changed_hook(self): |
430 | - _pkgs = ['plumgrid-pythonlib'] |
431 | - self._call_hook('config-changed') |
432 | - self.stop.assert_called_with() |
433 | - self.configure_sources.assert_called_with() |
434 | - self.apt_update.assert_called_with() |
435 | - self.apt_install.assert_has_calls([ |
436 | - call(_pkgs, fatal=True, |
437 | - options=['--force-yes']), |
438 | - ]) |
439 | - self.ensure_files.assert_called_with() |
440 | - self.CONFIGS.write_all.assert_called_with() |
441 | - |
442 | def test_neutron_api_joined(self): |
443 | self._call_hook('neutron-plugin-api-relation-joined') |
444 | self.ensure_files.assert_called_with() |
445 | @@ -73,10 +61,3 @@ |
446 | self._call_hook('container-relation-changed') |
447 | self.ensure_files.assert_called_with() |
448 | self.CONFIGS.write_all.assert_called_with() |
449 | - |
450 | - def test_stop(self): |
451 | - _pkgs = 'plumgrid-pythonlib' |
452 | - self._call_hook('stop') |
453 | - self.apt_purge.assert_has_calls([ |
454 | - call(_pkgs, fatal=False) |
455 | - ]) |
456 | |
457 | === modified file 'unit_tests/test_neutron_plumgrid_plugin_utils.py' |
458 | --- unit_tests/test_neutron_plumgrid_plugin_utils.py 2015-07-29 18:35:16 +0000 |
459 | +++ unit_tests/test_neutron_plumgrid_plugin_utils.py 2016-04-08 15:23:08 +0000 |
460 | @@ -36,11 +36,6 @@ |
461 | # Reset cached cache |
462 | hookenv.cache = {} |
463 | |
464 | - def test_determine_packages(self): |
465 | - pkg_list = nutils.determine_packages() |
466 | - expect = ['plumgrid-pythonlib'] |
467 | - self.assertItemsEqual(pkg_list, expect) |
468 | - |
469 | def test_register_configs(self): |
470 | class _mock_OSConfigRenderer(): |
471 | def __init__(self, templates_dir=None, openstack_release=None): |
tests/files/ plumgrid- edge-dense. yaml and tests/tests.yaml in both branches are identical. Dont know the reason for the conflict. Please resolve it before merging.