Merge lp:~openstack-charmers/charms/precise/cinder/active-active into lp:~openstack-charmers-archive/charms/precise/cinder/trunk

Proposed by Edward Hope-Morley
Status: Work in progress
Proposed branch: lp:~openstack-charmers/charms/precise/cinder/active-active
Merge into: lp:~openstack-charmers-archive/charms/precise/cinder/trunk
Diff against target: 356 lines (+159/-33)
5 files modified
hooks/charmhelpers/contrib/hahelpers/apache.py (+9/-8)
hooks/charmhelpers/contrib/openstack/context.py (+68/-21)
hooks/charmhelpers/contrib/openstack/neutron.py (+14/-4)
hooks/cinder_hooks.py (+8/-0)
templates/grizzly/cinder.conf (+60/-0)
To merge this branch: bzr merge lp:~openstack-charmers/charms/precise/cinder/active-active
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+213043@code.launchpad.net
To post a comment you must log in.
48. By Edward Hope-Morley

[hopem] set charm-helpers.yaml to point to trunk and synced charm-helpers

Unmerged revisions

48. By Edward Hope-Morley

[hopem] set charm-helpers.yaml to point to trunk and synced charm-helpers

47. By Edward Hope-Morley

[hopem] synced charm-helpers

46. By Edward Hope-Morley

[hopem] updated from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added symlink 'hooks/amqp-relation-departed'
=== target is u'cinder_hooks.py'
=== modified file 'hooks/charmhelpers/contrib/hahelpers/apache.py'
--- hooks/charmhelpers/contrib/hahelpers/apache.py 2013-10-17 21:48:08 +0000
+++ hooks/charmhelpers/contrib/hahelpers/apache.py 2014-03-28 10:00:55 +0000
@@ -39,14 +39,15 @@
3939
4040
41def get_ca_cert():41def get_ca_cert():
42 ca_cert = None42 ca_cert = config_get('ssl_ca')
43 log("Inspecting identity-service relations for CA SSL certificate.",43 if ca_cert is None:
44 level=INFO)44 log("Inspecting identity-service relations for CA SSL certificate.",
45 for r_id in relation_ids('identity-service'):45 level=INFO)
46 for unit in relation_list(r_id):46 for r_id in relation_ids('identity-service'):
47 if not ca_cert:47 for unit in relation_list(r_id):
48 ca_cert = relation_get('ca_cert',48 if ca_cert is None:
49 rid=r_id, unit=unit)49 ca_cert = relation_get('ca_cert',
50 rid=r_id, unit=unit)
50 return ca_cert51 return ca_cert
5152
5253
5354
=== modified file 'hooks/charmhelpers/contrib/openstack/context.py'
--- hooks/charmhelpers/contrib/openstack/context.py 2014-03-25 12:26:41 +0000
+++ hooks/charmhelpers/contrib/openstack/context.py 2014-03-28 10:00:55 +0000
@@ -1,5 +1,6 @@
1import json1import json
2import os2import os
3import time
34
4from base64 import b64decode5from base64 import b64decode
56
@@ -113,7 +114,8 @@
113class SharedDBContext(OSContextGenerator):114class SharedDBContext(OSContextGenerator):
114 interfaces = ['shared-db']115 interfaces = ['shared-db']
115116
116 def __init__(self, database=None, user=None, relation_prefix=None):117 def __init__(self,
118 database=None, user=None, relation_prefix=None, ssl_dir=None):
117 '''119 '''
118 Allows inspecting relation for settings prefixed with relation_prefix.120 Allows inspecting relation for settings prefixed with relation_prefix.
119 This is useful for parsing access for multiple databases returned via121 This is useful for parsing access for multiple databases returned via
@@ -122,6 +124,7 @@
122 self.relation_prefix = relation_prefix124 self.relation_prefix = relation_prefix
123 self.database = database125 self.database = database
124 self.user = user126 self.user = user
127 self.ssl_dir = ssl_dir
125128
126 def __call__(self):129 def __call__(self):
127 self.database = self.database or config('database')130 self.database = self.database or config('database')
@@ -139,19 +142,44 @@
139142
140 for rid in relation_ids('shared-db'):143 for rid in relation_ids('shared-db'):
141 for unit in related_units(rid):144 for unit in related_units(rid):
142 passwd = relation_get(password_setting, rid=rid, unit=unit)145 rdata = relation_get(rid=rid, unit=unit)
143 ctxt = {146 ctxt = {
144 'database_host': relation_get('db_host', rid=rid,147 'database_host': rdata.get('db_host'),
145 unit=unit),
146 'database': self.database,148 'database': self.database,
147 'database_user': self.user,149 'database_user': self.user,
148 'database_password': passwd,150 'database_password': rdata.get(password_setting)
149 }151 }
150 if context_complete(ctxt):152 if context_complete(ctxt):
153 db_ssl(rdata, ctxt, self.ssl_dir)
151 return ctxt154 return ctxt
152 return {}155 return {}
153156
154157
158def db_ssl(rdata, ctxt, ssl_dir):
159 if 'ssl_ca' in rdata and ssl_dir:
160 ca_path = os.path.join(ssl_dir, 'db-client.ca')
161 with open(ca_path, 'w') as fh:
162 fh.write(b64decode(rdata['ssl_ca']))
163 ctxt['database_ssl_ca'] = ca_path
164 elif 'ssl_ca' in rdata:
165 log("Charm not setup for ssl support but ssl ca found")
166 return ctxt
167 if 'ssl_cert' in rdata:
168 cert_path = os.path.join(
169 ssl_dir, 'db-client.cert')
170 if not os.path.exists(cert_path):
171 log("Waiting 1m for ssl client cert validity")
172 time.sleep(60)
173 with open(cert_path, 'w') as fh:
174 fh.write(b64decode(rdata['ssl_cert']))
175 ctxt['database_ssl_cert'] = cert_path
176 key_path = os.path.join(ssl_dir, 'db-client.key')
177 with open(key_path, 'w') as fh:
178 fh.write(b64decode(rdata['ssl_key']))
179 ctxt['database_ssl_key'] = key_path
180 return ctxt
181
182
155class IdentityServiceContext(OSContextGenerator):183class IdentityServiceContext(OSContextGenerator):
156 interfaces = ['identity-service']184 interfaces = ['identity-service']
157185
@@ -161,22 +189,19 @@
161189
162 for rid in relation_ids('identity-service'):190 for rid in relation_ids('identity-service'):
163 for unit in related_units(rid):191 for unit in related_units(rid):
192 rdata = relation_get(rid=rid, unit=unit)
164 ctxt = {193 ctxt = {
165 'service_port': relation_get('service_port', rid=rid,194 'service_port': rdata.get('service_port'),
166 unit=unit),195 'service_host': rdata.get('service_host'),
167 'service_host': relation_get('service_host', rid=rid,196 'auth_host': rdata.get('auth_host'),
168 unit=unit),197 'auth_port': rdata.get('auth_port'),
169 'auth_host': relation_get('auth_host', rid=rid, unit=unit),198 'admin_tenant_name': rdata.get('service_tenant'),
170 'auth_port': relation_get('auth_port', rid=rid, unit=unit),199 'admin_user': rdata.get('service_username'),
171 'admin_tenant_name': relation_get('service_tenant',200 'admin_password': rdata.get('service_password'),
172 rid=rid, unit=unit),201 'service_protocol':
173 'admin_user': relation_get('service_username', rid=rid,202 rdata.get('service_protocol') or 'http',
174 unit=unit),203 'auth_protocol':
175 'admin_password': relation_get('service_password', rid=rid,204 rdata.get('auth_protocol') or 'http',
176 unit=unit),
177 # XXX: Hard-coded http.
178 'service_protocol': 'http',
179 'auth_protocol': 'http',
180 }205 }
181 if context_complete(ctxt):206 if context_complete(ctxt):
182 return ctxt207 return ctxt
@@ -186,6 +211,9 @@
186class AMQPContext(OSContextGenerator):211class AMQPContext(OSContextGenerator):
187 interfaces = ['amqp']212 interfaces = ['amqp']
188213
214 def __init__(self, ssl_dir=None):
215 self.ssl_dir = ssl_dir
216
189 def __call__(self):217 def __call__(self):
190 log('Generating template context for amqp')218 log('Generating template context for amqp')
191 conf = config()219 conf = config()
@@ -196,7 +224,6 @@
196 log('Could not generate shared_db context. '224 log('Could not generate shared_db context. '
197 'Missing required charm config options: %s.' % e)225 'Missing required charm config options: %s.' % e)
198 raise OSContextError226 raise OSContextError
199
200 ctxt = {}227 ctxt = {}
201 for rid in relation_ids('amqp'):228 for rid in relation_ids('amqp'):
202 ha_vip_only = False229 ha_vip_only = False
@@ -214,6 +241,14 @@
214 unit=unit),241 unit=unit),
215 'rabbitmq_virtual_host': vhost,242 'rabbitmq_virtual_host': vhost,
216 })243 })
244
245 ssl_port = relation_get('ssl_port', rid=rid, unit=unit)
246 if ssl_port:
247 ctxt['rabbit_ssl_port'] = ssl_port
248 ssl_ca = relation_get('ssl_ca', rid=rid, unit=unit)
249 if ssl_ca:
250 ctxt['rabbit_ssl_ca'] = ssl_ca
251
217 if relation_get('ha_queues', rid=rid, unit=unit) is not None:252 if relation_get('ha_queues', rid=rid, unit=unit) is not None:
218 ctxt['rabbitmq_ha_queues'] = True253 ctxt['rabbitmq_ha_queues'] = True
219254
@@ -221,6 +256,16 @@
221 rid=rid, unit=unit) is not None256 rid=rid, unit=unit) is not None
222257
223 if context_complete(ctxt):258 if context_complete(ctxt):
259 if 'rabbit_ssl_ca' in ctxt:
260 if not self.ssl_dir:
261 log(("Charm not setup for ssl support "
262 "but ssl ca found"))
263 break
264 ca_path = os.path.join(
265 self.ssl_dir, 'rabbit-client-ca.pem')
266 with open(ca_path, 'w') as fh:
267 fh.write(b64decode(ctxt['rabbit_ssl_ca']))
268 ctxt['rabbit_ssl_ca'] = ca_path
224 # Sufficient information found = break out!269 # Sufficient information found = break out!
225 break270 break
226 # Used for active/active rabbitmq >= grizzly271 # Used for active/active rabbitmq >= grizzly
@@ -391,6 +436,8 @@
391 'private_address': unit_get('private-address'),436 'private_address': unit_get('private-address'),
392 'endpoints': []437 'endpoints': []
393 }438 }
439 if is_clustered():
440 ctxt['private_address'] = config('vip')
394 for api_port in self.external_ports:441 for api_port in self.external_ports:
395 ext_port = determine_apache_port(api_port)442 ext_port = determine_apache_port(api_port)
396 int_port = determine_api_port(api_port)443 int_port = determine_api_port(api_port)
397444
=== modified file 'hooks/charmhelpers/contrib/openstack/neutron.py'
--- hooks/charmhelpers/contrib/openstack/neutron.py 2014-03-25 12:26:41 +0000
+++ hooks/charmhelpers/contrib/openstack/neutron.py 2014-03-28 10:00:55 +0000
@@ -17,6 +17,8 @@
17 kver = check_output(['uname', '-r']).strip()17 kver = check_output(['uname', '-r']).strip()
18 return 'linux-headers-%s' % kver18 return 'linux-headers-%s' % kver
1919
20QUANTUM_CONF_DIR = '/etc/quantum'
21
2022
21def kernel_version():23def kernel_version():
22 """ Retrieve the current major kernel version as a tuple e.g. (3, 13) """24 """ Retrieve the current major kernel version as a tuple e.g. (3, 13) """
@@ -35,6 +37,8 @@
3537
3638
37# legacy39# legacy
40
41
38def quantum_plugins():42def quantum_plugins():
39 from charmhelpers.contrib.openstack import context43 from charmhelpers.contrib.openstack import context
40 return {44 return {
@@ -46,7 +50,8 @@
46 'contexts': [50 'contexts': [
47 context.SharedDBContext(user=config('neutron-database-user'),51 context.SharedDBContext(user=config('neutron-database-user'),
48 database=config('neutron-database'),52 database=config('neutron-database'),
49 relation_prefix='neutron')],53 relation_prefix='neutron',
54 ssl_dir=QUANTUM_CONF_DIR)],
50 'services': ['quantum-plugin-openvswitch-agent'],55 'services': ['quantum-plugin-openvswitch-agent'],
51 'packages': [[headers_package()] + determine_dkms_package(),56 'packages': [[headers_package()] + determine_dkms_package(),
52 ['quantum-plugin-openvswitch-agent']],57 ['quantum-plugin-openvswitch-agent']],
@@ -61,7 +66,8 @@
61 'contexts': [66 'contexts': [
62 context.SharedDBContext(user=config('neutron-database-user'),67 context.SharedDBContext(user=config('neutron-database-user'),
63 database=config('neutron-database'),68 database=config('neutron-database'),
64 relation_prefix='neutron')],69 relation_prefix='neutron',
70 ssl_dir=QUANTUM_CONF_DIR)],
65 'services': [],71 'services': [],
66 'packages': [],72 'packages': [],
67 'server_packages': ['quantum-server',73 'server_packages': ['quantum-server',
@@ -70,6 +76,8 @@
70 }76 }
71 }77 }
7278
79NEUTRON_CONF_DIR = '/etc/neutron'
80
7381
74def neutron_plugins():82def neutron_plugins():
75 from charmhelpers.contrib.openstack import context83 from charmhelpers.contrib.openstack import context
@@ -83,7 +91,8 @@
83 'contexts': [91 'contexts': [
84 context.SharedDBContext(user=config('neutron-database-user'),92 context.SharedDBContext(user=config('neutron-database-user'),
85 database=config('neutron-database'),93 database=config('neutron-database'),
86 relation_prefix='neutron')],94 relation_prefix='neutron',
95 ssl_dir=NEUTRON_CONF_DIR)],
87 'services': ['neutron-plugin-openvswitch-agent'],96 'services': ['neutron-plugin-openvswitch-agent'],
88 'packages': [[headers_package()] + determine_dkms_package(),97 'packages': [[headers_package()] + determine_dkms_package(),
89 ['neutron-plugin-openvswitch-agent']],98 ['neutron-plugin-openvswitch-agent']],
@@ -98,7 +107,8 @@
98 'contexts': [107 'contexts': [
99 context.SharedDBContext(user=config('neutron-database-user'),108 context.SharedDBContext(user=config('neutron-database-user'),
100 database=config('neutron-database'),109 database=config('neutron-database'),
101 relation_prefix='neutron')],110 relation_prefix='neutron',
111 ssl_dir=NEUTRON_CONF_DIR)],
102 'services': [],112 'services': [],
103 'packages': [],113 'packages': [],
104 'server_packages': ['neutron-server',114 'server_packages': ['neutron-server',
105115
=== modified file 'hooks/cinder_hooks.py'
--- hooks/cinder_hooks.py 2014-03-13 15:50:49 +0000
+++ hooks/cinder_hooks.py 2014-03-28 10:00:55 +0000
@@ -122,6 +122,14 @@
122 return122 return
123 CONFIGS.write(CINDER_CONF)123 CONFIGS.write(CINDER_CONF)
124124
125@hooks.hook('amqp-relation-departed')
126@restart_on_change(restart_map())
127def amqp_departed():
128 if 'amqp' not in CONFIGS.complete_contexts():
129 juju_log('amqp relation incomplete. Peer not ready?')
130 return
131 CONFIGS.write(CINDER_CONF)
132
125133
126@hooks.hook('identity-service-relation-joined')134@hooks.hook('identity-service-relation-joined')
127def identity_joined(rid=None):135def identity_joined(rid=None):
128136
=== added file 'templates/grizzly/cinder.conf'
--- templates/grizzly/cinder.conf 1970-01-01 00:00:00 +0000
+++ templates/grizzly/cinder.conf 2014-03-28 10:00:55 +0000
@@ -0,0 +1,60 @@
1###############################################################################
2# [ WARNING ]
3# cinder configuration file maintained by Juju
4# local changes may be overwritten.
5###############################################################################
6[DEFAULT]
7rootwrap_config = /etc/cinder/rootwrap.conf
8api_paste_confg = /etc/cinder/api-paste.ini
9iscsi_helper = tgtadm
10volume_name_template = volume-%s
11volume_group = cinder-volumes
12verbose = True
13use_syslog = {{ use_syslog }}
14auth_strategy = keystone
15state_path = /var/lib/cinder
16lock_path = /var/lock/cinder
17volumes_dir = /var/lib/cinder/volumes
18{% if database_host -%}
19sql_connection = mysql://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }}
20{% endif -%}
21{% if rabbitmq_host or rabbitmq_hosts -%}
22notification_driver = cinder.openstack.common.notifier.rabbit_notifier
23control_exchange = cinder
24rabbit_userid = {{ rabbitmq_user }}
25rabbit_password = {{ rabbitmq_password }}
26rabbit_virtual_host = {{ rabbitmq_virtual_host }}
27{% if rabbitmq_hosts -%}
28rabbit_hosts = {{ rabbitmq_hosts }}
29{% if rabbitmq_ha_queues -%}
30rabbit_ha_queues = true
31rabbit_durable_queues = false
32{% endif %}
33{% else %}
34rabbit_host = {{ rabbitmq_host }}
35{% endif -%}
36{% endif -%}
37{% if volume_driver -%}
38volume_driver = {{ volume_driver }}
39{% endif -%}
40{% if rbd_pool -%}
41rbd_pool = {{ rbd_pool }}
42host = {{ host }}
43rbd_user = {{ rbd_user }}
44{% endif -%}
45{% if osapi_volume_listen_port -%}
46osapi_volume_listen_port = {{ osapi_volume_listen_port }}
47{% endif -%}
48{% if glance_api_servers -%}
49glance_api_servers = {{ glance_api_servers }}
50{% endif -%}
51{% if glance_api_version -%}
52glance_api_version = {{ glance_api_version }}
53{% endif -%}
54
55{% if user_config_flags -%}
56{% for key, value in user_config_flags.iteritems() -%}
57{{ key }} = {{ value }}
58{% endfor -%}
59{% endif -%}
60

Subscribers

People subscribed via source and target branches

to all changes: