Browse Source

Add: Aodh support into telemetry

Closes-Bug: #1779940

Change-Id: I6deefd31562fba5da3987ab31534ebd6689d27e2
changes/25/580225/4
Seb-Solon 1 year ago
parent
commit
94e56a4138
5 changed files with 206 additions and 3 deletions
  1. 19
    0
      attributes/aodh_conf.rb
  2. 28
    2
      attributes/default.rb
  3. 152
    0
      recipes/aodh.rb
  4. 4
    1
      recipes/identity_registration.rb
  5. 3
    0
      spec/spec_helper.rb

+ 19
- 0
attributes/aodh_conf.rb View File

@@ -0,0 +1,19 @@
1
+default['openstack']['aodh']['conf_secrets'] = {}
2
+
3
+default['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']
19
+end

+ 28
- 2
attributes/default.rb View File

@@ -27,13 +27,14 @@ default['openstack']['telemetry']['custom_template_banner'] = '
27 27
 
28 28
 # Set the endpoints for the telemetry services to allow all other cookbooks to
29 29
 # access and use them
30
-%w(telemetry telemetry-metric).each do |ts|
30
+%w(telemetry telemetry-metric aodh).each do |ts|
31 31
   %w(public internal admin).each do |ep_type|
32 32
     default['openstack']['endpoints'][ep_type][ts]['host'] = '127.0.0.1'
33 33
     default['openstack']['endpoints'][ep_type][ts]['scheme'] = 'http'
34 34
     default['openstack']['endpoints'][ep_type][ts]['path'] = ''
35 35
     default['openstack']['endpoints'][ep_type]['telemetry']['port'] = 8777
36 36
     default['openstack']['endpoints'][ep_type]['telemetry-metric']['port'] = 8041
37
+    default['openstack']['endpoints'][ep_type]['aodh']['port'] = 8042
37 38
     # web-service (e.g. apache) listen address (can be different from openstack
38 39
     # telemetry endpoints)
39 40
   end
@@ -41,6 +42,7 @@ default['openstack']['telemetry']['custom_template_banner'] = '
41 42
 end
42 43
 default['openstack']['bind_service']['all']['telemetry']['port'] = 8777
43 44
 default['openstack']['bind_service']['all']['telemetry-metric']['port'] = 8041
45
+default['openstack']['bind_service']['all']['aodh']['port'] = 8042
44 46
 
45 47
 default['openstack']['telemetry']['conf_dir'] = '/etc/ceilometer'
46 48
 default['openstack']['telemetry']['conf_file'] =
@@ -50,22 +52,32 @@ default['openstack']['telemetry-metric']['conf_file'] =
50 52
   ::File.join(node['openstack']['telemetry-metric']['conf_dir'], 'gnocchi.conf')
51 53
 default['openstack']['telemetry']['syslog']['use'] = false
52 54
 
55
+default['openstack']['aodh']['conf_dir'] = '/etc/aodh'
56
+default['openstack']['aodh']['conf_file'] =
57
+  ::File.join(node['openstack']['aodh']['conf_dir'], 'aodh.conf')
58
+
53 59
 default['openstack']['telemetry']['user'] = 'ceilometer'
54 60
 default['openstack']['telemetry']['group'] = 'ceilometer'
55 61
 
56 62
 default['openstack']['telemetry-metric']['user'] = 'gnocchi'
57 63
 default['openstack']['telemetry-metric']['group'] = 'gnocchi'
58 64
 
65
+default['openstack']['aodh']['user'] = 'aodh'
66
+default['openstack']['aodh']['group'] = 'aodh'
67
+
59 68
 default['openstack']['telemetry']['service_role'] = 'admin'
60 69
 default['openstack']['telemetry-metric']['service_role'] = 'admin'
70
+default['openstack']['aodh']['service_role'] = 'admin'
61 71
 
62 72
 default['openstack']['telemetry']['identity-api']['auth']['version'] =
63 73
   node['openstack']['api']['auth']['version']
64 74
 default['openstack']['telemetry-metric']['identity-api']['auth']['version'] =
65 75
   node['openstack']['api']['auth']['version']
76
+default['openstack']['aodh']['identity-api']['auth']['version'] =
77
+  node['openstack']['api']['auth']['version']
66 78
 default['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 81
   # specify whether to enable SSL for ceilometer API endpoint
70 82
   default['openstack'][ts]['ssl']['enabled'] = false
71 83
   # specify server whether to enforce client certificate requirement
@@ -109,6 +121,14 @@ when 'rhel'
109 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
+
112 132
 when 'debian'
113 133
   default['openstack']['telemetry']['platform'] = {
114 134
     'common_packages' => ['ceilometer-common'],
@@ -129,4 +149,10 @@ when 'debian'
129 149
     'collector_service' => 'ceilometer-collector',
130 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
+  }
132 158
 end

+ 152
- 0
recipes/aodh.rb View File

@@ -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
20
+class ::Chef::Recipe
21
+  include ::Openstack
22
+end
23
+
24
+platform = node['openstack']['aodh']['platform']
25
+platform['aodh_packages'].each do |pkg|
26
+  package pkg do
27
+    options platform['package_overrides']
28
+    action :upgrade
29
+  end
30
+end
31
+
32
+if node['openstack']['mq']['service_type'] == 'rabbit'
33
+  node.default['openstack']['aodh']['conf_secrets']['DEFAULT']['transport_url'] = rabbit_transport_url 'aodh'
34
+end
35
+
36
+db_user = node['openstack']['db']['aodh']['username']
37
+db_pass = get_password 'db', 'aodh'
38
+bind_service = node['openstack']['bind_service']['all']['aodh']
39
+bind_service_address = bind_address bind_service
40
+
41
+node.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'
48
+end
49
+
50
+identity_public_endpoint = public_endpoint 'identity'
51
+auth_url =
52
+  auth_uri_transform(
53
+    identity_public_endpoint.to_s,
54
+    node['openstack']['aodh']['identity-api']['auth']['version']
55
+  )
56
+
57
+node.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 ','
63
+end
64
+
65
+directory node['openstack']['aodh']['conf_dir'] do
66
+  owner node['openstack']['aodh']['user']
67
+  group node['openstack']['aodh']['group']
68
+  mode 0o0750
69
+  action :create
70
+end
71
+
72
+# merge all config options and secrets to be used in the aodh.conf
73
+aodh_conf_options = merge_config_options 'aodh'
74
+
75
+template 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
+  )
84
+end
85
+
86
+execute 'run aodh-dbsync' do
87
+  command 'aodh-dbsync '
88
+  user node['openstack']['aodh']['user']
89
+end
90
+
91
+#### Start of Apache specific work
92
+
93
+# configure attributes for apache2 cookbook to align with openstack settings
94
+apache_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
97
+apache_listen -= ['*:80']
98
+apache_listen += ["#{bind_service_address}:#{bind_service.port}"]
99
+node.normal['apache']['listen'] = apache_listen.uniq
100
+
101
+# include the apache2 default recipe and the recipes for mod_wsgi
102
+include_recipe 'apache2'
103
+include_recipe 'apache2::mod_wsgi'
104
+# include the apache2 mod_ssl recipe if ssl is enabled for identity
105
+include_recipe 'apache2::mod_ssl' if node['openstack']['aodh']['ssl']['enabled']
106
+
107
+# create the aodh-api apache directory
108
+aodh_apache_dir = "#{node['apache']['docroot_dir']}/aodh"
109
+directory aodh_apache_dir do
110
+  owner 'root'
111
+  group 'root'
112
+  mode 0o0755
113
+end
114
+
115
+aodh_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.
118
+file aodh_server_entry do
119
+  content lazy { IO.read(platform['aodh-api_wsgi_file']) }
120
+  owner 'root'
121
+  group 'root'
122
+  mode 0o0755
123
+end
124
+
125
+web_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']
144
+end
145
+
146
+platform['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
152
+end

+ 4
- 1
recipes/identity_registration.rb View File

@@ -41,7 +41,7 @@ connection_params = {
41 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 45
   case telemetry_service
46 46
   when 'telemetry'
47 47
     service_name = 'ceilometer'
@@ -49,6 +49,9 @@ connection_params = {
49 49
   when 'telemetry-metric'
50 50
     service_name = 'gnocchi'
51 51
     service_type = 'metric'
52
+  when 'aodh'
53
+    service_name = 'aodh'
54
+    service_type = 'alarming'
52 55
 
53 56
   end
54 57
   interfaces = {

+ 3
- 0
spec/spec_helper.rb View File

@@ -38,6 +38,9 @@ shared_context 'telemetry-stubs' do
38 38
     allow_any_instance_of(Chef::Recipe).to receive(:get_password)
39 39
       .with('service', 'openstack-telemetry-metric')
40 40
       .and_return('gnocchi-pass')
41
+    allow_any_instance_of(Chef::Recipe).to receive(:get_password)
42
+      .with('service', 'openstack-aodh')
43
+      .and_return('aodh-pass')
41 44
     allow_any_instance_of(Chef::Recipe).to receive(:get_password)
42 45
       .with('user', 'guest')
43 46
       .and_return('mq-pass')

Loading…
Cancel
Save