~corey.bryant/charms/trusty/ceilometer/git-ods

« back to all changes in this revision

Viewing changes to hooks/ceilometer_hooks.py

  • Committer: Edward Hope-Morley
  • Date: 2015-03-13 12:57:45 UTC
  • mfrom: (67.2.11 ceilometer.pki)
  • Revision ID: edward.hope-morley@canonical.com-20150313125745-7e9jf5egpi14c9cg
[hopem,r=gnuoy]

Implement PKI token signing.

Closes-Bug: 1309667

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
 
 
3
2
import base64
4
3
import shutil
 
4
import subprocess
5
5
import sys
6
6
import os
 
7
 
7
8
from charmhelpers.fetch import (
8
9
    apt_install, filter_installed_packages,
9
10
    apt_update
38
39
    get_ceilometer_context,
39
40
    get_shared_secret,
40
41
    do_openstack_upgrade,
41
 
    set_shared_secret
 
42
    set_shared_secret,
42
43
)
43
44
from ceilometer_contexts import CEILOMETER_PORT
44
45
from charmhelpers.contrib.openstack.ip import (
85
86
 
86
87
@hooks.hook("amqp-relation-changed",
87
88
            "shared-db-relation-changed",
88
 
            "shared-db-relation-departed",
89
 
            "identity-service-relation-changed")
 
89
            "shared-db-relation-departed")
90
90
@restart_on_change(restart_map())
91
91
def any_changed():
92
92
    CONFIGS.write_all()
 
93
    configure_https()
93
94
    ceilometer_joined()
94
95
 
95
96
 
 
97
@hooks.hook("identity-service-relation-changed")
 
98
@restart_on_change(restart_map())
 
99
def identity_service_relation_changed():
 
100
    CONFIGS.write_all()
 
101
    configure_https()
 
102
    keystone_joined()
 
103
 
 
104
 
96
105
@hooks.hook("amqp-relation-departed")
97
106
@restart_on_change(restart_map())
98
107
def amqp_departed():
102
111
    CONFIGS.write_all()
103
112
 
104
113
 
 
114
def configure_https():
 
115
    """Enables SSL API Apache config if appropriate."""
 
116
    # need to write all to ensure changes to the entire request pipeline
 
117
    # propagate (c-api, haprxy, apache)
 
118
    CONFIGS.write_all()
 
119
    if 'https' in CONFIGS.complete_contexts():
 
120
        cmd = ['a2ensite', 'openstack_https_frontend']
 
121
        subprocess.check_call(cmd)
 
122
    else:
 
123
        cmd = ['a2dissite', 'openstack_https_frontend']
 
124
        subprocess.check_call(cmd)
 
125
 
 
126
    subprocess.check_call(['service', 'apache2', 'reload'])
 
127
 
 
128
 
105
129
@hooks.hook('config-changed')
106
130
@restart_on_change(restart_map())
107
131
def config_changed():
110
134
    update_nrpe_config()
111
135
    CONFIGS.write_all()
112
136
    ceilometer_joined()
 
137
    configure_https()
113
138
    for rid in relation_ids('identity-service'):
114
139
        keystone_joined(relid=rid)
115
140