Merge lp:~corey.bryant/charms/trusty/cinder/git-1531612 into lp:~openstack-charmers-archive/charms/trusty/cinder/next
- Trusty Tahr (14.04)
- git-1531612
- Merge into next
Status: | Merged |
---|---|
Merged at revision: | 141 |
Proposed branch: | lp:~corey.bryant/charms/trusty/cinder/git-1531612 |
Merge into: | lp:~openstack-charmers-archive/charms/trusty/cinder/next |
Diff against target: |
324 lines (+129/-34) 7 files modified
charm-helpers-hooks.yaml (+1/-1) hooks/charmhelpers/contrib/openstack/context.py (+12/-2) hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg (+3/-2) hooks/charmhelpers/contrib/openstack/utils.py (+6/-9) hooks/charmhelpers/core/host.py (+34/-17) hooks/charmhelpers/fetch/giturl.py (+0/-3) hooks/charmhelpers/payload/archive.py (+73/-0) |
To merge this branch: | bzr merge lp:~corey.bryant/charms/trusty/cinder/git-1531612 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenStack Charmers | Pending | ||
Review via email: mp+281955@code.launchpad.net |
Commit message
Description of the change
uosci-testing-bot (uosci-testing-bot) wrote : | # |
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #16811 cinder-next for corey.bryant mp281955
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #8576 cinder-next for corey.bryant mp281955
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_lint_check #16839 cinder-next for corey.bryant mp281955
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #15725 cinder-next for corey.bryant mp281955
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #8608 cinder-next for corey.bryant mp281955
AMULET OK: passed
Build: http://
- 143. By Corey Bryant
-
[corey.
bryant, r=osci] Add hooks/charmhelp ers/payload/ archive. py
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_unit_test #15954 cinder-next for corey.bryant mp281955
UNIT OK: passed
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_lint_check #17086 cinder-next for corey.bryant mp281955
LINT OK: passed
Build: http://
uosci-testing-bot (uosci-testing-bot) wrote : | # |
charm_amulet_test #8689 cinder-next for corey.bryant mp281955
AMULET OK: passed
Build: http://
Preview Diff
1 | === modified file 'charm-helpers-hooks.yaml' |
2 | --- charm-helpers-hooks.yaml 2015-07-31 13:11:29 +0000 |
3 | +++ charm-helpers-hooks.yaml 2016-01-11 14:15:00 +0000 |
4 | @@ -10,7 +10,7 @@ |
5 | - apache |
6 | - cluster |
7 | - fetch |
8 | - - payload.execd |
9 | + - payload |
10 | - contrib.network.ip |
11 | - contrib.python.packages |
12 | - contrib.charmsupport |
13 | |
14 | === modified file 'hooks/charmhelpers/contrib/openstack/context.py' |
15 | --- hooks/charmhelpers/contrib/openstack/context.py 2016-01-04 21:26:14 +0000 |
16 | +++ hooks/charmhelpers/contrib/openstack/context.py 2016-01-11 14:15:00 +0000 |
17 | @@ -57,6 +57,7 @@ |
18 | get_nic_hwaddr, |
19 | mkdir, |
20 | write_file, |
21 | + pwgen, |
22 | ) |
23 | from charmhelpers.contrib.hahelpers.cluster import ( |
24 | determine_apache_port, |
25 | @@ -87,6 +88,8 @@ |
26 | is_bridge_member, |
27 | ) |
28 | from charmhelpers.contrib.openstack.utils import get_host_ip |
29 | +from charmhelpers.core.unitdata import kv |
30 | + |
31 | CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt' |
32 | ADDRESS_TYPES = ['admin', 'internal', 'public'] |
33 | |
34 | @@ -636,11 +639,18 @@ |
35 | ctxt['ipv6'] = True |
36 | ctxt['local_host'] = 'ip6-localhost' |
37 | ctxt['haproxy_host'] = '::' |
38 | - ctxt['stat_port'] = ':::8888' |
39 | else: |
40 | ctxt['local_host'] = '127.0.0.1' |
41 | ctxt['haproxy_host'] = '0.0.0.0' |
42 | - ctxt['stat_port'] = ':8888' |
43 | + |
44 | + ctxt['stat_port'] = '8888' |
45 | + |
46 | + db = kv() |
47 | + ctxt['stat_password'] = db.get('stat-password') |
48 | + if not ctxt['stat_password']: |
49 | + ctxt['stat_password'] = db.set('stat-password', |
50 | + pwgen(32)) |
51 | + db.flush() |
52 | |
53 | for frontend in cluster_hosts: |
54 | if (len(cluster_hosts[frontend]['backends']) > 1 or |
55 | |
56 | === modified file 'hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg' |
57 | --- hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2015-12-07 23:11:09 +0000 |
58 | +++ hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2016-01-11 14:15:00 +0000 |
59 | @@ -33,13 +33,14 @@ |
60 | timeout server 30000 |
61 | {%- endif %} |
62 | |
63 | -listen stats {{ stat_port }} |
64 | +listen stats |
65 | + bind {{ local_host }}:{{ stat_port }} |
66 | mode http |
67 | stats enable |
68 | stats hide-version |
69 | stats realm Haproxy\ Statistics |
70 | stats uri / |
71 | - stats auth admin:password |
72 | + stats auth admin:{{ stat_password }} |
73 | |
74 | {% if frontends -%} |
75 | {% for service, ports in service_ports.items() -%} |
76 | |
77 | === modified file 'hooks/charmhelpers/contrib/openstack/utils.py' |
78 | --- hooks/charmhelpers/contrib/openstack/utils.py 2016-01-05 11:01:37 +0000 |
79 | +++ hooks/charmhelpers/contrib/openstack/utils.py 2016-01-11 14:15:00 +0000 |
80 | @@ -593,7 +593,7 @@ |
81 | return yaml.load(projects_yaml) |
82 | |
83 | |
84 | -def git_clone_and_install(projects_yaml, core_project, depth=1): |
85 | +def git_clone_and_install(projects_yaml, core_project): |
86 | """ |
87 | Clone/install all specified OpenStack repositories. |
88 | |
89 | @@ -643,6 +643,9 @@ |
90 | for p in projects['repositories']: |
91 | repo = p['repository'] |
92 | branch = p['branch'] |
93 | + depth = '1' |
94 | + if 'depth' in p.keys(): |
95 | + depth = p['depth'] |
96 | if p['name'] == 'requirements': |
97 | repo_dir = _git_clone_and_install_single(repo, branch, depth, |
98 | parent_dir, http_proxy, |
99 | @@ -687,19 +690,13 @@ |
100 | """ |
101 | Clone and install a single git repository. |
102 | """ |
103 | - dest_dir = os.path.join(parent_dir, os.path.basename(repo)) |
104 | - |
105 | if not os.path.exists(parent_dir): |
106 | juju_log('Directory already exists at {}. ' |
107 | 'No need to create directory.'.format(parent_dir)) |
108 | os.mkdir(parent_dir) |
109 | |
110 | - if not os.path.exists(dest_dir): |
111 | - juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch)) |
112 | - repo_dir = install_remote(repo, dest=parent_dir, branch=branch, |
113 | - depth=depth) |
114 | - else: |
115 | - repo_dir = dest_dir |
116 | + juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch)) |
117 | + repo_dir = install_remote(repo, dest=parent_dir, branch=branch, depth=depth) |
118 | |
119 | venv = os.path.join(parent_dir, 'venv') |
120 | |
121 | |
122 | === modified file 'hooks/charmhelpers/core/host.py' |
123 | --- hooks/charmhelpers/core/host.py 2016-01-04 21:26:14 +0000 |
124 | +++ hooks/charmhelpers/core/host.py 2016-01-11 14:15:00 +0000 |
125 | @@ -72,7 +72,9 @@ |
126 | stopped = service_stop(service_name) |
127 | upstart_file = os.path.join(init_dir, "{}.conf".format(service_name)) |
128 | sysv_file = os.path.join(initd_dir, service_name) |
129 | - if os.path.exists(upstart_file): |
130 | + if init_is_systemd(): |
131 | + service('disable', service_name) |
132 | + elif os.path.exists(upstart_file): |
133 | override_path = os.path.join( |
134 | init_dir, '{}.override'.format(service_name)) |
135 | with open(override_path, 'w') as fh: |
136 | @@ -80,9 +82,9 @@ |
137 | elif os.path.exists(sysv_file): |
138 | subprocess.check_call(["update-rc.d", service_name, "disable"]) |
139 | else: |
140 | - # XXX: Support SystemD too |
141 | raise ValueError( |
142 | - "Unable to detect {0} as either Upstart {1} or SysV {2}".format( |
143 | + "Unable to detect {0} as SystemD, Upstart {1} or" |
144 | + " SysV {2}".format( |
145 | service_name, upstart_file, sysv_file)) |
146 | return stopped |
147 | |
148 | @@ -94,7 +96,9 @@ |
149 | Reenable starting again at boot. Start the service""" |
150 | upstart_file = os.path.join(init_dir, "{}.conf".format(service_name)) |
151 | sysv_file = os.path.join(initd_dir, service_name) |
152 | - if os.path.exists(upstart_file): |
153 | + if init_is_systemd(): |
154 | + service('enable', service_name) |
155 | + elif os.path.exists(upstart_file): |
156 | override_path = os.path.join( |
157 | init_dir, '{}.override'.format(service_name)) |
158 | if os.path.exists(override_path): |
159 | @@ -102,9 +106,9 @@ |
160 | elif os.path.exists(sysv_file): |
161 | subprocess.check_call(["update-rc.d", service_name, "enable"]) |
162 | else: |
163 | - # XXX: Support SystemD too |
164 | raise ValueError( |
165 | - "Unable to detect {0} as either Upstart {1} or SysV {2}".format( |
166 | + "Unable to detect {0} as SystemD, Upstart {1} or" |
167 | + " SysV {2}".format( |
168 | service_name, upstart_file, sysv_file)) |
169 | |
170 | started = service_running(service_name) |
171 | @@ -115,23 +119,29 @@ |
172 | |
173 | def service(action, service_name): |
174 | """Control a system service""" |
175 | - cmd = ['service', service_name, action] |
176 | + if init_is_systemd(): |
177 | + cmd = ['systemctl', action, service_name] |
178 | + else: |
179 | + cmd = ['service', service_name, action] |
180 | return subprocess.call(cmd) == 0 |
181 | |
182 | |
183 | -def service_running(service): |
184 | +def service_running(service_name): |
185 | """Determine whether a system service is running""" |
186 | - try: |
187 | - output = subprocess.check_output( |
188 | - ['service', service, 'status'], |
189 | - stderr=subprocess.STDOUT).decode('UTF-8') |
190 | - except subprocess.CalledProcessError: |
191 | - return False |
192 | + if init_is_systemd(): |
193 | + return service('is-active', service_name) |
194 | else: |
195 | - if ("start/running" in output or "is running" in output): |
196 | - return True |
197 | - else: |
198 | + try: |
199 | + output = subprocess.check_output( |
200 | + ['service', service_name, 'status'], |
201 | + stderr=subprocess.STDOUT).decode('UTF-8') |
202 | + except subprocess.CalledProcessError: |
203 | return False |
204 | + else: |
205 | + if ("start/running" in output or "is running" in output): |
206 | + return True |
207 | + else: |
208 | + return False |
209 | |
210 | |
211 | def service_available(service_name): |
212 | @@ -146,6 +156,13 @@ |
213 | return True |
214 | |
215 | |
216 | +SYSTEMD_SYSTEM = '/run/systemd/system' |
217 | + |
218 | + |
219 | +def init_is_systemd(): |
220 | + return os.path.isdir(SYSTEMD_SYSTEM) |
221 | + |
222 | + |
223 | def adduser(username, password=None, shell='/bin/bash', system_user=False, |
224 | primary_group=None, secondary_groups=None): |
225 | """ |
226 | |
227 | === modified file 'hooks/charmhelpers/fetch/giturl.py' |
228 | --- hooks/charmhelpers/fetch/giturl.py 2016-01-04 21:26:14 +0000 |
229 | +++ hooks/charmhelpers/fetch/giturl.py 2016-01-11 14:15:00 +0000 |
230 | @@ -22,7 +22,6 @@ |
231 | filter_installed_packages, |
232 | apt_install, |
233 | ) |
234 | -from charmhelpers.core.host import mkdir |
235 | |
236 | if filter_installed_packages(['git']) != []: |
237 | apt_install(['git']) |
238 | @@ -62,8 +61,6 @@ |
239 | else: |
240 | dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched", |
241 | branch_name) |
242 | - if not os.path.exists(dest_dir): |
243 | - mkdir(dest_dir, perms=0o755) |
244 | try: |
245 | self.clone(source, dest_dir, branch, depth) |
246 | except OSError as e: |
247 | |
248 | === added file 'hooks/charmhelpers/payload/archive.py' |
249 | --- hooks/charmhelpers/payload/archive.py 1970-01-01 00:00:00 +0000 |
250 | +++ hooks/charmhelpers/payload/archive.py 2016-01-11 14:15:00 +0000 |
251 | @@ -0,0 +1,73 @@ |
252 | +# Copyright 2014-2015 Canonical Limited. |
253 | +# |
254 | +# This file is part of charm-helpers. |
255 | +# |
256 | +# charm-helpers is free software: you can redistribute it and/or modify |
257 | +# it under the terms of the GNU Lesser General Public License version 3 as |
258 | +# published by the Free Software Foundation. |
259 | +# |
260 | +# charm-helpers is distributed in the hope that it will be useful, |
261 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
262 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
263 | +# GNU Lesser General Public License for more details. |
264 | +# |
265 | +# You should have received a copy of the GNU Lesser General Public License |
266 | +# along with charm-helpers. If not, see <http://www.gnu.org/licenses/>. |
267 | + |
268 | +import os |
269 | +import tarfile |
270 | +import zipfile |
271 | +from charmhelpers.core import ( |
272 | + host, |
273 | + hookenv, |
274 | +) |
275 | + |
276 | + |
277 | +class ArchiveError(Exception): |
278 | + pass |
279 | + |
280 | + |
281 | +def get_archive_handler(archive_name): |
282 | + if os.path.isfile(archive_name): |
283 | + if tarfile.is_tarfile(archive_name): |
284 | + return extract_tarfile |
285 | + elif zipfile.is_zipfile(archive_name): |
286 | + return extract_zipfile |
287 | + else: |
288 | + # look at the file name |
289 | + for ext in ('.tar', '.tar.gz', '.tgz', 'tar.bz2', '.tbz2', '.tbz'): |
290 | + if archive_name.endswith(ext): |
291 | + return extract_tarfile |
292 | + for ext in ('.zip', '.jar'): |
293 | + if archive_name.endswith(ext): |
294 | + return extract_zipfile |
295 | + |
296 | + |
297 | +def archive_dest_default(archive_name): |
298 | + archive_file = os.path.basename(archive_name) |
299 | + return os.path.join(hookenv.charm_dir(), "archives", archive_file) |
300 | + |
301 | + |
302 | +def extract(archive_name, destpath=None): |
303 | + handler = get_archive_handler(archive_name) |
304 | + if handler: |
305 | + if not destpath: |
306 | + destpath = archive_dest_default(archive_name) |
307 | + if not os.path.isdir(destpath): |
308 | + host.mkdir(destpath) |
309 | + handler(archive_name, destpath) |
310 | + return destpath |
311 | + else: |
312 | + raise ArchiveError("No handler for archive") |
313 | + |
314 | + |
315 | +def extract_tarfile(archive_name, destpath): |
316 | + "Unpack a tar archive, optionally compressed" |
317 | + archive = tarfile.open(archive_name) |
318 | + archive.extractall(destpath) |
319 | + |
320 | + |
321 | +def extract_zipfile(archive_name, destpath): |
322 | + "Unpack a zip file" |
323 | + archive = zipfile.ZipFile(archive_name) |
324 | + archive.extractall(destpath) |
charm_unit_test #15693 cinder-next for corey.bryant mp281955
UNIT OK: passed
Build: http:// 10.245. 162.77: 8080/job/ charm_unit_ test/15693/