Merge lp:~corey.bryant/charms/trusty/ceilometer/aodh-conf into lp:~openstack-charmers-archive/charms/trusty/ceilometer/next

Proposed by Corey Bryant
Status: Work in progress
Proposed branch: lp:~corey.bryant/charms/trusty/ceilometer/aodh-conf
Merge into: lp:~openstack-charmers-archive/charms/trusty/ceilometer/next
Diff against target: 336 lines (+192/-19)
4 files modified
lib/ceilometer_contexts.py (+60/-2)
lib/ceilometer_utils.py (+44/-17)
templates/mitaka/aodh.conf (+44/-0)
templates/mitaka/ceilometer.conf (+44/-0)
To merge this branch: bzr merge lp:~corey.bryant/charms/trusty/ceilometer/aodh-conf
Reviewer Review Type Date Requested Status
OpenStack Charmers Pending
Review via email: mp+282819@code.launchpad.net
To post a comment you must log in.
114. By Corey Bryant

Add ceilomter.conf template support and adjust aodh.conf template

115. By Corey Bryant

Update comment in template files to mitaka

116. By Corey Bryant

Update aodh context and separate from ceilometer context

Unmerged revisions

116. By Corey Bryant

Update aodh context and separate from ceilometer context

115. By Corey Bryant

Update comment in template files to mitaka

114. By Corey Bryant

Add ceilomter.conf template support and adjust aodh.conf template

113. By Corey Bryant

Add aodh.conf template support

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/ceilometer_contexts.py'
--- lib/ceilometer_contexts.py 2015-10-16 12:29:41 +0000
+++ lib/ceilometer_contexts.py 2016-01-19 18:54:49 +0000
@@ -19,6 +19,7 @@
19)19)
2020
21CEILOMETER_DB = 'ceilometer'21CEILOMETER_DB = 'ceilometer'
22AODH_DB = 'aodh'
2223
2324
24class LoggingConfigContext(OSContextGenerator):25class LoggingConfigContext(OSContextGenerator):
@@ -26,13 +27,13 @@
26 return {'debug': config('debug'), 'verbose': config('verbose')}27 return {'debug': config('debug'), 'verbose': config('verbose')}
2728
2829
29class MongoDBContext(OSContextGenerator):30class MongoDBContextCeilometer(OSContextGenerator):
30 interfaces = ['mongodb']31 interfaces = ['mongodb']
3132
32 def __call__(self):33 def __call__(self):
33 mongo_servers = []34 mongo_servers = []
34 replset = None35 replset = None
35 use_replset = os_release('ceilometer-api') >= 'icehouse'36 use_replset = True
3637
37 for relid in relation_ids('shared-db'):38 for relid in relation_ids('shared-db'):
38 rel_units = related_units(relid)39 rel_units = related_units(relid)
@@ -69,7 +70,51 @@
69 return {}70 return {}
7071
7172
73class MongoDBContextAodh(OSContextGenerator):
74 interfaces = ['mongodb']
75
76 def __call__(self):
77 mongo_servers = []
78 replset = None
79 use_replset = os_release('aodh-api') >= 'icehouse'
80
81 for relid in relation_ids('shared-db'):
82 rel_units = related_units(relid)
83 use_replset = use_replset and (len(rel_units) > 1)
84
85 for unit in rel_units:
86 host = relation_get('hostname', unit, relid)
87 port = relation_get('port', unit, relid)
88
89 conf = {
90 "db_host": host,
91 "db_port": port,
92 "db_name": AODH_DB
93 }
94
95 if not context_complete(conf):
96 continue
97
98 if not use_replset:
99 return conf
100
101 if replset is None:
102 replset = relation_get('replset', unit, relid)
103
104 mongo_servers.append('{}:{}'.format(host, port))
105
106 if mongo_servers:
107 return {
108 'db_mongo_servers': ','.join(mongo_servers),
109 'db_name': AODH_DB,
110 'db_replset': replset
111 }
112
113 return {}
114
115
72CEILOMETER_PORT = 8777116CEILOMETER_PORT = 8777
117AODH_PORT = 8042
73118
74119
75class CeilometerContext(OSContextGenerator):120class CeilometerContext(OSContextGenerator):
@@ -85,6 +130,19 @@
85 return ctxt130 return ctxt
86131
87132
133class AodhContext(OSContextGenerator):
134 def __call__(self):
135 # Lazy-import to avoid a circular dependency in the imports
136 from ceilometer_utils import get_shared_secret
137
138 ctxt = {
139 'api_workers': config('api-workers'),
140 'port': AODH_PORT,
141 'metering_secret': get_shared_secret()
142 }
143 return ctxt
144
145
88class CeilometerServiceContext(OSContextGenerator):146class CeilometerServiceContext(OSContextGenerator):
89 interfaces = ['ceilometer-service']147 interfaces = ['ceilometer-service']
90148
91149
=== modified file 'lib/ceilometer_utils.py'
--- lib/ceilometer_utils.py 2016-01-06 14:59:34 +0000
+++ lib/ceilometer_utils.py 2016-01-19 18:54:49 +0000
@@ -10,8 +10,10 @@
10from ceilometer_contexts import (10from ceilometer_contexts import (
11 ApacheSSLContext,11 ApacheSSLContext,
12 LoggingConfigContext,12 LoggingConfigContext,
13 MongoDBContext,13 MongoDBContextCeilometer,
14 MongoDBContextAodh,
14 CeilometerContext,15 CeilometerContext,
16 AodhContext,
15 HAProxyContext17 HAProxyContext
16)18)
17from charmhelpers.contrib.openstack.utils import (19from charmhelpers.contrib.openstack.utils import (
@@ -28,6 +30,8 @@
28HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'30HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
29CEILOMETER_CONF_DIR = "/etc/ceilometer"31CEILOMETER_CONF_DIR = "/etc/ceilometer"
30CEILOMETER_CONF = "%s/ceilometer.conf" % CEILOMETER_CONF_DIR32CEILOMETER_CONF = "%s/ceilometer.conf" % CEILOMETER_CONF_DIR
33AODH_CONF_DIR = "/etc/aodh"
34AODH_CONF = "%s/aodh.conf" % AODH_CONF_DIR
31HTTPS_APACHE_CONF = "/etc/apache2/sites-available/openstack_https_frontend"35HTTPS_APACHE_CONF = "/etc/apache2/sites-available/openstack_https_frontend"
32HTTPS_APACHE_24_CONF = "/etc/apache2/sites-available/" \36HTTPS_APACHE_24_CONF = "/etc/apache2/sites-available/" \
33 "openstack_https_frontend.conf"37 "openstack_https_frontend.conf"
@@ -40,16 +44,15 @@
40 'ceilometer-agent-notification',44 'ceilometer-agent-notification',
41]45]
4246
43ICEHOUSE_SERVICES = [47CEILOMETER_ICEHOUSE_SERVICES = [
44 'ceilometer-alarm-notifier',48 'ceilometer-alarm-notifier',
45 'ceilometer-alarm-evaluator',49 'ceilometer-alarm-evaluator',
46 'ceilometer-agent-notification'
47]50]
4851
49MITAKA_SERVICES = [52# aodh is used in >= mitaka
53AODH_SERVICES = [
50 'aodh-notifier',54 'aodh-notifier',
51 'aodh-evaluator',55 'aodh-evaluator',
52 'ceilometer-agent-notification'
53]56]
5457
55CEILOMETER_DB = "ceilometer"58CEILOMETER_DB = "ceilometer"
@@ -64,16 +67,20 @@
64 'python-pymongo',67 'python-pymongo',
65]68]
6669
67ICEHOUSE_PACKAGES = [70CEILOMETER_ICEHOUSE_PACKAGES = [
68 'ceilometer-alarm-notifier',71 'ceilometer-alarm-notifier',
69 'ceilometer-alarm-evaluator',72 'ceilometer-alarm-evaluator',
70 'ceilometer-agent-notification'73 'ceilometer-agent-notification',
71]74]
7275
73MITAKA_PACKAGES = [76CEILOMETER_MITAKA_PACKAGES = [
77 'ceilometer-agent-notification',
78]
79
80# aodh is used in >= mitaka
81AODH_PACKAGES = [
74 'aodh-notifier',82 'aodh-notifier',
75 'aodh-evaluator',83 'aodh-evaluator',
76 'ceilometer-agent-notification'
77]84]
7885
79REQUIRED_INTERFACES = {86REQUIRED_INTERFACES = {
@@ -91,12 +98,23 @@
91 service_user=SVC),98 service_user=SVC),
92 context.AMQPContext(ssl_dir=CEILOMETER_CONF_DIR),99 context.AMQPContext(ssl_dir=CEILOMETER_CONF_DIR),
93 LoggingConfigContext(),100 LoggingConfigContext(),
94 MongoDBContext(),101 MongoDBContextCeilometer(),
95 CeilometerContext(),102 CeilometerContext(),
96 context.SyslogContext(),103 context.SyslogContext(),
97 HAProxyContext()],104 HAProxyContext()],
98 'services': CEILOMETER_BASE_SERVICES105 'services': CEILOMETER_BASE_SERVICES
99 }),106 }),
107 (AODH_CONF, {
108 'hook_contexts': [context.IdentityServiceContext(service=SVC,
109 service_user=SVC),
110 context.AMQPContext(ssl_dir=AODH_CONF_DIR),
111 LoggingConfigContext(),
112 MongoDBContextAodh(),
113 AodhContext(),
114 context.SyslogContext(),
115 HAProxyContext()],
116 'services': AODH_SERVICES
117 }),
100 (HAPROXY_CONF, {118 (HAPROXY_CONF, {
101 'hook_contexts': [context.HAProxyContext(singlenode_mode=True),119 'hook_contexts': [context.HAProxyContext(singlenode_mode=True),
102 HAProxyContext()],120 HAProxyContext()],
@@ -216,9 +234,9 @@
216def ceilometer_release_services():234def ceilometer_release_services():
217 codename = get_os_codename_install_source(config('openstack-origin'))235 codename = get_os_codename_install_source(config('openstack-origin'))
218 if codename >= 'mitaka':236 if codename >= 'mitaka':
219 return MITAKA_SERVICES237 return []
220 elif codename >= 'icehouse':238 elif codename >= 'icehouse':
221 return ICEHOUSE_SERVICES239 return CEILOMETER_ICEHOUSE_SERVICES
222 else:240 else:
223 return []241 return []
224242
@@ -226,16 +244,25 @@
226def ceilometer_release_packages():244def ceilometer_release_packages():
227 codename = get_os_codename_install_source(config('openstack-origin'))245 codename = get_os_codename_install_source(config('openstack-origin'))
228 if codename >= 'mitaka':246 if codename >= 'mitaka':
229 return MITAKA_PACKAGES247 return CEILOMETER_MITAKA_PACKAGES
230 elif codename >= 'icehouse':248 elif codename >= 'icehouse':
231 return ICEHOUSE_PACKAGES249 return CEILOMETER_ICEHOUSE_PACKAGES
250 else:
251 return []
252
253
254def aodh_release_packages():
255 codename = get_os_codename_install_source(config('openstack-origin'))
256 if codename >= 'mitaka':
257 return AODH_PACKAGES
232 else:258 else:
233 return []259 return []
234260
235261
236def get_packages():262def get_packages():
237 packages = (deepcopy(CEILOMETER_BASE_PACKAGES) +263 packages = (deepcopy(CEILOMETER_BASE_PACKAGES) +
238 ceilometer_release_packages())264 ceilometer_release_packages() +
265 aodh_release_packages())
239 return packages266 return packages
240267
241268
242269
=== added directory 'templates/mitaka'
=== added file 'templates/mitaka/aodh.conf'
--- templates/mitaka/aodh.conf 1970-01-01 00:00:00 +0000
+++ templates/mitaka/aodh.conf 2016-01-19 18:54:49 +0000
@@ -0,0 +1,44 @@
1# mitaka
2###############################################################################
3# [ WARNING ]
4# aodh configuration file maintained by Juju
5# local changes may be overwritten.
6###############################################################################
7[DEFAULT]
8debug = {{ debug }}
9verbose = {{ verbose }}
10use_syslog = {{ use_syslog }}
11
12[oslo_messaging_rabbit]
13{% include "parts/rabbitmq" -%}
14
15[api]
16port = {{ port }}
17workers = {{ api_workers }}
18
19[service_credentials]
20os_auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v2.0
21os_tenant_name = {{ admin_tenant_name }}
22os_username = {{ admin_user }}
23os_password = {{ admin_password }}
24
25[database]
26{% if db_replset: -%}
27connection = mongodb://{{ db_mongo_servers }}/{{ db_name }}?readPreference=primaryPreferred&replicaSet={{ db_replset }}
28mongodb_replica_set = {{ db_replset }}
29{% else -%}
30connection = mongodb://{{ db_host }}:{{ db_port }}/{{ db_name }}
31{% endif %}
32
33[publisher_rpc]
34metering_secret = {{ metering_secret }}
35
36[keystone_authtoken]
37auth_uri = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/
38auth_host = {{ auth_host }}
39auth_port = {{ auth_port }}
40auth_protocol = {{ auth_protocol }}
41admin_tenant_name = {{ admin_tenant_name }}
42admin_user = {{ admin_user }}
43admin_password = {{ admin_password }}
44signing_dir = {{ signing_dir }}
045
=== added file 'templates/mitaka/ceilometer.conf'
--- templates/mitaka/ceilometer.conf 1970-01-01 00:00:00 +0000
+++ templates/mitaka/ceilometer.conf 2016-01-19 18:54:49 +0000
@@ -0,0 +1,44 @@
1# mitaka
2###############################################################################
3# [ WARNING ]
4# ceilometer configuration file maintained by Juju
5# local changes may be overwritten.
6###############################################################################
7[DEFAULT]
8debug = {{ debug }}
9verbose = {{ verbose }}
10use_syslog = {{ use_syslog }}
11
12[oslo_messaging_rabbit]
13{% include "parts/rabbitmq" -%}
14
15[api]
16port = {{ port }}
17workers = {{ api_workers }}
18
19[service_credentials]
20os_auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v2.0
21os_tenant_name = {{ admin_tenant_name }}
22os_username = {{ admin_user }}
23os_password = {{ admin_password }}
24
25[database]
26{% if db_replset: -%}
27connection = mongodb://{{ db_mongo_servers }}/{{ db_name }}?readPreference=primaryPreferred&replicaSet={{ db_replset }}
28mongodb_replica_set = {{ db_replset }}
29{% else -%}
30connection = mongodb://{{ db_host }}:{{ db_port }}/{{ db_name }}
31{% endif %}
32
33[publisher_rpc]
34metering_secret = {{ metering_secret }}
35
36[keystone_authtoken]
37auth_uri = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/
38auth_host = {{ auth_host }}
39auth_port = {{ auth_port }}
40auth_protocol = {{ auth_protocol }}
41admin_tenant_name = {{ admin_tenant_name }}
42admin_user = {{ admin_user }}
43admin_password = {{ admin_password }}
44signing_dir = {{ signing_dir }}

Subscribers

People subscribed via source and target branches