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

Proposed by Corey Bryant
Status: Merged
Merged at revision: 208
Proposed branch: lp:~corey.bryant/charms/trusty/nova-cloud-controller/git-1531612
Merge into: lp:~openstack-charmers-archive/charms/trusty/nova-cloud-controller/next
Diff against target: 246 lines (+56/-34)
6 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)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/nova-cloud-controller/git-1531612
Reviewer Review Type Date Requested Status
Liam Young (community) Approve
Review via email: mp+281962@code.launchpad.net
To post a comment you must log in.
Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_lint_check #16810 nova-cloud-controller-next for corey.bryant mp281962
    LINT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_unit_test #15699 nova-cloud-controller-next for corey.bryant mp281962
    UNIT OK: passed

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

Revision history for this message
uosci-testing-bot (uosci-testing-bot) wrote :

charm_amulet_test #8581 nova-cloud-controller-next for corey.bryant mp281962
    AMULET OK: passed

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

Revision history for this message
Liam Young (gnuoy) wrote :

Approve

Revision history for this message
Liam Young (gnuoy) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charm-helpers-hooks.yaml'
2--- charm-helpers-hooks.yaml 2015-07-31 13:10:41 +0000
3+++ charm-helpers-hooks.yaml 2016-01-08 03:12:58 +0000
4@@ -8,7 +8,7 @@
5 - contrib.storage
6 - contrib.peerstorage
7 - contrib.hahelpers
8- - payload.execd
9+ - payload
10 - contrib.network.ip
11 - contrib.peerstorage
12 - contrib.python.packages
13
14=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
15--- hooks/charmhelpers/contrib/openstack/context.py 2016-01-04 21:29:34 +0000
16+++ hooks/charmhelpers/contrib/openstack/context.py 2016-01-08 03:12:58 +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 22:44:00 +0000
58+++ hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2016-01-08 03:12:58 +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:43:58 +0000
79+++ hooks/charmhelpers/contrib/openstack/utils.py 2016-01-08 03:12:58 +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:29:34 +0000
124+++ hooks/charmhelpers/core/host.py 2016-01-08 03:12:58 +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:29:34 +0000
229+++ hooks/charmhelpers/fetch/giturl.py 2016-01-08 03:12:58 +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:

Subscribers

People subscribed via source and target branches