Merge lp:~hopem/charms/precise/nova-compute/lp1273067 into lp:~openstack-charmers-archive/charms/precise/nova-compute/trunk

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 56
Proposed branch: lp:~hopem/charms/precise/nova-compute/lp1273067
Merge into: lp:~openstack-charmers-archive/charms/precise/nova-compute/trunk
Diff against target: 466 lines (+151/-42)
11 files modified
hooks/charmhelpers/contrib/hahelpers/cluster.py (+4/-4)
hooks/charmhelpers/contrib/openstack/context.py (+37/-11)
hooks/charmhelpers/contrib/openstack/neutron.py (+28/-4)
hooks/charmhelpers/contrib/openstack/templates/ceph.conf (+5/-1)
hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg (+2/-3)
hooks/charmhelpers/contrib/openstack/utils.py (+16/-13)
hooks/charmhelpers/contrib/storage/linux/ceph.py (+6/-2)
hooks/charmhelpers/contrib/storage/linux/utils.py (+2/-1)
hooks/charmhelpers/core/host.py (+9/-3)
hooks/charmhelpers/fetch/__init__.py (+27/-0)
hooks/charmhelpers/fetch/archiveurl.py (+15/-0)
To merge this branch: bzr merge lp:~hopem/charms/precise/nova-compute/lp1273067
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+212826@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Page (james-page) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/charmhelpers/contrib/hahelpers/cluster.py'
2--- hooks/charmhelpers/contrib/hahelpers/cluster.py 2013-08-14 16:13:38 +0000
3+++ hooks/charmhelpers/contrib/hahelpers/cluster.py 2014-03-26 11:39:18 +0000
4@@ -126,17 +126,17 @@
5 return public_port - (i * 10)
6
7
8-def determine_haproxy_port(public_port):
9+def determine_apache_port(public_port):
10 '''
11- Description: Determine correct proxy listening port based on public IP +
12- existence of HTTPS reverse proxy.
13+ Description: Determine correct apache listening port based on public IP +
14+ state of the cluster.
15
16 public_port: int: standard public port for given service
17
18 returns: int: the correct listening port for the HAProxy service
19 '''
20 i = 0
21- if https():
22+ if len(peer_units()) > 0 or is_clustered():
23 i += 1
24 return public_port - (i * 10)
25
26
27=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
28--- hooks/charmhelpers/contrib/openstack/context.py 2014-02-13 08:29:21 +0000
29+++ hooks/charmhelpers/contrib/openstack/context.py 2014-03-26 11:39:18 +0000
30@@ -26,11 +26,10 @@
31 )
32
33 from charmhelpers.contrib.hahelpers.cluster import (
34+ determine_apache_port,
35 determine_api_port,
36- determine_haproxy_port,
37 https,
38- is_clustered,
39- peer_units,
40+ is_clustered
41 )
42
43 from charmhelpers.contrib.hahelpers.apache import (
44@@ -200,6 +199,7 @@
45
46 ctxt = {}
47 for rid in relation_ids('amqp'):
48+ ha_vip_only = False
49 for unit in related_units(rid):
50 if relation_get('clustered', rid=rid, unit=unit):
51 ctxt['clustered'] = True
52@@ -214,11 +214,18 @@
53 unit=unit),
54 'rabbitmq_virtual_host': vhost,
55 })
56+ if relation_get('ha_queues', rid=rid, unit=unit) is not None:
57+ ctxt['rabbitmq_ha_queues'] = True
58+
59+ ha_vip_only = relation_get('ha-vip-only',
60+ rid=rid, unit=unit) is not None
61+
62 if context_complete(ctxt):
63 # Sufficient information found = break out!
64 break
65 # Used for active/active rabbitmq >= grizzly
66- if 'clustered' not in ctxt and len(related_units(rid)) > 1:
67+ if ('clustered' not in ctxt or ha_vip_only) \
68+ and len(related_units(rid)) > 1:
69 rabbitmq_hosts = []
70 for unit in related_units(rid):
71 rabbitmq_hosts.append(relation_get('private-address',
72@@ -237,10 +244,13 @@
73 '''This generates context for /etc/ceph/ceph.conf templates'''
74 if not relation_ids('ceph'):
75 return {}
76+
77 log('Generating template context for ceph')
78+
79 mon_hosts = []
80 auth = None
81 key = None
82+ use_syslog = str(config('use-syslog')).lower()
83 for rid in relation_ids('ceph'):
84 for unit in related_units(rid):
85 mon_hosts.append(relation_get('private-address', rid=rid,
86@@ -252,6 +262,7 @@
87 'mon_hosts': ' '.join(mon_hosts),
88 'auth': auth,
89 'key': key,
90+ 'use_syslog': use_syslog
91 }
92
93 if not os.path.isdir('/etc/ceph'):
94@@ -380,17 +391,15 @@
95 'private_address': unit_get('private-address'),
96 'endpoints': []
97 }
98- for ext_port in self.external_ports:
99- if peer_units() or is_clustered():
100- int_port = determine_haproxy_port(ext_port)
101- else:
102- int_port = determine_api_port(ext_port)
103+ for api_port in self.external_ports:
104+ ext_port = determine_apache_port(api_port)
105+ int_port = determine_api_port(api_port)
106 portmap = (int(ext_port), int(int_port))
107 ctxt['endpoints'].append(portmap)
108 return ctxt
109
110
111-class NeutronContext(object):
112+class NeutronContext(OSContextGenerator):
113 interfaces = []
114
115 @property
116@@ -451,6 +460,22 @@
117
118 return nvp_ctxt
119
120+ def neutron_ctxt(self):
121+ if https():
122+ proto = 'https'
123+ else:
124+ proto = 'http'
125+ if is_clustered():
126+ host = config('vip')
127+ else:
128+ host = unit_get('private-address')
129+ url = '%s://%s:%s' % (proto, host, '9696')
130+ ctxt = {
131+ 'network_manager': self.network_manager,
132+ 'neutron_url': url,
133+ }
134+ return ctxt
135+
136 def __call__(self):
137 self._ensure_packages()
138
139@@ -460,7 +485,7 @@
140 if not self.plugin:
141 return {}
142
143- ctxt = {'network_manager': self.network_manager}
144+ ctxt = self.neutron_ctxt()
145
146 if self.plugin == 'ovs':
147 ctxt.update(self.ovs_ctxt())
148@@ -586,6 +611,7 @@
149
150
151 class SyslogContext(OSContextGenerator):
152+
153 def __call__(self):
154 ctxt = {
155 'use_syslog': config('use-syslog')
156
157=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
158--- hooks/charmhelpers/contrib/openstack/neutron.py 2013-10-22 23:02:45 +0000
159+++ hooks/charmhelpers/contrib/openstack/neutron.py 2014-03-26 11:39:18 +0000
160@@ -18,6 +18,22 @@
161 return 'linux-headers-%s' % kver
162
163
164+def kernel_version():
165+ """ Retrieve the current major kernel version as a tuple e.g. (3, 13) """
166+ kver = check_output(['uname', '-r']).strip()
167+ kver = kver.split('.')
168+ return (int(kver[0]), int(kver[1]))
169+
170+
171+def determine_dkms_package():
172+ """ Determine which DKMS package should be used based on kernel version """
173+ # NOTE: 3.13 kernels have support for GRE and VXLAN native
174+ if kernel_version() >= (3, 13):
175+ return []
176+ else:
177+ return ['openvswitch-datapath-dkms']
178+
179+
180 # legacy
181 def quantum_plugins():
182 from charmhelpers.contrib.openstack import context
183@@ -32,7 +48,7 @@
184 database=config('neutron-database'),
185 relation_prefix='neutron')],
186 'services': ['quantum-plugin-openvswitch-agent'],
187- 'packages': [[headers_package(), 'openvswitch-datapath-dkms'],
188+ 'packages': [[headers_package()] + determine_dkms_package(),
189 ['quantum-plugin-openvswitch-agent']],
190 'server_packages': ['quantum-server',
191 'quantum-plugin-openvswitch'],
192@@ -57,7 +73,8 @@
193
194 def neutron_plugins():
195 from charmhelpers.contrib.openstack import context
196- return {
197+ release = os_release('nova-common')
198+ plugins = {
199 'ovs': {
200 'config': '/etc/neutron/plugins/openvswitch/'
201 'ovs_neutron_plugin.ini',
202@@ -68,8 +85,8 @@
203 database=config('neutron-database'),
204 relation_prefix='neutron')],
205 'services': ['neutron-plugin-openvswitch-agent'],
206- 'packages': [[headers_package(), 'openvswitch-datapath-dkms'],
207- ['quantum-plugin-openvswitch-agent']],
208+ 'packages': [[headers_package()] + determine_dkms_package(),
209+ ['neutron-plugin-openvswitch-agent']],
210 'server_packages': ['neutron-server',
211 'neutron-plugin-openvswitch'],
212 'server_services': ['neutron-server']
213@@ -89,6 +106,13 @@
214 'server_services': ['neutron-server']
215 }
216 }
217+ # NOTE: patch in ml2 plugin for icehouse onwards
218+ if release >= 'icehouse':
219+ plugins['ovs']['config'] = '/etc/neutron/plugins/ml2/ml2_conf.ini'
220+ plugins['ovs']['driver'] = 'neutron.plugins.ml2.plugin.Ml2Plugin'
221+ plugins['ovs']['server_packages'] = ['neutron-server',
222+ 'neutron-plugin-ml2']
223+ return plugins
224
225
226 def neutron_plugin_attribute(plugin, attr, net_manager=None):
227
228=== modified file 'hooks/charmhelpers/contrib/openstack/templates/ceph.conf'
229--- hooks/charmhelpers/contrib/openstack/templates/ceph.conf 2013-08-12 21:48:24 +0000
230+++ hooks/charmhelpers/contrib/openstack/templates/ceph.conf 2014-03-26 11:39:18 +0000
231@@ -3,9 +3,13 @@
232 # cinder configuration file maintained by Juju
233 # local changes may be overwritten.
234 ###############################################################################
235+[global]
236 {% if auth -%}
237-[global]
238 auth_supported = {{ auth }}
239 keyring = /etc/ceph/$cluster.$name.keyring
240 mon host = {{ mon_hosts }}
241 {% endif -%}
242+ log to syslog = {{ use_syslog }}
243+ err to syslog = {{ use_syslog }}
244+ clog to syslog = {{ use_syslog }}
245+
246
247=== modified file 'hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg'
248--- hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2013-08-12 21:48:24 +0000
249+++ hooks/charmhelpers/contrib/openstack/templates/haproxy.cfg 2014-03-26 11:39:18 +0000
250@@ -8,8 +8,8 @@
251
252 defaults
253 log global
254- mode http
255- option httplog
256+ mode tcp
257+ option tcplog
258 option dontlognull
259 retries 3
260 timeout queue 1000
261@@ -29,7 +29,6 @@
262 {% for service, ports in service_ports.iteritems() -%}
263 listen {{ service }} 0.0.0.0:{{ ports[0] }}
264 balance roundrobin
265- option tcplog
266 {% for unit, address in units.iteritems() -%}
267 server {{ unit }} {{ address }}:{{ ports[1] }} check
268 {% endfor %}
269
270=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
271--- hooks/charmhelpers/contrib/openstack/utils.py 2014-02-13 08:29:21 +0000
272+++ hooks/charmhelpers/contrib/openstack/utils.py 2014-03-26 11:39:18 +0000
273@@ -65,6 +65,9 @@
274 ('1.10.0', 'havana'),
275 ('1.9.1', 'havana'),
276 ('1.9.0', 'havana'),
277+ ('1.13.0', 'icehouse'),
278+ ('1.12.0', 'icehouse'),
279+ ('1.11.0', 'icehouse'),
280 ])
281
282 DEFAULT_LOOPBACK_SIZE = '5G'
283@@ -420,19 +423,19 @@
284 Resolves hostname for given IP, or returns the input
285 if it is already a hostname.
286 """
287- if not is_ip(address):
288- return address
289-
290- try:
291- import dns.reversename
292- except ImportError:
293- apt_install('python-dnspython')
294- import dns.reversename
295-
296- rev = dns.reversename.from_address(address)
297- result = ns_query(rev)
298- if not result:
299- return None
300+ if is_ip(address):
301+ try:
302+ import dns.reversename
303+ except ImportError:
304+ apt_install('python-dnspython')
305+ import dns.reversename
306+
307+ rev = dns.reversename.from_address(address)
308+ result = ns_query(rev)
309+ if not result:
310+ return None
311+ else:
312+ result = address
313
314 if fqdn:
315 # strip trailing .
316
317=== modified file 'hooks/charmhelpers/contrib/storage/linux/ceph.py'
318--- hooks/charmhelpers/contrib/storage/linux/ceph.py 2013-11-06 03:50:44 +0000
319+++ hooks/charmhelpers/contrib/storage/linux/ceph.py 2014-03-26 11:39:18 +0000
320@@ -49,6 +49,9 @@
321 auth supported = {auth}
322 keyring = {keyring}
323 mon host = {mon_hosts}
324+ log to syslog = {use_syslog}
325+ err to syslog = {use_syslog}
326+ clog to syslog = {use_syslog}
327 """
328
329
330@@ -194,7 +197,7 @@
331 return hosts
332
333
334-def configure(service, key, auth):
335+def configure(service, key, auth, use_syslog):
336 ''' Perform basic configuration of Ceph '''
337 create_keyring(service, key)
338 create_key_file(service, key)
339@@ -202,7 +205,8 @@
340 with open('/etc/ceph/ceph.conf', 'w') as ceph_conf:
341 ceph_conf.write(CEPH_CONF.format(auth=auth,
342 keyring=_keyring_path(service),
343- mon_hosts=",".join(map(str, hosts))))
344+ mon_hosts=",".join(map(str, hosts)),
345+ use_syslog=use_syslog))
346 modprobe('rbd')
347
348
349
350=== modified file 'hooks/charmhelpers/contrib/storage/linux/utils.py'
351--- hooks/charmhelpers/contrib/storage/linux/utils.py 2014-02-13 08:29:21 +0000
352+++ hooks/charmhelpers/contrib/storage/linux/utils.py 2014-03-26 11:39:18 +0000
353@@ -22,4 +22,5 @@
354
355 :param block_device: str: Full path of block device to clean.
356 '''
357- check_call(['sgdisk', '--zap-all', '--mbrtogpt', block_device])
358+ check_call(['sgdisk', '--zap-all', '--clear',
359+ '--mbrtogpt', block_device])
360
361=== modified file 'hooks/charmhelpers/core/host.py'
362--- hooks/charmhelpers/core/host.py 2014-02-13 08:29:21 +0000
363+++ hooks/charmhelpers/core/host.py 2014-03-26 11:39:18 +0000
364@@ -194,7 +194,7 @@
365 return None
366
367
368-def restart_on_change(restart_map):
369+def restart_on_change(restart_map, stopstart=False):
370 """Restart services based on configuration files changing
371
372 This function is used a decorator, for example
373@@ -219,8 +219,14 @@
374 for path in restart_map:
375 if checksums[path] != file_hash(path):
376 restarts += restart_map[path]
377- for service_name in list(OrderedDict.fromkeys(restarts)):
378- service('restart', service_name)
379+ services_list = list(OrderedDict.fromkeys(restarts))
380+ if not stopstart:
381+ for service_name in services_list:
382+ service('restart', service_name)
383+ else:
384+ for action in ['stop', 'start']:
385+ for service_name in services_list:
386+ service(action, service_name)
387 return wrapped_f
388 return wrap
389
390
391=== modified file 'hooks/charmhelpers/fetch/__init__.py'
392--- hooks/charmhelpers/fetch/__init__.py 2014-02-13 08:29:21 +0000
393+++ hooks/charmhelpers/fetch/__init__.py 2014-03-26 11:39:18 +0000
394@@ -97,6 +97,29 @@
395 subprocess.call(cmd, env=env)
396
397
398+def apt_upgrade(options=None, fatal=False, dist=False):
399+ """Upgrade all packages"""
400+ if options is None:
401+ options = ['--option=Dpkg::Options::=--force-confold']
402+
403+ cmd = ['apt-get', '--assume-yes']
404+ cmd.extend(options)
405+ if dist:
406+ cmd.append('dist-upgrade')
407+ else:
408+ cmd.append('upgrade')
409+ log("Upgrading with options: {}".format(options))
410+
411+ env = os.environ.copy()
412+ if 'DEBIAN_FRONTEND' not in env:
413+ env['DEBIAN_FRONTEND'] = 'noninteractive'
414+
415+ if fatal:
416+ subprocess.check_call(cmd, env=env)
417+ else:
418+ subprocess.call(cmd, env=env)
419+
420+
421 def apt_update(fatal=False):
422 """Update local apt cache"""
423 cmd = ['apt-get', 'update']
424@@ -135,6 +158,10 @@
425
426
427 def add_source(source, key=None):
428+ if source is None:
429+ log('Source is not present. Skipping')
430+ return
431+
432 if (source.startswith('ppa:') or
433 source.startswith('http') or
434 source.startswith('deb ') or
435
436=== modified file 'hooks/charmhelpers/fetch/archiveurl.py'
437--- hooks/charmhelpers/fetch/archiveurl.py 2013-09-23 13:23:51 +0000
438+++ hooks/charmhelpers/fetch/archiveurl.py 2014-03-26 11:39:18 +0000
439@@ -1,5 +1,7 @@
440 import os
441 import urllib2
442+import urlparse
443+
444 from charmhelpers.fetch import (
445 BaseFetchHandler,
446 UnhandledSource
447@@ -24,6 +26,19 @@
448 def download(self, source, dest):
449 # propogate all exceptions
450 # URLError, OSError, etc
451+ proto, netloc, path, params, query, fragment = urlparse.urlparse(source)
452+ if proto in ('http', 'https'):
453+ auth, barehost = urllib2.splituser(netloc)
454+ if auth is not None:
455+ source = urlparse.urlunparse((proto, barehost, path, params, query, fragment))
456+ username, password = urllib2.splitpasswd(auth)
457+ passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
458+ # Realm is set to None in add_password to force the username and password
459+ # to be used whatever the realm
460+ passman.add_password(None, source, username, password)
461+ authhandler = urllib2.HTTPBasicAuthHandler(passman)
462+ opener = urllib2.build_opener(authhandler)
463+ urllib2.install_opener(opener)
464 response = urllib2.urlopen(source)
465 try:
466 with open(dest, 'w') as dest_file:

Subscribers

People subscribed via source and target branches