Merge lp:~hopem/charms/precise/quantum-gateway/lp1273067 into lp:charms/quantum-gateway

Proposed by Edward Hope-Morley
Status: Merged
Merged at revision: 46
Proposed branch: lp:~hopem/charms/precise/quantum-gateway/lp1273067
Merge into: lp:charms/quantum-gateway
Diff against target: 412 lines (+134/-32)
15 files modified
config.yaml (+5/-0)
hooks/charmhelpers/contrib/openstack/context.py (+9/-6)
hooks/charmhelpers/contrib/openstack/neutron.py (+28/-4)
hooks/charmhelpers/contrib/openstack/utils.py (+16/-13)
hooks/charmhelpers/contrib/storage/linux/utils.py (+2/-1)
hooks/charmhelpers/fetch/__init__.py (+23/-0)
hooks/charmhelpers/fetch/archiveurl.py (+15/-0)
hooks/quantum_utils.py (+9/-3)
revision (+1/-1)
templates/folsom/metadata_agent.ini (+1/-1)
templates/folsom/nova.conf (+1/-0)
templates/folsom/quantum.conf (+1/-0)
templates/havana/neutron.conf (+1/-0)
templates/havana/nova.conf (+1/-0)
unit_tests/test_quantum_contexts.py (+21/-3)
To merge this branch: bzr merge lp:~hopem/charms/precise/quantum-gateway/lp1273067
Reviewer Review Type Date Requested Status
Edward Hope-Morley Approve
Review via email: mp+212717@code.launchpad.net

Description of the change

The is part of a resubmit for all the charm use-syslog patches since the previous attempts were getting messy

To post a comment you must log in.
48. By Edward Hope-Morley

[hopem] removed extraneous use_syslog from .ini files since neutron.conf & quantum.conf should suffice

Revision history for this message
Edward Hope-Morley (hopem) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2014-03-14 13:16:57 +0000
3+++ config.yaml 2014-03-26 11:07:00 +0000
4@@ -50,6 +50,11 @@
5 type: string
6 description: RabbitMQ Virtual Host
7 default: openstack
8+ use-syslog:
9+ type: boolean
10+ default: False
11+ description: |
12+ If set to True, supporting services will log to syslog.
13 instance-mtu:
14 type: int
15 description: |
16
17=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
18--- hooks/charmhelpers/contrib/openstack/context.py 2014-03-14 13:24:39 +0000
19+++ hooks/charmhelpers/contrib/openstack/context.py 2014-03-26 11:07:00 +0000
20@@ -199,6 +199,7 @@
21
22 ctxt = {}
23 for rid in relation_ids('amqp'):
24+ ha_vip_only = False
25 for unit in related_units(rid):
26 if relation_get('clustered', rid=rid, unit=unit):
27 ctxt['clustered'] = True
28@@ -213,16 +214,18 @@
29 unit=unit),
30 'rabbitmq_virtual_host': vhost,
31 })
32+ if relation_get('ha_queues', rid=rid, unit=unit) is not None:
33+ ctxt['rabbitmq_ha_queues'] = True
34+
35+ ha_vip_only = relation_get('ha-vip-only',
36+ rid=rid, unit=unit) is not None
37+
38 if context_complete(ctxt):
39 # Sufficient information found = break out!
40 break
41 # Used for active/active rabbitmq >= grizzly
42- if ('clustered' not in ctxt or relation_get('ha-vip-only') == 'True') and \
43- len(related_units(rid)) > 1:
44- if relation_get('ha_queues'):
45- ctxt['rabbitmq_ha_queues'] = relation_get('ha_queues')
46- else:
47- ctxt['rabbitmq_ha_queues'] = False
48+ if ('clustered' not in ctxt or ha_vip_only) \
49+ and len(related_units(rid)) > 1:
50 rabbitmq_hosts = []
51 for unit in related_units(rid):
52 rabbitmq_hosts.append(relation_get('private-address',
53
54=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
55--- hooks/charmhelpers/contrib/openstack/neutron.py 2013-11-06 03:57:51 +0000
56+++ hooks/charmhelpers/contrib/openstack/neutron.py 2014-03-26 11:07:00 +0000
57@@ -18,6 +18,22 @@
58 return 'linux-headers-%s' % kver
59
60
61+def kernel_version():
62+ """ Retrieve the current major kernel version as a tuple e.g. (3, 13) """
63+ kver = check_output(['uname', '-r']).strip()
64+ kver = kver.split('.')
65+ return (int(kver[0]), int(kver[1]))
66+
67+
68+def determine_dkms_package():
69+ """ Determine which DKMS package should be used based on kernel version """
70+ # NOTE: 3.13 kernels have support for GRE and VXLAN native
71+ if kernel_version() >= (3, 13):
72+ return []
73+ else:
74+ return ['openvswitch-datapath-dkms']
75+
76+
77 # legacy
78 def quantum_plugins():
79 from charmhelpers.contrib.openstack import context
80@@ -32,7 +48,7 @@
81 database=config('neutron-database'),
82 relation_prefix='neutron')],
83 'services': ['quantum-plugin-openvswitch-agent'],
84- 'packages': [[headers_package(), 'openvswitch-datapath-dkms'],
85+ 'packages': [[headers_package()] + determine_dkms_package(),
86 ['quantum-plugin-openvswitch-agent']],
87 'server_packages': ['quantum-server',
88 'quantum-plugin-openvswitch'],
89@@ -57,7 +73,8 @@
90
91 def neutron_plugins():
92 from charmhelpers.contrib.openstack import context
93- return {
94+ release = os_release('nova-common')
95+ plugins = {
96 'ovs': {
97 'config': '/etc/neutron/plugins/openvswitch/'
98 'ovs_neutron_plugin.ini',
99@@ -68,8 +85,8 @@
100 database=config('neutron-database'),
101 relation_prefix='neutron')],
102 'services': ['neutron-plugin-openvswitch-agent'],
103- 'packages': [[headers_package(), 'openvswitch-datapath-dkms'],
104- ['quantum-plugin-openvswitch-agent']],
105+ 'packages': [[headers_package()] + determine_dkms_package(),
106+ ['neutron-plugin-openvswitch-agent']],
107 'server_packages': ['neutron-server',
108 'neutron-plugin-openvswitch'],
109 'server_services': ['neutron-server']
110@@ -89,6 +106,13 @@
111 'server_services': ['neutron-server']
112 }
113 }
114+ # NOTE: patch in ml2 plugin for icehouse onwards
115+ if release >= 'icehouse':
116+ plugins['ovs']['config'] = '/etc/neutron/plugins/ml2/ml2_conf.ini'
117+ plugins['ovs']['driver'] = 'neutron.plugins.ml2.plugin.Ml2Plugin'
118+ plugins['ovs']['server_packages'] = ['neutron-server',
119+ 'neutron-plugin-ml2']
120+ return plugins
121
122
123 def neutron_plugin_attribute(plugin, attr, net_manager=None):
124
125=== modified file 'hooks/charmhelpers/contrib/openstack/utils.py'
126--- hooks/charmhelpers/contrib/openstack/utils.py 2014-03-14 13:24:39 +0000
127+++ hooks/charmhelpers/contrib/openstack/utils.py 2014-03-26 11:07:00 +0000
128@@ -65,6 +65,9 @@
129 ('1.10.0', 'havana'),
130 ('1.9.1', 'havana'),
131 ('1.9.0', 'havana'),
132+ ('1.13.0', 'icehouse'),
133+ ('1.12.0', 'icehouse'),
134+ ('1.11.0', 'icehouse'),
135 ])
136
137 DEFAULT_LOOPBACK_SIZE = '5G'
138@@ -420,19 +423,19 @@
139 Resolves hostname for given IP, or returns the input
140 if it is already a hostname.
141 """
142- if not is_ip(address):
143- return address
144-
145- try:
146- import dns.reversename
147- except ImportError:
148- apt_install('python-dnspython')
149- import dns.reversename
150-
151- rev = dns.reversename.from_address(address)
152- result = ns_query(rev)
153- if not result:
154- return None
155+ if is_ip(address):
156+ try:
157+ import dns.reversename
158+ except ImportError:
159+ apt_install('python-dnspython')
160+ import dns.reversename
161+
162+ rev = dns.reversename.from_address(address)
163+ result = ns_query(rev)
164+ if not result:
165+ return None
166+ else:
167+ result = address
168
169 if fqdn:
170 # strip trailing .
171
172=== modified file 'hooks/charmhelpers/contrib/storage/linux/utils.py'
173--- hooks/charmhelpers/contrib/storage/linux/utils.py 2014-03-14 13:24:39 +0000
174+++ hooks/charmhelpers/contrib/storage/linux/utils.py 2014-03-26 11:07:00 +0000
175@@ -22,4 +22,5 @@
176
177 :param block_device: str: Full path of block device to clean.
178 '''
179- check_call(['sgdisk', '--zap-all', '--mbrtogpt', block_device])
180+ check_call(['sgdisk', '--zap-all', '--clear',
181+ '--mbrtogpt', block_device])
182
183=== modified file 'hooks/charmhelpers/fetch/__init__.py'
184--- hooks/charmhelpers/fetch/__init__.py 2014-03-14 13:24:39 +0000
185+++ hooks/charmhelpers/fetch/__init__.py 2014-03-26 11:07:00 +0000
186@@ -97,6 +97,29 @@
187 subprocess.call(cmd, env=env)
188
189
190+def apt_upgrade(options=None, fatal=False, dist=False):
191+ """Upgrade all packages"""
192+ if options is None:
193+ options = ['--option=Dpkg::Options::=--force-confold']
194+
195+ cmd = ['apt-get', '--assume-yes']
196+ cmd.extend(options)
197+ if dist:
198+ cmd.append('dist-upgrade')
199+ else:
200+ cmd.append('upgrade')
201+ log("Upgrading with options: {}".format(options))
202+
203+ env = os.environ.copy()
204+ if 'DEBIAN_FRONTEND' not in env:
205+ env['DEBIAN_FRONTEND'] = 'noninteractive'
206+
207+ if fatal:
208+ subprocess.check_call(cmd, env=env)
209+ else:
210+ subprocess.call(cmd, env=env)
211+
212+
213 def apt_update(fatal=False):
214 """Update local apt cache"""
215 cmd = ['apt-get', 'update']
216
217=== modified file 'hooks/charmhelpers/fetch/archiveurl.py'
218--- hooks/charmhelpers/fetch/archiveurl.py 2013-09-02 16:36:50 +0000
219+++ hooks/charmhelpers/fetch/archiveurl.py 2014-03-26 11:07:00 +0000
220@@ -1,5 +1,7 @@
221 import os
222 import urllib2
223+import urlparse
224+
225 from charmhelpers.fetch import (
226 BaseFetchHandler,
227 UnhandledSource
228@@ -24,6 +26,19 @@
229 def download(self, source, dest):
230 # propogate all exceptions
231 # URLError, OSError, etc
232+ proto, netloc, path, params, query, fragment = urlparse.urlparse(source)
233+ if proto in ('http', 'https'):
234+ auth, barehost = urllib2.splituser(netloc)
235+ if auth is not None:
236+ source = urlparse.urlunparse((proto, barehost, path, params, query, fragment))
237+ username, password = urllib2.splitpasswd(auth)
238+ passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
239+ # Realm is set to None in add_password to force the username and password
240+ # to be used whatever the realm
241+ passman.add_password(None, source, username, password)
242+ authhandler = urllib2.HTTPBasicAuthHandler(passman)
243+ opener = urllib2.build_opener(authhandler)
244+ urllib2.install_opener(opener)
245 response = urllib2.urlopen(source)
246 try:
247 with open(dest, 'w') as dest_file:
248
249=== modified file 'hooks/quantum_utils.py'
250--- hooks/quantum_utils.py 2014-03-14 13:24:39 +0000
251+++ hooks/quantum_utils.py 2014-03-26 11:07:00 +0000
252@@ -25,6 +25,9 @@
253 )
254
255 import charmhelpers.contrib.openstack.context as context
256+from charmhelpers.contrib.openstack.context import (
257+ SyslogContext
258+)
259 import charmhelpers.contrib.openstack.templating as templating
260 from charmhelpers.contrib.openstack.neutron import headers_package
261 from quantum_contexts import (
262@@ -150,7 +153,8 @@
263 'hook_contexts': [context.AMQPContext(),
264 QuantumSharedDBContext(),
265 NetworkServiceContext(),
266- QuantumGatewayContext()],
267+ QuantumGatewayContext(),
268+ SyslogContext()],
269 'services': ['nova-api-metadata']
270 },
271 }
272@@ -188,7 +192,8 @@
273 QUANTUM_OVS_CONFIG_FILES = {
274 QUANTUM_CONF: {
275 'hook_contexts': [context.AMQPContext(),
276- QuantumGatewayContext()],
277+ QuantumGatewayContext(),
278+ SyslogContext()],
279 'services': ['quantum-l3-agent',
280 'quantum-dhcp-agent',
281 'quantum-metadata-agent',
282@@ -214,7 +219,8 @@
283 NEUTRON_OVS_CONFIG_FILES = {
284 NEUTRON_CONF: {
285 'hook_contexts': [context.AMQPContext(),
286- QuantumGatewayContext()],
287+ QuantumGatewayContext(),
288+ SyslogContext()],
289 'services': ['neutron-l3-agent',
290 'neutron-dhcp-agent',
291 'neutron-metadata-agent',
292
293=== modified file 'revision'
294--- revision 2014-03-14 13:24:39 +0000
295+++ revision 2014-03-26 11:07:00 +0000
296@@ -1,1 +1,1 @@
297-63
298+64
299\ No newline at end of file
300
301=== modified file 'templates/folsom/metadata_agent.ini'
302--- templates/folsom/metadata_agent.ini 2013-09-04 09:46:54 +0000
303+++ templates/folsom/metadata_agent.ini 2014-03-26 11:07:00 +0000
304@@ -14,4 +14,4 @@
305 # shared secret to prevent spoofing. You may select any string for a secret,
306 # but it must match here and in the configuration used by the Nova Metadata
307 # Server. NOTE: Nova uses a different key: quantum_metadata_proxy_shared_secret
308-metadata_proxy_shared_secret = {{ shared_secret }}
309+metadata_proxy_shared_secret = {{ shared_secret }}
310\ No newline at end of file
311
312=== modified file 'templates/folsom/nova.conf'
313--- templates/folsom/nova.conf 2013-09-04 09:46:54 +0000
314+++ templates/folsom/nova.conf 2014-03-26 11:07:00 +0000
315@@ -4,6 +4,7 @@
316 lock_path=/var/lock/nova
317 root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf
318 verbose=True
319+use_syslog = {{ use_syslog }}
320 api_paste_config=/etc/nova/api-paste.ini
321 enabled_apis=metadata
322 multi_host=True
323
324=== modified file 'templates/folsom/quantum.conf'
325--- templates/folsom/quantum.conf 2013-09-04 09:46:54 +0000
326+++ templates/folsom/quantum.conf 2014-03-26 11:07:00 +0000
327@@ -5,6 +5,7 @@
328 rabbit_host = {{ rabbitmq_host }}
329 rabbit_password = {{ rabbitmq_password }}
330 debug = True
331+use_syslog = {{ use_syslog }}
332 bind_host = 0.0.0.0
333 bind_port = 9696
334 core_plugin = {{ core_plugin }}
335
336=== modified file 'templates/havana/neutron.conf'
337--- templates/havana/neutron.conf 2013-09-04 09:46:54 +0000
338+++ templates/havana/neutron.conf 2014-03-26 11:07:00 +0000
339@@ -5,6 +5,7 @@
340 rabbit_host = {{ rabbitmq_host }}
341 rabbit_password = {{ rabbitmq_password }}
342 debug = True
343+use_syslog = {{ use_syslog }}
344 bind_host = 0.0.0.0
345 bind_port = 9696
346 core_plugin = {{ core_plugin }}
347
348=== modified file 'templates/havana/nova.conf'
349--- templates/havana/nova.conf 2013-09-04 09:46:54 +0000
350+++ templates/havana/nova.conf 2014-03-26 11:07:00 +0000
351@@ -4,6 +4,7 @@
352 lock_path=/var/lock/nova
353 root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf
354 verbose=True
355+use_syslog = {{ use_syslog }}
356 api_paste_config=/etc/nova/api-paste.ini
357 enabled_apis=metadata
358 multi_host=True
359
360=== modified file 'unit_tests/test_quantum_contexts.py'
361--- unit_tests/test_quantum_contexts.py 2014-03-14 13:24:39 +0000
362+++ unit_tests/test_quantum_contexts.py 2014-03-26 11:07:00 +0000
363@@ -1,5 +1,10 @@
364-from mock import MagicMock, patch
365+from mock import (
366+ Mock,
367+ MagicMock,
368+ patch
369+)
370 import quantum_contexts
371+import sys
372 from contextlib import contextmanager
373
374 from test_utils import (
375@@ -199,6 +204,7 @@
376 def setUp(self):
377 super(TestQuantumGatewayContext, self).setUp(quantum_contexts,
378 TO_PATCH)
379+ self.config.side_effect = self.test_config.get
380
381 @patch.object(quantum_contexts, 'get_shared_secret')
382 @patch.object(quantum_contexts, 'get_host_ip')
383@@ -256,6 +262,19 @@
384 super(TestHostIP, self).setUp(quantum_contexts,
385 TO_PATCH)
386 self.config.side_effect = self.test_config.get
387+ # Save and inject
388+ self.mods = {'dns': None, 'dns.resolver': None}
389+ for mod in self.mods:
390+ if mod not in sys.modules:
391+ sys.modules[mod] = Mock()
392+ else:
393+ del self.mods[mod]
394+
395+ def tearDown(self):
396+ super(TestHostIP, self).tearDown()
397+ # Cleanup
398+ for mod in self.mods.keys():
399+ del sys.modules[mod]
400
401 def test_get_host_ip_already_ip(self):
402 self.assertEquals(quantum_contexts.get_host_ip('10.5.0.1'),
403@@ -268,8 +287,7 @@
404
405 @patch('dns.resolver.query')
406 def test_get_host_ip_hostname_unresolvable(self, _query):
407- class NXDOMAIN(Exception):
408- pass
409+ class NXDOMAIN(Exception): pass
410 _query.side_effect = NXDOMAIN()
411 self.assertRaises(NXDOMAIN, quantum_contexts.get_host_ip,
412 'missing.example.com')

Subscribers

People subscribed via source and target branches