diff --git a/CHANGELOG.md b/CHANGELOG.md index 74944c9..9560e66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ openstack-telemetry Cookbook CHANGELG ============================== This file is used to list changes made in each version of the openstack-metering cookbook. +## 8.4.0 +### Blue print +# Use the library method auth_uri_transform + ## 8.3.0 * Rename openstack-metering to openstack-telemetry diff --git a/README.md b/README.md index 2a527ac..8f125d9 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ identity_registration Attributes ========== +* `openstack['telemetry']['api']['auth']['version']` - Select v2.0 or v3.0. Default v2.0. The auth API version used to interact with identity service. + Testing ===== diff --git a/attributes/default.rb b/attributes/default.rb index 3d74118..8c39d30 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -32,6 +32,8 @@ default['openstack']['telemetry']['debug'] = 'false' default['openstack']['telemetry']['api']['auth']['cache_dir'] = '/var/cache/ceilometer/api' +default['openstack']['telemetry']['api']['auth']['version'] = node['openstack']['api']['auth']['version'] + default['openstack']['telemetry']['user'] = 'ceilometer' default['openstack']['telemetry']['group'] = 'ceilometer' diff --git a/metadata.rb b/metadata.rb index 7d70a1e..afec971 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer_email 'cookbooks@lists.tfoundry.com' license 'Apache 2.0' description 'The OpenStack Metering service Ceilometer.' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '8.3.0' +version '8.4.0' recipe 'openstack-telemetry::agent-central', 'Installs agent central service.' recipe 'openstack-telemetry::agent-compute', 'Installs agent compute service.' diff --git a/recipes/common.rb b/recipes/common.rb index 0646e41..5a974e9 100644 --- a/recipes/common.rb +++ b/recipes/common.rb @@ -53,6 +53,8 @@ identity_endpoint = endpoint 'identity-api' identity_admin_endpoint = endpoint 'identity-admin' image_endpoint = endpoint 'image-api' +auth_uri = auth_uri_transform identity_endpoint.to_s, node['openstack']['telemetry']['api']['auth']['version'] + Chef::Log.debug("openstack-telemetry::common:service_user|#{service_user}") Chef::Log.debug("openstack-telemetry::common:service_tenant|#{service_tenant}") Chef::Log.debug("openstack-telemetry::common:identity_endpoint|#{identity_endpoint.to_s}") @@ -72,7 +74,7 @@ template node['openstack']['telemetry']['conf'] do mode 00640 variables( - auth_uri: ::URI.decode(identity_endpoint.to_s), + auth_uri: auth_uri, database_connection: db_uri, image_endpoint: image_endpoint, identity_endpoint: identity_endpoint, diff --git a/spec/common_spec.rb b/spec/common_spec.rb index d5ec6ba..c8249be 100644 --- a/spec/common_spec.rb +++ b/spec/common_spec.rb @@ -86,6 +86,53 @@ describe 'openstack-telemetry::common' do end end end + + context 'has keystone authtoken configuration' do + it 'has auth_uri' do + expect(@chef_run).to render_file(@filename).with_content( + /^#{Regexp.quote('auth_uri = http://127.0.0.1:5000/v2.0')}$/) + end + + it 'has auth_host' do + expect(@chef_run).to render_file(@filename).with_content( + /^#{Regexp.quote('auth_host = 127.0.0.1')}$/) + end + + it 'has auth_port' do + expect(@chef_run).to render_file(@filename).with_content( + /^auth_port = 35357$/) + end + + it 'has auth_protocol' do + expect(@chef_run).to render_file(@filename).with_content( + /^auth_protocol = http$/) + end + + it 'has no auth_version' do + expect(@chef_run).not_to render_file(@filename).with_content( + /^auth_version = v2.0$/) + end + + it 'has admin_tenant_name' do + expect(@chef_run).to render_file(@filename).with_content( + /^admin_tenant_name = service$/) + end + + it 'has admin_user' do + expect(@chef_run).to render_file(@filename).with_content( + /^admin_user = ceilometer$/) + end + + it 'has admin_password' do + expect(@chef_run).to render_file(@filename).with_content( + /^admin_password = ceilometer-pass$/) + end + + it 'has signing_dir' do + expect(@chef_run).to render_file(@filename).with_content( + /^#{Regexp.quote('signing_dir = /var/cache/ceilometer/api')}$/) + end + end end it 'installs the /etc/ceilometer/policy.json file' do diff --git a/templates/default/ceilometer.conf.erb b/templates/default/ceilometer.conf.erb index 9c21991..6ca9ab7 100644 --- a/templates/default/ceilometer.conf.erb +++ b/templates/default/ceilometer.conf.erb @@ -54,10 +54,13 @@ periodic_interval = <%= node["openstack"]["telemetry"]["periodic_interval"] %> [keystone_authtoken] paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory -auth_uri = <%= @identity_endpoint.to_s %> +auth_uri = <%= @auth_uri %> auth_host = <%= @identity_admin_endpoint.host %> auth_port = <%= @identity_admin_endpoint.port %> auth_protocol = <%= @identity_admin_endpoint.scheme %> +<% if node['openstack']['telemetry']['api']['auth']['version'] != 'v2.0' %> +auth_version = <%= node['openstack']['telemetry']['api']['auth']['version'] %> +<% end %> admin_tenant_name = <%= @service_tenant_name %> admin_user = <%= @service_user %> admin_password = <%= @service_pass %>