Merge lp:~corey.bryant/charms/trusty/ceilometer/git-1531612 into lp:~openstack-charmers-archive/charms/trusty/ceilometer/next

Proposed by Corey Bryant on 2016-01-08
Status: Merged
Merged at revision: 111
Proposed branch: lp:~corey.bryant/charms/trusty/ceilometer/git-1531612
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceilometer/next
Diff against target: 233 lines (+55/-33)
5 files modified
charmhelpers/contrib/openstack/context.py (+12/-2)
charmhelpers/contrib/openstack/templates/haproxy.cfg (+3/-2)
charmhelpers/contrib/openstack/utils.py (+6/-9)
charmhelpers/core/host.py (+34/-17)
charmhelpers/fetch/giturl.py (+0/-3)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/ceilometer/git-1531612
Reviewer Review Type Date Requested Status
Liam Young 2016-01-08 Approve on 2016-01-08
Review via email: mp+281954@code.launchpad.net
To post a comment you must log in.

charm_lint_check #16804 ceilometer-next for corey.bryant mp281954
    LINT OK: passed

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

charm_unit_test #15700 ceilometer-next for corey.bryant mp281954
    UNIT OK: passed

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

charm_amulet_test #8585 ceilometer-next for corey.bryant mp281954
    AMULET OK: passed

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

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 'charmhelpers/contrib/openstack/context.py'
2--- charmhelpers/contrib/openstack/context.py 2016-01-04 21:24:42 +0000
3+++ charmhelpers/contrib/openstack/context.py 2016-01-08 03:09:55 +0000
4@@ -57,6 +57,7 @@
5 get_nic_hwaddr,
6 mkdir,
7 write_file,
8+ pwgen,
9 )
10 from charmhelpers.contrib.hahelpers.cluster import (
11 determine_apache_port,
12@@ -87,6 +88,8 @@
13 is_bridge_member,
14 )
15 from charmhelpers.contrib.openstack.utils import get_host_ip
16+from charmhelpers.core.unitdata import kv
17+
18 CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
19 ADDRESS_TYPES = ['admin', 'internal', 'public']
20
21@@ -636,11 +639,18 @@
22 ctxt['ipv6'] = True
23 ctxt['local_host'] = 'ip6-localhost'
24 ctxt['haproxy_host'] = '::'
25- ctxt['stat_port'] = ':::8888'
26 else:
27 ctxt['local_host'] = '127.0.0.1'
28 ctxt['haproxy_host'] = '0.0.0.0'
29- ctxt['stat_port'] = ':8888'
30+
31+ ctxt['stat_port'] = '8888'
32+
33+ db = kv()
34+ ctxt['stat_password'] = db.get('stat-password')
35+ if not ctxt['stat_password']:
36+ ctxt['stat_password'] = db.set('stat-password',
37+ pwgen(32))
38+ db.flush()
39
40 for frontend in cluster_hosts:
41 if (len(cluster_hosts[frontend]['backends']) > 1 or
42
43=== modified file 'charmhelpers/contrib/openstack/templates/haproxy.cfg'
44--- charmhelpers/contrib/openstack/templates/haproxy.cfg 2015-12-07 23:08:12 +0000
45+++ charmhelpers/contrib/openstack/templates/haproxy.cfg 2016-01-08 03:09:55 +0000
46@@ -33,13 +33,14 @@
47 timeout server 30000
48 {%- endif %}
49
50-listen stats {{ stat_port }}
51+listen stats
52+ bind {{ local_host }}:{{ stat_port }}
53 mode http
54 stats enable
55 stats hide-version
56 stats realm Haproxy\ Statistics
57 stats uri /
58- stats auth admin:password
59+ stats auth admin:{{ stat_password }}
60
61 {% if frontends -%}
62 {% for service, ports in service_ports.items() -%}
63
64=== modified file 'charmhelpers/contrib/openstack/utils.py'
65--- charmhelpers/contrib/openstack/utils.py 2016-01-05 11:48:08 +0000
66+++ charmhelpers/contrib/openstack/utils.py 2016-01-08 03:09:55 +0000
67@@ -593,7 +593,7 @@
68 return yaml.load(projects_yaml)
69
70
71-def git_clone_and_install(projects_yaml, core_project, depth=1):
72+def git_clone_and_install(projects_yaml, core_project):
73 """
74 Clone/install all specified OpenStack repositories.
75
76@@ -643,6 +643,9 @@
77 for p in projects['repositories']:
78 repo = p['repository']
79 branch = p['branch']
80+ depth = '1'
81+ if 'depth' in p.keys():
82+ depth = p['depth']
83 if p['name'] == 'requirements':
84 repo_dir = _git_clone_and_install_single(repo, branch, depth,
85 parent_dir, http_proxy,
86@@ -687,19 +690,13 @@
87 """
88 Clone and install a single git repository.
89 """
90- dest_dir = os.path.join(parent_dir, os.path.basename(repo))
91-
92 if not os.path.exists(parent_dir):
93 juju_log('Directory already exists at {}. '
94 'No need to create directory.'.format(parent_dir))
95 os.mkdir(parent_dir)
96
97- if not os.path.exists(dest_dir):
98- juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
99- repo_dir = install_remote(repo, dest=parent_dir, branch=branch,
100- depth=depth)
101- else:
102- repo_dir = dest_dir
103+ juju_log('Cloning git repo: {}, branch: {}'.format(repo, branch))
104+ repo_dir = install_remote(repo, dest=parent_dir, branch=branch, depth=depth)
105
106 venv = os.path.join(parent_dir, 'venv')
107
108
109=== modified file 'charmhelpers/core/host.py'
110--- charmhelpers/core/host.py 2016-01-04 21:24:42 +0000
111+++ charmhelpers/core/host.py 2016-01-08 03:09:55 +0000
112@@ -72,7 +72,9 @@
113 stopped = service_stop(service_name)
114 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
115 sysv_file = os.path.join(initd_dir, service_name)
116- if os.path.exists(upstart_file):
117+ if init_is_systemd():
118+ service('disable', service_name)
119+ elif os.path.exists(upstart_file):
120 override_path = os.path.join(
121 init_dir, '{}.override'.format(service_name))
122 with open(override_path, 'w') as fh:
123@@ -80,9 +82,9 @@
124 elif os.path.exists(sysv_file):
125 subprocess.check_call(["update-rc.d", service_name, "disable"])
126 else:
127- # XXX: Support SystemD too
128 raise ValueError(
129- "Unable to detect {0} as either Upstart {1} or SysV {2}".format(
130+ "Unable to detect {0} as SystemD, Upstart {1} or"
131+ " SysV {2}".format(
132 service_name, upstart_file, sysv_file))
133 return stopped
134
135@@ -94,7 +96,9 @@
136 Reenable starting again at boot. Start the service"""
137 upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
138 sysv_file = os.path.join(initd_dir, service_name)
139- if os.path.exists(upstart_file):
140+ if init_is_systemd():
141+ service('enable', service_name)
142+ elif os.path.exists(upstart_file):
143 override_path = os.path.join(
144 init_dir, '{}.override'.format(service_name))
145 if os.path.exists(override_path):
146@@ -102,9 +106,9 @@
147 elif os.path.exists(sysv_file):
148 subprocess.check_call(["update-rc.d", service_name, "enable"])
149 else:
150- # XXX: Support SystemD too
151 raise ValueError(
152- "Unable to detect {0} as either Upstart {1} or SysV {2}".format(
153+ "Unable to detect {0} as SystemD, Upstart {1} or"
154+ " SysV {2}".format(
155 service_name, upstart_file, sysv_file))
156
157 started = service_running(service_name)
158@@ -115,23 +119,29 @@
159
160 def service(action, service_name):
161 """Control a system service"""
162- cmd = ['service', service_name, action]
163+ if init_is_systemd():
164+ cmd = ['systemctl', action, service_name]
165+ else:
166+ cmd = ['service', service_name, action]
167 return subprocess.call(cmd) == 0
168
169
170-def service_running(service):
171+def service_running(service_name):
172 """Determine whether a system service is running"""
173- try:
174- output = subprocess.check_output(
175- ['service', service, 'status'],
176- stderr=subprocess.STDOUT).decode('UTF-8')
177- except subprocess.CalledProcessError:
178- return False
179+ if init_is_systemd():
180+ return service('is-active', service_name)
181 else:
182- if ("start/running" in output or "is running" in output):
183- return True
184- else:
185+ try:
186+ output = subprocess.check_output(
187+ ['service', service_name, 'status'],
188+ stderr=subprocess.STDOUT).decode('UTF-8')
189+ except subprocess.CalledProcessError:
190 return False
191+ else:
192+ if ("start/running" in output or "is running" in output):
193+ return True
194+ else:
195+ return False
196
197
198 def service_available(service_name):
199@@ -146,6 +156,13 @@
200 return True
201
202
203+SYSTEMD_SYSTEM = '/run/systemd/system'
204+
205+
206+def init_is_systemd():
207+ return os.path.isdir(SYSTEMD_SYSTEM)
208+
209+
210 def adduser(username, password=None, shell='/bin/bash', system_user=False,
211 primary_group=None, secondary_groups=None):
212 """
213
214=== modified file 'charmhelpers/fetch/giturl.py'
215--- charmhelpers/fetch/giturl.py 2016-01-04 21:24:42 +0000
216+++ charmhelpers/fetch/giturl.py 2016-01-08 03:09:55 +0000
217@@ -22,7 +22,6 @@
218 filter_installed_packages,
219 apt_install,
220 )
221-from charmhelpers.core.host import mkdir
222
223 if filter_installed_packages(['git']) != []:
224 apt_install(['git'])
225@@ -62,8 +61,6 @@
226 else:
227 dest_dir = os.path.join(os.environ.get('CHARM_DIR'), "fetched",
228 branch_name)
229- if not os.path.exists(dest_dir):
230- mkdir(dest_dir, perms=0o755)
231 try:
232 self.clone(source, dest_dir, branch, depth)
233 except OSError as e:

Subscribers

People subscribed via source and target branches