~corey.bryant/charms/trusty/keystone/python-six

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/openstack/context.py

  • Committer: Liam Young
  • Date: 2014-08-13 14:22:55 UTC
  • mfrom: (73.1.2 keystone)
  • Revision ID: liam.young@canonical.com-20140813142255-conhi1nncsxgnncf
[gnuoy, rs=jamespage] Sync charm-helpers from lp:charm-helpers

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    neutron_plugin_attribute,
45
45
)
46
46
 
47
 
from charmhelpers.contrib.network.ip import get_address_in_network
 
47
from charmhelpers.contrib.network.ip import (
 
48
    get_address_in_network,
 
49
    get_ipv6_addr,
 
50
)
48
51
 
49
52
CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
50
53
 
401
404
 
402
405
        cluster_hosts = {}
403
406
        l_unit = local_unit().replace('/', '-')
404
 
        cluster_hosts[l_unit] = \
405
 
            get_address_in_network(config('os-internal-network'),
406
 
                                   unit_get('private-address'))
 
407
        if config('prefer-ipv6'):
 
408
            addr = get_ipv6_addr()
 
409
        else:
 
410
            addr = unit_get('private-address')
 
411
        cluster_hosts[l_unit] = get_address_in_network(config('os-internal-network'),
 
412
                                                       addr)
407
413
 
408
414
        for rid in relation_ids('cluster'):
409
415
            for unit in related_units(rid):
414
420
        ctxt = {
415
421
            'units': cluster_hosts,
416
422
        }
 
423
 
 
424
        if config('prefer-ipv6'):
 
425
            ctxt['local_host'] = 'ip6-localhost'
 
426
            ctxt['haproxy_host'] = '::'
 
427
            ctxt['stat_port'] = ':::8888'
 
428
        else:
 
429
            ctxt['local_host'] = '127.0.0.1'
 
430
            ctxt['haproxy_host'] = '0.0.0.0'
 
431
            ctxt['stat_port'] = ':8888'
 
432
 
417
433
        if len(cluster_hosts.keys()) > 1:
418
434
            # Enable haproxy when we have enough peers.
419
435
            log('Ensuring haproxy enabled in /etc/default/haproxy.')