summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeb-Solon <openid@pyseb.cx>2017-11-14 14:24:25 -0500
committerSeb-Solon <openid@pyseb.cx>2018-07-05 13:06:26 -0400
commit94e56a4138e1915298b53217c2bfbc1de8dc5739 (patch)
tree76470b0f20dddec578244cdedf9f2a6238a552a4
parenta5d4ce3bd20b0e03be3423c195c61317a66645bc (diff)
Add: Aodh support into telemetry
Notes
Notes (review): Code-Review+2: Samuel Cassiba <s@cassiba.com> Workflow+1: Samuel Cassiba <s@cassiba.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 20 Jul 2018 19:52:29 +0000 Reviewed-on: https://review.openstack.org/580225 Project: openstack/cookbook-openstack-telemetry Branch: refs/heads/master
-rw-r--r--attributes/aodh_conf.rb19
-rw-r--r--attributes/default.rb30
-rw-r--r--recipes/aodh.rb152
-rw-r--r--recipes/identity_registration.rb5
-rw-r--r--spec/spec_helper.rb3
5 files changed, 206 insertions, 3 deletions
diff --git a/attributes/aodh_conf.rb b/attributes/aodh_conf.rb
new file mode 100644
index 0000000..993b1a8
--- /dev/null
+++ b/attributes/aodh_conf.rb
@@ -0,0 +1,19 @@
1default['openstack']['aodh']['conf_secrets'] = {}
2
3default['openstack']['aodh']['conf'].tap do |conf|
4 # [keystone_authtoken] section
5 conf['keystone_authtoken']['username'] = 'aodh'
6 conf['keystone_authtoken']['project_name'] = 'service'
7 conf['keystone_authtoken']['auth_type'] = 'v3password'
8 conf['keystone_authtoken']['user_domain_name'] = 'Default'
9 conf['keystone_authtoken']['project_domain_name'] = 'Default'
10 conf['keystone_authtoken']['region_name'] = node['openstack']['region']
11 # [service_credentials] section
12 conf['service_credentials']['username'] = 'aodh'
13 conf['service_credentials']['project_name'] = 'service'
14 conf['service_credentials']['user_domain_name'] = 'Default'
15 conf['service_credentials']['project_domain_name'] = 'Default'
16 conf['service_credentials']['auth_type'] = 'v3password'
17 conf['service_credentials']['interface'] = 'internal'
18 conf['service_credentials']['region_name'] = node['openstack']['region']
19end
diff --git a/attributes/default.rb b/attributes/default.rb
index 4d047eb..6c3634a 100644
--- a/attributes/default.rb
+++ b/attributes/default.rb
@@ -27,13 +27,14 @@ default['openstack']['telemetry']['custom_template_banner'] = '
27 27
28# Set the endpoints for the telemetry services to allow all other cookbooks to 28# Set the endpoints for the telemetry services to allow all other cookbooks to
29# access and use them 29# access and use them
30%w(telemetry telemetry-metric).each do |ts| 30%w(telemetry telemetry-metric aodh).each do |ts|
31 %w(public internal admin).each do |ep_type| 31 %w(public internal admin).each do |ep_type|
32 default['openstack']['endpoints'][ep_type][ts]['host'] = '127.0.0.1' 32 default['openstack']['endpoints'][ep_type][ts]['host'] = '127.0.0.1'
33 default['openstack']['endpoints'][ep_type][ts]['scheme'] = 'http' 33 default['openstack']['endpoints'][ep_type][ts]['scheme'] = 'http'
34 default['openstack']['endpoints'][ep_type][ts]['path'] = '' 34 default['openstack']['endpoints'][ep_type][ts]['path'] = ''
35 default['openstack']['endpoints'][ep_type]['telemetry']['port'] = 8777 35 default['openstack']['endpoints'][ep_type]['telemetry']['port'] = 8777
36 default['openstack']['endpoints'][ep_type]['telemetry-metric']['port'] = 8041 36 default['openstack']['endpoints'][ep_type]['telemetry-metric']['port'] = 8041
37 default['openstack']['endpoints'][ep_type]['aodh']['port'] = 8042
37 # web-service (e.g. apache) listen address (can be different from openstack 38 # web-service (e.g. apache) listen address (can be different from openstack
38 # telemetry endpoints) 39 # telemetry endpoints)
39 end 40 end
@@ -41,6 +42,7 @@ default['openstack']['telemetry']['custom_template_banner'] = '
41end 42end
42default['openstack']['bind_service']['all']['telemetry']['port'] = 8777 43default['openstack']['bind_service']['all']['telemetry']['port'] = 8777
43default['openstack']['bind_service']['all']['telemetry-metric']['port'] = 8041 44default['openstack']['bind_service']['all']['telemetry-metric']['port'] = 8041
45default['openstack']['bind_service']['all']['aodh']['port'] = 8042
44 46
45default['openstack']['telemetry']['conf_dir'] = '/etc/ceilometer' 47default['openstack']['telemetry']['conf_dir'] = '/etc/ceilometer'
46default['openstack']['telemetry']['conf_file'] = 48default['openstack']['telemetry']['conf_file'] =
@@ -50,22 +52,32 @@ default['openstack']['telemetry-metric']['conf_file'] =
50 ::File.join(node['openstack']['telemetry-metric']['conf_dir'], 'gnocchi.conf') 52 ::File.join(node['openstack']['telemetry-metric']['conf_dir'], 'gnocchi.conf')
51default['openstack']['telemetry']['syslog']['use'] = false 53default['openstack']['telemetry']['syslog']['use'] = false
52 54
55default['openstack']['aodh']['conf_dir'] = '/etc/aodh'
56default['openstack']['aodh']['conf_file'] =
57 ::File.join(node['openstack']['aodh']['conf_dir'], 'aodh.conf')
58
53default['openstack']['telemetry']['user'] = 'ceilometer' 59default['openstack']['telemetry']['user'] = 'ceilometer'
54default['openstack']['telemetry']['group'] = 'ceilometer' 60default['openstack']['telemetry']['group'] = 'ceilometer'
55 61
56default['openstack']['telemetry-metric']['user'] = 'gnocchi' 62default['openstack']['telemetry-metric']['user'] = 'gnocchi'
57default['openstack']['telemetry-metric']['group'] = 'gnocchi' 63default['openstack']['telemetry-metric']['group'] = 'gnocchi'
58 64
65default['openstack']['aodh']['user'] = 'aodh'
66default['openstack']['aodh']['group'] = 'aodh'
67
59default['openstack']['telemetry']['service_role'] = 'admin' 68default['openstack']['telemetry']['service_role'] = 'admin'
60default['openstack']['telemetry-metric']['service_role'] = 'admin' 69default['openstack']['telemetry-metric']['service_role'] = 'admin'
70default['openstack']['aodh']['service_role'] = 'admin'
61 71
62default['openstack']['telemetry']['identity-api']['auth']['version'] = 72default['openstack']['telemetry']['identity-api']['auth']['version'] =
63 node['openstack']['api']['auth']['version'] 73 node['openstack']['api']['auth']['version']
64default['openstack']['telemetry-metric']['identity-api']['auth']['version'] = 74default['openstack']['telemetry-metric']['identity-api']['auth']['version'] =
65 node['openstack']['api']['auth']['version'] 75 node['openstack']['api']['auth']['version']
76default['openstack']['aodh']['identity-api']['auth']['version'] =
77 node['openstack']['api']['auth']['version']
66default['openstack']['telemetry-metric']['gnocchi-upgrade-options'] = '' 78default['openstack']['telemetry-metric']['gnocchi-upgrade-options'] = ''
67 79
68%w(telemetry telemetry-metric).each do |ts| 80%w(telemetry telemetry-metric aodh).each do |ts|
69 # specify whether to enable SSL for ceilometer API endpoint 81 # specify whether to enable SSL for ceilometer API endpoint
70 default['openstack'][ts]['ssl']['enabled'] = false 82 default['openstack'][ts]['ssl']['enabled'] = false
71 # specify server whether to enforce client certificate requirement 83 # specify server whether to enforce client certificate requirement
@@ -109,6 +121,14 @@ when 'rhel'
109 'package_overrides' => '', 121 'package_overrides' => '',
110 } 122 }
111 123
124 default['openstack']['aodh']['platform'] = {
125 'aodh_packages' => ['openstack-aodh', 'openstack-aodh-api', 'openstack-aodh-evaluator',
126 'openstack-aodh-expirer', 'openstack-aodh-listener', 'openstack-aodh-notifier',
127 'python-aodhclient'],
128 'aodh_services' => ['openstack-aodh-evaluator', 'openstack-aodh-notifier', 'openstack-aodh-listener'],
129 'aodh-api_wsgi_file' => '/usr/share/aodh/app.wsgi',
130 }
131
112when 'debian' 132when 'debian'
113 default['openstack']['telemetry']['platform'] = { 133 default['openstack']['telemetry']['platform'] = {
114 'common_packages' => ['ceilometer-common'], 134 'common_packages' => ['ceilometer-common'],
@@ -129,4 +149,10 @@ when 'debian'
129 'collector_service' => 'ceilometer-collector', 149 'collector_service' => 'ceilometer-collector',
130 'package_overrides' => '', 150 'package_overrides' => '',
131 } 151 }
152
153 default['openstack']['aodh']['platform'] = {
154 'aodh_packages' => ['aodh-api', 'aodh-evaluator', 'aodh-expirer', 'aodh-listener', 'aodh-notifier', 'python-ceilometerclient'],
155 'aodh_services' => ['aodh-evaluator', 'aodh-notifier', 'aodh-listener'],
156 'aodh-api_wsgi_file' => '/usr/share/aodh/app.wsgi' # this file come with aodh-common which aodh-api depends on
157 }
132end 158end
diff --git a/recipes/aodh.rb b/recipes/aodh.rb
new file mode 100644
index 0000000..bb04a48
--- /dev/null
+++ b/recipes/aodh.rb
@@ -0,0 +1,152 @@
1# encoding: UTF-8
2#
3# Cookbook Name:: openstack-telemetry
4# Recipe:: aodh
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18
19# load the methods defined in cookbook-openstack-common libraries
20class ::Chef::Recipe
21 include ::Openstack
22end
23
24platform = node['openstack']['aodh']['platform']
25platform['aodh_packages'].each do |pkg|
26 package pkg do
27 options platform['package_overrides']
28 action :upgrade
29 end
30end
31
32if node['openstack']['mq']['service_type'] == 'rabbit'
33 node.default['openstack']['aodh']['conf_secrets']['DEFAULT']['transport_url'] = rabbit_transport_url 'aodh'
34end
35
36db_user = node['openstack']['db']['aodh']['username']
37db_pass = get_password 'db', 'aodh'
38bind_service = node['openstack']['bind_service']['all']['aodh']
39bind_service_address = bind_address bind_service
40
41node.default['openstack']['aodh']['conf_secrets'].tap do |conf_secrets|
42 conf_secrets['database']['connection'] =
43 db_uri('aodh', db_user, db_pass)
44 conf_secrets['service_credentials']['password'] =
45 get_password 'service', 'openstack-aodh'
46 conf_secrets['keystone_authtoken']['password'] =
47 get_password 'service', 'openstack-aodh'
48end
49
50identity_public_endpoint = public_endpoint 'identity'
51auth_url =
52 auth_uri_transform(
53 identity_public_endpoint.to_s,
54 node['openstack']['aodh']['identity-api']['auth']['version']
55 )
56
57node.default['openstack']['aodh']['conf'].tap do |conf|
58 conf['api']['host'] = bind_service_address
59 conf['api']['port'] = bind_service.port
60 conf['keystone_authtoken']['auth_url'] = auth_url
61 conf['service_credentials']['auth_url'] = auth_url
62 conf['keystone_authtoken']['memcache_servers'] = memcached_servers.join ','
63end
64
65directory node['openstack']['aodh']['conf_dir'] do
66 owner node['openstack']['aodh']['user']
67 group node['openstack']['aodh']['group']
68 mode 0o0750
69 action :create
70end
71
72# merge all config options and secrets to be used in the aodh.conf
73aodh_conf_options = merge_config_options 'aodh'
74
75template node['openstack']['aodh']['conf_file'] do
76 source 'openstack-service.conf.erb'
77 cookbook 'openstack-common'
78 owner node['openstack']['aodh']['user']
79 group node['openstack']['aodh']['group']
80 mode 0o0640
81 variables(
82 service_config: aodh_conf_options
83 )
84end
85
86execute 'run aodh-dbsync' do
87 command 'aodh-dbsync '
88 user node['openstack']['aodh']['user']
89end
90
91#### Start of Apache specific work
92
93# configure attributes for apache2 cookbook to align with openstack settings
94apache_listen = Array(node['apache']['listen']) # include already defined listen attributes
95# Remove the default apache2 cookbook port, as that is also the default for horizon, but with
96# a different address syntax. *:80 vs 0.0.0.0:80
97apache_listen -= ['*:80']
98apache_listen += ["#{bind_service_address}:#{bind_service.port}"]
99node.normal['apache']['listen'] = apache_listen.uniq
100
101# include the apache2 default recipe and the recipes for mod_wsgi
102include_recipe 'apache2'
103include_recipe 'apache2::mod_wsgi'
104# include the apache2 mod_ssl recipe if ssl is enabled for identity
105include_recipe 'apache2::mod_ssl' if node['openstack']['aodh']['ssl']['enabled']
106
107# create the aodh-api apache directory
108aodh_apache_dir = "#{node['apache']['docroot_dir']}/aodh"
109directory aodh_apache_dir do
110 owner 'root'
111 group 'root'
112 mode 0o0755
113end
114
115aodh_server_entry = "#{aodh_apache_dir}/app"
116# Note: Using lazy here as the wsgi file is not available until after
117# the aodh-common package is installed during execution phase.
118file aodh_server_entry do
119 content lazy { IO.read(platform['aodh-api_wsgi_file']) }
120 owner 'root'
121 group 'root'
122 mode 0o0755
123end
124
125web_app 'aodh-api' do
126 template 'wsgi-template.conf.erb'
127 daemon_process 'aodh-api'
128 server_host bind_service.host
129 server_port bind_service.port
130 server_entry aodh_server_entry
131 run_dir node['apache']['run_dir']
132 log_dir node['apache']['log_dir']
133 log_debug node['openstack']['aodh']['debug']
134 user node['openstack']['aodh']['user']
135 group node['openstack']['aodh']['group']
136 use_ssl node['openstack']['aodh']['ssl']['enabled']
137 cert_file node['openstack']['aodh']['ssl']['certfile']
138 chain_file node['openstack']['aodh']['ssl']['chainfile']
139 key_file node['openstack']['aodh']['ssl']['keyfile']
140 ca_certs_path node['openstack']['aodh']['ssl']['ca_certs_path']
141 cert_required node['openstack']['aodh']['ssl']['cert_required']
142 protocol node['openstack']['aodh']['ssl']['protocol']
143 ciphers node['openstack']['aodh']['ssl']['ciphers']
144end
145
146platform['aodh_services'].each do |aodh_service|
147 service aodh_service do
148 service_name aodh_service
149 subscribes :restart, "template[#{node['openstack']['aodh']['conf_file']}]"
150 action [:enable, :start]
151 end
152end
diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb
index f7d3fcb..0aff62c 100644
--- a/recipes/identity_registration.rb
+++ b/recipes/identity_registration.rb
@@ -41,7 +41,7 @@ connection_params = {
41 openstack_domain_name: admin_domain, 41 openstack_domain_name: admin_domain,
42} 42}
43 43
44%w(telemetry telemetry-metric).each do |telemetry_service| 44%w(telemetry telemetry-metric aodh).each do |telemetry_service|
45 case telemetry_service 45 case telemetry_service
46 when 'telemetry' 46 when 'telemetry'
47 service_name = 'ceilometer' 47 service_name = 'ceilometer'
@@ -49,6 +49,9 @@ connection_params = {
49 when 'telemetry-metric' 49 when 'telemetry-metric'
50 service_name = 'gnocchi' 50 service_name = 'gnocchi'
51 service_type = 'metric' 51 service_type = 'metric'
52 when 'aodh'
53 service_name = 'aodh'
54 service_type = 'alarming'
52 55
53 end 56 end
54 interfaces = { 57 interfaces = {
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index bf7574a..52b083c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -39,6 +39,9 @@ shared_context 'telemetry-stubs' do
39 .with('service', 'openstack-telemetry-metric') 39 .with('service', 'openstack-telemetry-metric')
40 .and_return('gnocchi-pass') 40 .and_return('gnocchi-pass')
41 allow_any_instance_of(Chef::Recipe).to receive(:get_password) 41 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
42 .with('service', 'openstack-aodh')
43 .and_return('aodh-pass')
44 allow_any_instance_of(Chef::Recipe).to receive(:get_password)
42 .with('user', 'guest') 45 .with('user', 'guest')
43 .and_return('mq-pass') 46 .and_return('mq-pass')
44 allow_any_instance_of(Chef::Recipe).to receive(:get_password) 47 allow_any_instance_of(Chef::Recipe).to receive(:get_password)