~alexlist/charms/trusty/ceilometer/add-execd-preinstall

« back to all changes in this revision

Viewing changes to hooks/ceilometer_hooks.py

  • Committer: James Page
  • Date: 2014-04-16 08:10:53 UTC
  • mfrom: (47.1.12 ceilometer)
  • Revision ID: james.page@canonical.com-20140416081053-s25775hrftyzndwa
[hazmat,yolanda.robla,james-page,r=james-page,t=*]

Support for Icehouse on 12.04 and 14.04
Support for Active/Active RabbitMQ
Support for SSL endpoints

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
 
3
import base64
3
4
import sys
4
5
from charmhelpers.fetch import (
5
6
    apt_install, filter_installed_packages,
23
24
    openstack_upgrade_available
24
25
)
25
26
from ceilometer_utils import (
26
 
    CEILOMETER_PACKAGES,
 
27
    get_packages,
27
28
    CEILOMETER_DB,
28
29
    CEILOMETER_SERVICE,
29
30
    CEILOMETER_ROLE,
46
47
        origin = 'cloud:precise-grizzly'
47
48
    configure_installation_source(origin)
48
49
    apt_update(fatal=True)
49
 
    apt_install(filter_installed_packages(CEILOMETER_PACKAGES),
 
50
    apt_install(filter_installed_packages(get_packages()),
50
51
                fatal=True)
51
52
    open_port(CEILOMETER_PORT)
52
53
 
71
72
    ceilometer_joined()
72
73
 
73
74
 
 
75
@hooks.hook("amqp-relation-departed")
 
76
@restart_on_change(restart_map())
 
77
def amqp_departed():
 
78
    if 'amqp' not in CONFIGS.complete_contexts():
 
79
        log('amqp relation incomplete. Peer not ready?')
 
80
        return
 
81
    CONFIGS.write_all()
 
82
 
 
83
 
74
84
@hooks.hook('config-changed')
75
85
@restart_on_change(restart_map())
76
86
def config_changed():
101
111
def ceilometer_joined():
102
112
    # Pass local context data onto related agent services
103
113
    context = get_ceilometer_context()
 
114
    # This value gets tranformed to a path by the context we need to
 
115
    # pass the data to agents.
 
116
    if 'rabbit_ssl_ca' in context:
 
117
        with open(context['rabbit_ssl_ca']) as fh:
 
118
            context['rabbit_ssl_ca'] = base64.b64encode(fh.read())
104
119
    for relid in relation_ids('ceilometer-service'):
105
120
        relation_set(relid, context)
106
121