~james-page/charms/trusty/cinder/worker-config

« back to all changes in this revision

Viewing changes to hooks/cinder_hooks.py

  • Committer: james.page at ubuntu
  • Date: 2014-10-06 21:49:00 UTC
  • mfrom: (45.1.14 cinder)
  • Revision ID: james.page@ubuntu.com-20141006214900-8ipsbvdjb5l5tlf3
[jamespage,r=gnuoy] Add support for HTTPS+HA in network-split configurations

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
 
56
56
from charmhelpers.contrib.hahelpers.cluster import (
57
57
    eligible_leader,
58
 
    is_leader,
59
58
    get_hacluster_config,
60
59
)
61
60
 
71
70
    canonical_url,
72
71
    PUBLIC, INTERNAL, ADMIN
73
72
)
 
73
from charmhelpers.contrib.openstack.context import ADDRESS_TYPES
74
74
 
75
75
hooks = Hooks()
76
76
 
212
212
 
213
213
@hooks.hook('identity-service-relation-joined')
214
214
def identity_joined(rid=None):
215
 
    if not eligible_leader(CLUSTER_RES):
216
 
        return
217
 
 
218
215
    public_url = '{}:{}/v1/$(tenant_id)s'.format(
219
216
        canonical_url(CONFIGS, PUBLIC),
220
217
        config('api-listening-port')
277
274
 
278
275
@hooks.hook('cluster-relation-joined')
279
276
def cluster_joined(relation_id=None):
 
277
    for addr_type in ADDRESS_TYPES:
 
278
        address = get_address_in_network(
 
279
            config('os-{}-network'.format(addr_type))
 
280
        )
 
281
        if address:
 
282
            relation_set(
 
283
                relation_id=relation_id,
 
284
                relation_settings={'{}-address'.format(addr_type): address}
 
285
            )
280
286
    if config('prefer-ipv6'):
281
287
        private_addr = get_ipv6_addr(exc_list=[config('vip')])[0]
282
 
    else:
283
 
        private_addr = unit_get('private-address')
284
 
 
285
 
    address = get_address_in_network(config('os-internal-network'),
286
 
                                     private_addr)
287
 
    relation_set(relation_id=relation_id,
288
 
                 relation_settings={'private-address': address})
 
288
        relation_set(relation_id=relation_id,
 
289
                     relation_settings={'private-address': private_addr})
289
290
 
290
291
 
291
292
@hooks.hook('cluster-relation-changed',
351
352
    clustered = relation_get('clustered')
352
353
    if not clustered or clustered in [None, 'None', '']:
353
354
        juju_log('ha_changed: hacluster subordinate not fully clustered.')
354
 
        return
355
 
    if not is_leader(CLUSTER_RES):
356
 
        juju_log('ha_changed: hacluster complete but we are not leader.')
357
 
        return
358
 
    juju_log('Cluster configured, notifying other services and updating '
359
 
             'keystone endpoint configuration')
360
 
    for rid in relation_ids('identity-service'):
361
 
        identity_joined(rid=rid)
 
355
    else:
 
356
        juju_log('Cluster configured, notifying other services and updating '
 
357
                 'keystone endpoint configuration')
 
358
        for rid in relation_ids('identity-service'):
 
359
            identity_joined(rid=rid)
362
360
 
363
361
 
364
362
@hooks.hook('image-service-relation-changed')