3
from charmhelpers.fetch import apt_install as install
1
from charmhelpers.contrib.openstack import (
5
from ceilometer_contexts import (
10
from charmhelpers.contrib.openstack.utils import (
11
get_os_codename_package
5
RABBIT_USER = "ceilometer"
6
RABBIT_VHOST = "openstack"
7
14
CEILOMETER_CONF = "/etc/ceilometer/ceilometer.conf"
9
SHARED_SECRET = "/etc/ceilometer/secret.txt"
10
16
CEILOMETER_SERVICES = [
11
'ceilometer-agent-central', 'ceilometer-collector',
17
'ceilometer-agent-central',
18
'ceilometer-collector',
14
22
CEILOMETER_DB = "ceilometer"
15
23
CEILOMETER_SERVICE = "ceilometer"
16
CEILOMETER_COMPUTE_SERVICES = ['ceilometer-agent-compute']
17
25
CEILOMETER_PACKAGES = [
18
'python-ceilometer', 'ceilometer-common',
19
'ceilometer-agent-central', 'ceilometer-collector', 'ceilometer-api'
21
CEILOMETER_AGENT_PACKAGES = [
22
'python-ceilometer', 'ceilometer-common',
23
'ceilometer-agent-compute'
25
CEILOMETER_PORT = 8777
26
'ceilometer-agent-central',
27
'ceilometer-collector',
26
31
CEILOMETER_ROLE = "ResellerAdmin"
28
NOVA_CONF = "/etc/nova/nova.conf"
30
('DEFAULT', 'instance_usage_audit', 'True'),
31
('DEFAULT', 'instance_usage_audit_period', 'hour'),
32
('DEFAULT', 'notification_driver', 'ceilometer.compute.nova_notifier')
36
def get_shared_secret():
38
if not os.path.exists(SHARED_SECRET):
39
secret = str(uuid.uuid4())
40
with open(SHARED_SECRET, 'w') as secret_file:
41
secret_file.write(secret)
43
with open(SHARED_SECRET, 'r') as secret_file:
44
secret = secret_file.read().strip()
48
TEMPLATES_DIR = 'templates'
53
install(['python-jinja2'])
57
def render_template(template_name, context, template_dir=TEMPLATES_DIR):
59
jinja2.Environment(loader=jinja2.FileSystemLoader(template_dir))
60
template = templates.get_template(template_name)
61
return template.render(context)
33
#NOVA_CONF = "/etc/nova/nova.conf"
35
# ('DEFAULT', 'instance_usage_audit', 'True'),
36
# ('DEFAULT', 'instance_usage_audit_period', 'hour'),
37
# ('DEFAULT', 'notification_driver', 'ceilometer.compute.nova_notifier')
42
'hook_contexts': [context.IdentityServiceContext(),
43
context.AMQPContext(),
44
LoggingConfigContext(),
47
'services': CEILOMETER_SERVICES
51
TEMPLATES = 'templates'
54
def register_configs():
56
Register config files with their respective contexts.
57
Regstration of some configs may not be required depending on
58
existing of certain relations.
60
# if called without anything installed (eg during install hook)
61
# just default to earliest supported release. configs dont get touched
62
# till post-install, anyway.
63
release = get_os_codename_package('ceilometer-common', fatal=False) \
65
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
66
openstack_release=release)
68
for conf in CONFIG_FILES:
69
configs.register(conf, CONFIG_FILES[conf]['hook_contexts'])
76
Determine the correct resource map to be passed to
77
charmhelpers.core.restart_on_change() based on the services configured.
79
:returns: dict: A dictionary mapping config file to lists of services
80
that should be restarted when file changes.
83
for f, ctxt in CONFIG_FILES.iteritems():
85
for svc in ctxt['services']:
92
def get_ceilometer_context():
93
''' Retrieve a map of all current relation data for agent configuration '''
95
for context in CONFIG_FILES[CEILOMETER_CONF]['hook_contexts']:
96
ctxt.update(context())