Merge lp:~james-page/charms/trusty/neutron-api/lp1531102 into lp:~openstack-charmers-archive/charms/trusty/neutron-api/next

Proposed by James Page on 2016-01-05
Status: Merged
Merged at revision: 161
Proposed branch: lp:~james-page/charms/trusty/neutron-api/lp1531102
Merge into: lp:~openstack-charmers-archive/charms/trusty/neutron-api/next
Diff against target: 166 lines (+95/-25)
2 files modified
hooks/charmhelpers/contrib/openstack/utils.py (+27/-25)
hooks/charmhelpers/core/kernel.py (+68/-0)
To merge this branch: bzr merge lp:~james-page/charms/trusty/neutron-api/lp1531102
Reviewer Review Type Date Requested Status
Liam Young 2016-01-05 Approve on 2016-01-06
Review via email: mp+281609@code.launchpad.net

Commit message

Resync helpers

Description of the change

Resync helpers

To post a comment you must log in.

charm_lint_check #16586 neutron-api-next for james-page mp281609
    LINT OK: passed

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

charm_unit_test #15489 neutron-api-next for james-page mp281609
    UNIT OK: passed

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

charm_amulet_test #8509 neutron-api-next for james-page mp281609
    AMULET OK: passed

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

Liam Young (gnuoy) wrote :

Approve

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
2--- hooks/charmhelpers/contrib/openstack/utils.py 2016-01-04 21:28:17 +0000
3+++ hooks/charmhelpers/contrib/openstack/utils.py 2016-01-05 11:34:38 +0000
4@@ -131,40 +131,40 @@
5 # >= Liberty version->codename mapping
6 PACKAGE_CODENAMES = {
7 'nova-common': OrderedDict([
8- ('12.0.0', 'liberty'),
9- ('13.0.0', 'mitaka'),
10+ ('12.0', 'liberty'),
11+ ('13.0', 'mitaka'),
12 ]),
13 'neutron-common': OrderedDict([
14- ('7.0.0', 'liberty'),
15- ('8.0.0', 'mitaka'),
16+ ('7.0', 'liberty'),
17+ ('8.0', 'mitaka'),
18 ]),
19 'cinder-common': OrderedDict([
20- ('7.0.0', 'liberty'),
21- ('8.0.0', 'mitaka'),
22+ ('7.0', 'liberty'),
23+ ('8.0', 'mitaka'),
24 ]),
25 'keystone': OrderedDict([
26- ('8.0.0', 'liberty'),
27- ('9.0.0', 'mitaka'),
28+ ('8.0', 'liberty'),
29+ ('9.0', 'mitaka'),
30 ]),
31 'horizon-common': OrderedDict([
32- ('8.0.0', 'liberty'),
33- ('9.0.0', 'mitaka'),
34+ ('8.0', 'liberty'),
35+ ('9.0', 'mitaka'),
36 ]),
37 'ceilometer-common': OrderedDict([
38- ('5.0.0', 'liberty'),
39- ('6.0.0', 'mitaka'),
40+ ('5.0', 'liberty'),
41+ ('6.0', 'mitaka'),
42 ]),
43 'heat-common': OrderedDict([
44- ('5.0.0', 'liberty'),
45- ('6.0.0', 'mitaka'),
46+ ('5.0', 'liberty'),
47+ ('6.0', 'mitaka'),
48 ]),
49 'glance-common': OrderedDict([
50- ('11.0.0', 'liberty'),
51- ('12.0.0', 'mitaka'),
52+ ('11.0', 'liberty'),
53+ ('12.0', 'mitaka'),
54 ]),
55 'openstack-dashboard': OrderedDict([
56- ('8.0.0', 'liberty'),
57- ('9.0.0', 'mitaka'),
58+ ('8.0', 'liberty'),
59+ ('9.0', 'mitaka'),
60 ]),
61 }
62
63@@ -251,7 +251,14 @@
64 error_out(e)
65
66 vers = apt.upstream_version(pkg.current_ver.ver_str)
67- match = re.match('^(\d+)\.(\d+)\.(\d+)', vers)
68+ if 'swift' in pkg.name:
69+ # Fully x.y.z match for swift versions
70+ match = re.match('^(\d+)\.(\d+)\.(\d+)', vers)
71+ else:
72+ # x.y match only for 20XX.X
73+ # and ignore patch level for other packages
74+ match = re.match('^(\d+)\.(\d+)', vers)
75+
76 if match:
77 vers = match.group(0)
78
79@@ -263,13 +270,8 @@
80 # < Liberty co-ordinated project versions
81 try:
82 if 'swift' in pkg.name:
83- swift_vers = vers[:5]
84- if swift_vers not in SWIFT_CODENAMES:
85- # Deal with 1.10.0 upward
86- swift_vers = vers[:6]
87- return SWIFT_CODENAMES[swift_vers]
88+ return SWIFT_CODENAMES[vers]
89 else:
90- vers = vers[:6]
91 return OPENSTACK_CODENAMES[vers]
92 except KeyError:
93 if not fatal:
94
95=== added file 'hooks/charmhelpers/core/kernel.py'
96--- hooks/charmhelpers/core/kernel.py 1970-01-01 00:00:00 +0000
97+++ hooks/charmhelpers/core/kernel.py 2016-01-05 11:34:38 +0000
98@@ -0,0 +1,68 @@
99+#!/usr/bin/env python
100+# -*- coding: utf-8 -*-
101+
102+# Copyright 2014-2015 Canonical Limited.
103+#
104+# This file is part of charm-helpers.
105+#
106+# charm-helpers is free software: you can redistribute it and/or modify
107+# it under the terms of the GNU Lesser General Public License version 3 as
108+# published by the Free Software Foundation.
109+#
110+# charm-helpers is distributed in the hope that it will be useful,
111+# but WITHOUT ANY WARRANTY; without even the implied warranty of
112+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
113+# GNU Lesser General Public License for more details.
114+#
115+# You should have received a copy of the GNU Lesser General Public License
116+# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
117+
118+__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
119+
120+from charmhelpers.core.hookenv import (
121+ log,
122+ INFO
123+)
124+
125+from subprocess import check_call, check_output
126+import re
127+
128+
129+def modprobe(module, persist=True):
130+ """Load a kernel module and configure for auto-load on reboot."""
131+ cmd = ['modprobe', module]
132+
133+ log('Loading kernel module %s' % module, level=INFO)
134+
135+ check_call(cmd)
136+ if persist:
137+ with open('/etc/modules', 'r+') as modules:
138+ if module not in modules.read():
139+ modules.write(module)
140+
141+
142+def rmmod(module, force=False):
143+ """Remove a module from the linux kernel"""
144+ cmd = ['rmmod']
145+ if force:
146+ cmd.append('-f')
147+ cmd.append(module)
148+ log('Removing kernel module %s' % module, level=INFO)
149+ return check_call(cmd)
150+
151+
152+def lsmod():
153+ """Shows what kernel modules are currently loaded"""
154+ return check_output(['lsmod'],
155+ universal_newlines=True)
156+
157+
158+def is_module_loaded(module):
159+ """Checks if a kernel module is already loaded"""
160+ matches = re.findall('^%s[ ]+' % module, lsmod(), re.M)
161+ return len(matches) > 0
162+
163+
164+def update_initramfs(version='all'):
165+ """Updates an initramfs image"""
166+ return check_call(["update-initramfs", "-k", version, "-u"])

Subscribers

People subscribed via source and target branches