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