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

Proposed by James Page on 2016-01-05
Status: Merged
Merged at revision: 195
Proposed branch: lp:~james-page/charms/trusty/keystone/lp1531102
Merge into: lp:~openstack-charmers-archive/charms/trusty/keystone/next
Diff against target: 271 lines (+129/-42)
3 files modified
charmhelpers/contrib/openstack/utils.py (+27/-25)
charmhelpers/core/host.py (+34/-17)
charmhelpers/core/kernel.py (+68/-0)
To merge this branch: bzr merge lp:~james-page/charms/trusty/keystone/lp1531102
Reviewer Review Type Date Requested Status
OpenStack Charmers 2016-01-05 Pending
Review via email: mp+281615@code.launchpad.net

Commit message

Resync helpers

Description of the change

Resync helpers.

To post a comment you must log in.

charm_lint_check #16597 keystone-next for james-page mp281615
    LINT OK: passed

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

charm_amulet_test #8516 keystone-next for james-page mp281615
    AMULET FAIL: amulet-test failed

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

Full amulet test output: http://paste.ubuntu.com/14411765/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8516/

charm_amulet_test #8536 keystone-next for james-page mp281615
    AMULET FAIL: amulet-test failed

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

Full amulet test output: http://paste.ubuntu.com/14420307/
Build: http://10.245.162.77:8080/job/charm_amulet_test/8536/

196. By James Page on 2016-01-07

Resync helpers to resolve systemd related amulet test failures.

charm_lint_check #16722 keystone-next for james-page mp281615
    LINT OK: passed

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

charm_unit_test #15619 keystone-next for james-page mp281615
    UNIT OK: passed

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

charm_amulet_test #8549 keystone-next for james-page mp281615
    AMULET OK: passed

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmhelpers/contrib/openstack/utils.py'
2--- charmhelpers/contrib/openstack/utils.py 2016-01-04 21:27:51 +0000
3+++ charmhelpers/contrib/openstack/utils.py 2016-01-07 09:16:53 +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=== modified file 'charmhelpers/core/host.py'
96--- charmhelpers/core/host.py 2016-01-04 21:27:51 +0000
97+++ charmhelpers/core/host.py 2016-01-07 09:16:53 +0000
98@@ -72,7 +72,9 @@
99 stopped = service_stop(service_name)
100 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
101 sysv_file = os.path.join(initd_dir, service_name)
102- if os.path.exists(upstart_file):
103+ if init_is_systemd():
104+ service('disable', service_name)
105+ elif os.path.exists(upstart_file):
106 override_path = os.path.join(
107 init_dir, '{}.override'.format(service_name))
108 with open(override_path, 'w') as fh:
109@@ -80,9 +82,9 @@
110 elif os.path.exists(sysv_file):
111 subprocess.check_call(["update-rc.d", service_name, "disable"])
112 else:
113- # XXX: Support SystemD too
114 raise ValueError(
115- "Unable to detect {0} as either Upstart {1} or SysV {2}".format(
116+ "Unable to detect {0} as SystemD, Upstart {1} or"
117+ " SysV {2}".format(
118 service_name, upstart_file, sysv_file))
119 return stopped
120
121@@ -94,7 +96,9 @@
122 Reenable starting again at boot. Start the service"""
123 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
124 sysv_file = os.path.join(initd_dir, service_name)
125- if os.path.exists(upstart_file):
126+ if init_is_systemd():
127+ service('enable', service_name)
128+ elif os.path.exists(upstart_file):
129 override_path = os.path.join(
130 init_dir, '{}.override'.format(service_name))
131 if os.path.exists(override_path):
132@@ -102,9 +106,9 @@
133 elif os.path.exists(sysv_file):
134 subprocess.check_call(["update-rc.d", service_name, "enable"])
135 else:
136- # XXX: Support SystemD too
137 raise ValueError(
138- "Unable to detect {0} as either Upstart {1} or SysV {2}".format(
139+ "Unable to detect {0} as SystemD, Upstart {1} or"
140+ " SysV {2}".format(
141 service_name, upstart_file, sysv_file))
142
143 started = service_running(service_name)
144@@ -115,23 +119,29 @@
145
146 def service(action, service_name):
147 """Control a system service"""
148- cmd = ['service', service_name, action]
149+ if init_is_systemd():
150+ cmd = ['systemctl', action, service_name]
151+ else:
152+ cmd = ['service', service_name, action]
153 return subprocess.call(cmd) == 0
154
155
156-def service_running(service):
157+def service_running(service_name):
158 """Determine whether a system service is running"""
159- try:
160- output = subprocess.check_output(
161- ['service', service, 'status'],
162- stderr=subprocess.STDOUT).decode('UTF-8')
163- except subprocess.CalledProcessError:
164- return False
165+ if init_is_systemd():
166+ return service('is-active', service_name)
167 else:
168- if ("start/running" in output or "is running" in output):
169- return True
170- else:
171+ try:
172+ output = subprocess.check_output(
173+ ['service', service_name, 'status'],
174+ stderr=subprocess.STDOUT).decode('UTF-8')
175+ except subprocess.CalledProcessError:
176 return False
177+ else:
178+ if ("start/running" in output or "is running" in output):
179+ return True
180+ else:
181+ return False
182
183
184 def service_available(service_name):
185@@ -146,6 +156,13 @@
186 return True
187
188
189+SYSTEMD_SYSTEM = '/run/systemd/system'
190+
191+
192+def init_is_systemd():
193+ return os.path.isdir(SYSTEMD_SYSTEM)
194+
195+
196 def adduser(username, password=None, shell='/bin/bash', system_user=False,
197 primary_group=None, secondary_groups=None):
198 """
199
200=== added file 'charmhelpers/core/kernel.py'
201--- charmhelpers/core/kernel.py 1970-01-01 00:00:00 +0000
202+++ charmhelpers/core/kernel.py 2016-01-07 09:16:53 +0000
203@@ -0,0 +1,68 @@
204+#!/usr/bin/env python
205+# -*- coding: utf-8 -*-
206+
207+# Copyright 2014-2015 Canonical Limited.
208+#
209+# This file is part of charm-helpers.
210+#
211+# charm-helpers is free software: you can redistribute it and/or modify
212+# it under the terms of the GNU Lesser General Public License version 3 as
213+# published by the Free Software Foundation.
214+#
215+# charm-helpers is distributed in the hope that it will be useful,
216+# but WITHOUT ANY WARRANTY; without even the implied warranty of
217+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
218+# GNU Lesser General Public License for more details.
219+#
220+# You should have received a copy of the GNU Lesser General Public License
221+# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>.
222+
223+__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
224+
225+from charmhelpers.core.hookenv import (
226+ log,
227+ INFO
228+)
229+
230+from subprocess import check_call, check_output
231+import re
232+
233+
234+def modprobe(module, persist=True):
235+ """Load a kernel module and configure for auto-load on reboot."""
236+ cmd = ['modprobe', module]
237+
238+ log('Loading kernel module %s' % module, level=INFO)
239+
240+ check_call(cmd)
241+ if persist:
242+ with open('/etc/modules', 'r+') as modules:
243+ if module not in modules.read():
244+ modules.write(module)
245+
246+
247+def rmmod(module, force=False):
248+ """Remove a module from the linux kernel"""
249+ cmd = ['rmmod']
250+ if force:
251+ cmd.append('-f')
252+ cmd.append(module)
253+ log('Removing kernel module %s' % module, level=INFO)
254+ return check_call(cmd)
255+
256+
257+def lsmod():
258+ """Shows what kernel modules are currently loaded"""
259+ return check_output(['lsmod'],
260+ universal_newlines=True)
261+
262+
263+def is_module_loaded(module):
264+ """Checks if a kernel module is already loaded"""
265+ matches = re.findall('^%s[ ]+' % module, lsmod(), re.M)
266+ return len(matches) > 0
267+
268+
269+def update_initramfs(version='all'):
270+ """Updates an initramfs image"""
271+ return check_call(["update-initramfs", "-k", version, "-u"])

Subscribers

People subscribed via source and target branches