~openstack-charmers/charms/precise/ceilometer/old-1410

« back to all changes in this revision

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

  • Committer: Liam Young
  • Date: 2014-08-13 14:14:12 UTC
  • mfrom: (50.1.1 ceilometer)
  • Revision ID: liam.young@canonical.com-20140813141412-1aka30eps05ypyzj
[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.')
753
769
        return ctxt
754
770
 
755
771
 
 
772
class LogLevelContext(OSContextGenerator):
 
773
 
 
774
    def __call__(self):
 
775
        ctxt = {}
 
776
        ctxt['debug'] = \
 
777
            False if config('debug') is None else config('debug')
 
778
        ctxt['verbose'] = \
 
779
            False if config('verbose') is None else config('verbose')
 
780
        return ctxt
 
781
 
 
782
 
756
783
class SyslogContext(OSContextGenerator):
757
784
 
758
785
    def __call__(self):