Merge lp:~james-page/charms/trusty/keystone/lp1531102 into lp:~openstack-charmers-archive/charms/trusty/keystone/next
- Trusty Tahr (14.04)
- lp1531102
- Merge into next
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 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenStack Charmers | Pending | ||
Review via email: mp+281615@code.launchpad.net |
Commit message
Resync helpers
Description of the change
Resync helpers.
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
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://
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
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://
Build: http://
- 196. By James Page
-
Resync helpers to resolve systemd related amulet test failures.
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #16722 keystone-next for james-page mp281615
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #15619 keystone-next for james-page mp281615
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #8549 keystone-next for james-page mp281615
AMULET OK: passed
Build: http://
Preview Diff
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 | 131 | # >= Liberty version->codename mapping | 131 | # >= Liberty version->codename mapping |
6 | 132 | PACKAGE_CODENAMES = { | 132 | PACKAGE_CODENAMES = { |
7 | 133 | 'nova-common': OrderedDict([ | 133 | 'nova-common': OrderedDict([ |
10 | 134 | ('12.0.0', 'liberty'), | 134 | ('12.0', 'liberty'), |
11 | 135 | ('13.0.0', 'mitaka'), | 135 | ('13.0', 'mitaka'), |
12 | 136 | ]), | 136 | ]), |
13 | 137 | 'neutron-common': OrderedDict([ | 137 | 'neutron-common': OrderedDict([ |
16 | 138 | ('7.0.0', 'liberty'), | 138 | ('7.0', 'liberty'), |
17 | 139 | ('8.0.0', 'mitaka'), | 139 | ('8.0', 'mitaka'), |
18 | 140 | ]), | 140 | ]), |
19 | 141 | 'cinder-common': OrderedDict([ | 141 | 'cinder-common': OrderedDict([ |
22 | 142 | ('7.0.0', 'liberty'), | 142 | ('7.0', 'liberty'), |
23 | 143 | ('8.0.0', 'mitaka'), | 143 | ('8.0', 'mitaka'), |
24 | 144 | ]), | 144 | ]), |
25 | 145 | 'keystone': OrderedDict([ | 145 | 'keystone': OrderedDict([ |
28 | 146 | ('8.0.0', 'liberty'), | 146 | ('8.0', 'liberty'), |
29 | 147 | ('9.0.0', 'mitaka'), | 147 | ('9.0', 'mitaka'), |
30 | 148 | ]), | 148 | ]), |
31 | 149 | 'horizon-common': OrderedDict([ | 149 | 'horizon-common': OrderedDict([ |
34 | 150 | ('8.0.0', 'liberty'), | 150 | ('8.0', 'liberty'), |
35 | 151 | ('9.0.0', 'mitaka'), | 151 | ('9.0', 'mitaka'), |
36 | 152 | ]), | 152 | ]), |
37 | 153 | 'ceilometer-common': OrderedDict([ | 153 | 'ceilometer-common': OrderedDict([ |
40 | 154 | ('5.0.0', 'liberty'), | 154 | ('5.0', 'liberty'), |
41 | 155 | ('6.0.0', 'mitaka'), | 155 | ('6.0', 'mitaka'), |
42 | 156 | ]), | 156 | ]), |
43 | 157 | 'heat-common': OrderedDict([ | 157 | 'heat-common': OrderedDict([ |
46 | 158 | ('5.0.0', 'liberty'), | 158 | ('5.0', 'liberty'), |
47 | 159 | ('6.0.0', 'mitaka'), | 159 | ('6.0', 'mitaka'), |
48 | 160 | ]), | 160 | ]), |
49 | 161 | 'glance-common': OrderedDict([ | 161 | 'glance-common': OrderedDict([ |
52 | 162 | ('11.0.0', 'liberty'), | 162 | ('11.0', 'liberty'), |
53 | 163 | ('12.0.0', 'mitaka'), | 163 | ('12.0', 'mitaka'), |
54 | 164 | ]), | 164 | ]), |
55 | 165 | 'openstack-dashboard': OrderedDict([ | 165 | 'openstack-dashboard': OrderedDict([ |
58 | 166 | ('8.0.0', 'liberty'), | 166 | ('8.0', 'liberty'), |
59 | 167 | ('9.0.0', 'mitaka'), | 167 | ('9.0', 'mitaka'), |
60 | 168 | ]), | 168 | ]), |
61 | 169 | } | 169 | } |
62 | 170 | 170 | ||
63 | @@ -251,7 +251,14 @@ | |||
64 | 251 | error_out(e) | 251 | error_out(e) |
65 | 252 | 252 | ||
66 | 253 | vers = apt.upstream_version(pkg.current_ver.ver_str) | 253 | vers = apt.upstream_version(pkg.current_ver.ver_str) |
68 | 254 | match = re.match('^(\d+)\.(\d+)\.(\d+)', vers) | 254 | if 'swift' in pkg.name: |
69 | 255 | # Fully x.y.z match for swift versions | ||
70 | 256 | match = re.match('^(\d+)\.(\d+)\.(\d+)', vers) | ||
71 | 257 | else: | ||
72 | 258 | # x.y match only for 20XX.X | ||
73 | 259 | # and ignore patch level for other packages | ||
74 | 260 | match = re.match('^(\d+)\.(\d+)', vers) | ||
75 | 261 | |||
76 | 255 | if match: | 262 | if match: |
77 | 256 | vers = match.group(0) | 263 | vers = match.group(0) |
78 | 257 | 264 | ||
79 | @@ -263,13 +270,8 @@ | |||
80 | 263 | # < Liberty co-ordinated project versions | 270 | # < Liberty co-ordinated project versions |
81 | 264 | try: | 271 | try: |
82 | 265 | if 'swift' in pkg.name: | 272 | if 'swift' in pkg.name: |
88 | 266 | swift_vers = vers[:5] | 273 | return SWIFT_CODENAMES[vers] |
84 | 267 | if swift_vers not in SWIFT_CODENAMES: | ||
85 | 268 | # Deal with 1.10.0 upward | ||
86 | 269 | swift_vers = vers[:6] | ||
87 | 270 | return SWIFT_CODENAMES[swift_vers] | ||
89 | 271 | else: | 274 | else: |
90 | 272 | vers = vers[:6] | ||
91 | 273 | return OPENSTACK_CODENAMES[vers] | 275 | return OPENSTACK_CODENAMES[vers] |
92 | 274 | except KeyError: | 276 | except KeyError: |
93 | 275 | if not fatal: | 277 | if not fatal: |
94 | 276 | 278 | ||
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 | 72 | stopped = service_stop(service_name) | 72 | stopped = service_stop(service_name) |
100 | 73 | upstart_file = os.path.join(init_dir, "{}.conf".format(service_name)) | 73 | upstart_file = os.path.join(init_dir, "{}.conf".format(service_name)) |
101 | 74 | sysv_file = os.path.join(initd_dir, service_name) | 74 | sysv_file = os.path.join(initd_dir, service_name) |
103 | 75 | if os.path.exists(upstart_file): | 75 | if init_is_systemd(): |
104 | 76 | service('disable', service_name) | ||
105 | 77 | elif os.path.exists(upstart_file): | ||
106 | 76 | override_path = os.path.join( | 78 | override_path = os.path.join( |
107 | 77 | init_dir, '{}.override'.format(service_name)) | 79 | init_dir, '{}.override'.format(service_name)) |
108 | 78 | with open(override_path, 'w') as fh: | 80 | with open(override_path, 'w') as fh: |
109 | @@ -80,9 +82,9 @@ | |||
110 | 80 | elif os.path.exists(sysv_file): | 82 | elif os.path.exists(sysv_file): |
111 | 81 | subprocess.check_call(["update-rc.d", service_name, "disable"]) | 83 | subprocess.check_call(["update-rc.d", service_name, "disable"]) |
112 | 82 | else: | 84 | else: |
113 | 83 | # XXX: Support SystemD too | ||
114 | 84 | raise ValueError( | 85 | raise ValueError( |
116 | 85 | "Unable to detect {0} as either Upstart {1} or SysV {2}".format( | 86 | "Unable to detect {0} as SystemD, Upstart {1} or" |
117 | 87 | " SysV {2}".format( | ||
118 | 86 | service_name, upstart_file, sysv_file)) | 88 | service_name, upstart_file, sysv_file)) |
119 | 87 | return stopped | 89 | return stopped |
120 | 88 | 90 | ||
121 | @@ -94,7 +96,9 @@ | |||
122 | 94 | Reenable starting again at boot. Start the service""" | 96 | Reenable starting again at boot. Start the service""" |
123 | 95 | upstart_file = os.path.join(init_dir, "{}.conf".format(service_name)) | 97 | upstart_file = os.path.join(init_dir, "{}.conf".format(service_name)) |
124 | 96 | sysv_file = os.path.join(initd_dir, service_name) | 98 | sysv_file = os.path.join(initd_dir, service_name) |
126 | 97 | if os.path.exists(upstart_file): | 99 | if init_is_systemd(): |
127 | 100 | service('enable', service_name) | ||
128 | 101 | elif os.path.exists(upstart_file): | ||
129 | 98 | override_path = os.path.join( | 102 | override_path = os.path.join( |
130 | 99 | init_dir, '{}.override'.format(service_name)) | 103 | init_dir, '{}.override'.format(service_name)) |
131 | 100 | if os.path.exists(override_path): | 104 | if os.path.exists(override_path): |
132 | @@ -102,9 +106,9 @@ | |||
133 | 102 | elif os.path.exists(sysv_file): | 106 | elif os.path.exists(sysv_file): |
134 | 103 | subprocess.check_call(["update-rc.d", service_name, "enable"]) | 107 | subprocess.check_call(["update-rc.d", service_name, "enable"]) |
135 | 104 | else: | 108 | else: |
136 | 105 | # XXX: Support SystemD too | ||
137 | 106 | raise ValueError( | 109 | raise ValueError( |
139 | 107 | "Unable to detect {0} as either Upstart {1} or SysV {2}".format( | 110 | "Unable to detect {0} as SystemD, Upstart {1} or" |
140 | 111 | " SysV {2}".format( | ||
141 | 108 | service_name, upstart_file, sysv_file)) | 112 | service_name, upstart_file, sysv_file)) |
142 | 109 | 113 | ||
143 | 110 | started = service_running(service_name) | 114 | started = service_running(service_name) |
144 | @@ -115,23 +119,29 @@ | |||
145 | 115 | 119 | ||
146 | 116 | def service(action, service_name): | 120 | def service(action, service_name): |
147 | 117 | """Control a system service""" | 121 | """Control a system service""" |
149 | 118 | cmd = ['service', service_name, action] | 122 | if init_is_systemd(): |
150 | 123 | cmd = ['systemctl', action, service_name] | ||
151 | 124 | else: | ||
152 | 125 | cmd = ['service', service_name, action] | ||
153 | 119 | return subprocess.call(cmd) == 0 | 126 | return subprocess.call(cmd) == 0 |
154 | 120 | 127 | ||
155 | 121 | 128 | ||
157 | 122 | def service_running(service): | 129 | def service_running(service_name): |
158 | 123 | """Determine whether a system service is running""" | 130 | """Determine whether a system service is running""" |
165 | 124 | try: | 131 | if init_is_systemd(): |
166 | 125 | output = subprocess.check_output( | 132 | return service('is-active', service_name) |
161 | 126 | ['service', service, 'status'], | ||
162 | 127 | stderr=subprocess.STDOUT).decode('UTF-8') | ||
163 | 128 | except subprocess.CalledProcessError: | ||
164 | 129 | return False | ||
167 | 130 | else: | 133 | else: |
171 | 131 | if ("start/running" in output or "is running" in output): | 134 | try: |
172 | 132 | return True | 135 | output = subprocess.check_output( |
173 | 133 | else: | 136 | ['service', service_name, 'status'], |
174 | 137 | stderr=subprocess.STDOUT).decode('UTF-8') | ||
175 | 138 | except subprocess.CalledProcessError: | ||
176 | 134 | return False | 139 | return False |
177 | 140 | else: | ||
178 | 141 | if ("start/running" in output or "is running" in output): | ||
179 | 142 | return True | ||
180 | 143 | else: | ||
181 | 144 | return False | ||
182 | 135 | 145 | ||
183 | 136 | 146 | ||
184 | 137 | def service_available(service_name): | 147 | def service_available(service_name): |
185 | @@ -146,6 +156,13 @@ | |||
186 | 146 | return True | 156 | return True |
187 | 147 | 157 | ||
188 | 148 | 158 | ||
189 | 159 | SYSTEMD_SYSTEM = '/run/systemd/system' | ||
190 | 160 | |||
191 | 161 | |||
192 | 162 | def init_is_systemd(): | ||
193 | 163 | return os.path.isdir(SYSTEMD_SYSTEM) | ||
194 | 164 | |||
195 | 165 | |||
196 | 149 | def adduser(username, password=None, shell='/bin/bash', system_user=False, | 166 | def adduser(username, password=None, shell='/bin/bash', system_user=False, |
197 | 150 | primary_group=None, secondary_groups=None): | 167 | primary_group=None, secondary_groups=None): |
198 | 151 | """ | 168 | """ |
199 | 152 | 169 | ||
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 | 1 | #!/usr/bin/env python | ||
205 | 2 | # -*- coding: utf-8 -*- | ||
206 | 3 | |||
207 | 4 | # Copyright 2014-2015 Canonical Limited. | ||
208 | 5 | # | ||
209 | 6 | # This file is part of charm-helpers. | ||
210 | 7 | # | ||
211 | 8 | # charm-helpers is free software: you can redistribute it and/or modify | ||
212 | 9 | # it under the terms of the GNU Lesser General Public License version 3 as | ||
213 | 10 | # published by the Free Software Foundation. | ||
214 | 11 | # | ||
215 | 12 | # charm-helpers is distributed in the hope that it will be useful, | ||
216 | 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
217 | 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
218 | 15 | # GNU Lesser General Public License for more details. | ||
219 | 16 | # | ||
220 | 17 | # You should have received a copy of the GNU Lesser General Public License | ||
221 | 18 | # along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. | ||
222 | 19 | |||
223 | 20 | __author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>" | ||
224 | 21 | |||
225 | 22 | from charmhelpers.core.hookenv import ( | ||
226 | 23 | log, | ||
227 | 24 | INFO | ||
228 | 25 | ) | ||
229 | 26 | |||
230 | 27 | from subprocess import check_call, check_output | ||
231 | 28 | import re | ||
232 | 29 | |||
233 | 30 | |||
234 | 31 | def modprobe(module, persist=True): | ||
235 | 32 | """Load a kernel module and configure for auto-load on reboot.""" | ||
236 | 33 | cmd = ['modprobe', module] | ||
237 | 34 | |||
238 | 35 | log('Loading kernel module %s' % module, level=INFO) | ||
239 | 36 | |||
240 | 37 | check_call(cmd) | ||
241 | 38 | if persist: | ||
242 | 39 | with open('/etc/modules', 'r+') as modules: | ||
243 | 40 | if module not in modules.read(): | ||
244 | 41 | modules.write(module) | ||
245 | 42 | |||
246 | 43 | |||
247 | 44 | def rmmod(module, force=False): | ||
248 | 45 | """Remove a module from the linux kernel""" | ||
249 | 46 | cmd = ['rmmod'] | ||
250 | 47 | if force: | ||
251 | 48 | cmd.append('-f') | ||
252 | 49 | cmd.append(module) | ||
253 | 50 | log('Removing kernel module %s' % module, level=INFO) | ||
254 | 51 | return check_call(cmd) | ||
255 | 52 | |||
256 | 53 | |||
257 | 54 | def lsmod(): | ||
258 | 55 | """Shows what kernel modules are currently loaded""" | ||
259 | 56 | return check_output(['lsmod'], | ||
260 | 57 | universal_newlines=True) | ||
261 | 58 | |||
262 | 59 | |||
263 | 60 | def is_module_loaded(module): | ||
264 | 61 | """Checks if a kernel module is already loaded""" | ||
265 | 62 | matches = re.findall('^%s[ ]+' % module, lsmod(), re.M) | ||
266 | 63 | return len(matches) > 0 | ||
267 | 64 | |||
268 | 65 | |||
269 | 66 | def update_initramfs(version='all'): | ||
270 | 67 | """Updates an initramfs image""" | ||
271 | 68 | return check_call(["update-initramfs", "-k", version, "-u"]) |
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/