200
209
def relation_broken():
201
210
CONFIGS.write_all()
212
@hooks.hook('cluster-relation-joined')
213
def cluster_joined(relation_id=None):
214
for addr_type in ADDRESS_TYPES:
215
address = get_address_in_network(
216
config('os-{}-network'.format(addr_type))
220
relation_id=relation_id,
221
relation_settings={'{}-address'.format(addr_type): address}
224
# Only do if this is fired by cluster rel
226
check_db_initialised()
228
if config('prefer-ipv6'):
229
private_addr = get_ipv6_addr(exc_list=[config('vip')])[0]
230
relation_set(relation_id=relation_id,
231
relation_settings={'private-address': private_addr})
234
@hooks.hook('cluster-relation-changed',
235
'cluster-relation-departed')
236
@restart_on_change(restart_map(), stopstart=True)
237
def cluster_changed():
238
check_db_initialised()
242
@hooks.hook('ha-relation-joined')
243
def ha_joined(relation_id=None):
244
cluster_config = get_hacluster_config()
247
'res_cinder_haproxy': 'lsb:haproxy'
251
'res_cinder_haproxy': 'op monitor interval="5s"'
255
for vip in cluster_config['vip'].split():
257
res_cinder_vip = 'ocf:heartbeat:IPv6addr'
258
vip_params = 'ipv6addr'
260
res_cinder_vip = 'ocf:heartbeat:IPaddr2'
263
iface = (get_iface_for_address(vip) or
265
netmask = (get_netmask_for_address(vip) or
268
if iface is not None:
269
vip_key = 'res_cinder_{}_vip'.format(iface)
270
resources[vip_key] = res_cinder_vip
271
resource_params[vip_key] = (
272
'params {ip}="{vip}" cidr_netmask="{netmask}"'
273
' nic="{iface}"'.format(ip=vip_params,
278
vip_group.append(vip_key)
280
if len(vip_group) >= 1:
281
relation_set(relation_id=relation_id,
282
groups={'grp_cinder_vips': ' '.join(vip_group)})
285
'res_cinder_haproxy': 'haproxy'
288
'cl_cinder_haproxy': 'res_cinder_haproxy'
290
relation_set(relation_id=relation_id,
291
init_services=init_services,
292
corosync_bindiface=cluster_config['ha-bindiface'],
293
corosync_mcastport=cluster_config['ha-mcastport'],
295
resource_params=resource_params,
299
@hooks.hook('ha-relation-changed')
301
clustered = relation_get('clustered')
302
if not clustered or clustered in [None, 'None', '']:
303
juju_log('ha_changed: hacluster subordinate not fully clustered.')
305
juju_log('Cluster configured, notifying other services and updating '
306
'keystone endpoint configuration')
307
for rid in relation_ids('identity-service'):
308
identity_joined(rid=rid)