auth: refactor to use *_url

Be consistent with other modules and use *_url parameters.

Change-Id: I2aea954d1246d3d70b7da33c5860da71560a8c59
This commit is contained in:
Emilien Macchi 2015-10-19 18:22:35 -04:00
parent 2cbfc044a7
commit 51bada5009
2 changed files with 40 additions and 72 deletions

View File

@ -1,6 +1,6 @@
# == Class: aodh::keystone::auth
#
# Configures aodh user, service and endpoint in Keystone.
# Configures Aodh user, service and endpoint in Keystone.
#
# === Parameters
#
@ -28,31 +28,7 @@
# Defaults to 'true'.
#
# [*service_type*]
# Type of service. Defaults to 'alarming'.
#
# [*public_protocol*]
# Protocol for public endpoint. Defaults to 'http'.
#
# [*public_address*]
# Public address for endpoint. Defaults to '127.0.0.1'.
#
# [*admin_protocol*]
# Protocol for admin endpoint. Defaults to 'http'.
#
# [*admin_address*]
# Admin address for endpoint. Defaults to '127.0.0.1'.
#
# [*internal_protocol*]
# Protocol for internal endpoint. Defaults to 'http'.
#
# [*internal_address*]
# Internal address for endpoint. Defaults to '127.0.0.1'.
#
# [*port*]
# Port for endpoint. Defaults to '8042'.
#
# [*public_port*]
# Port for public endpoint. Defaults to $port.
# Type of service. Defaults to 'key-manager'.
#
# [*region*]
# Region for endpoint. Defaults to 'RegionOne'.
@ -61,6 +37,17 @@
# (optional) Name of the service.
# Defaults to the value of auth_name.
#
# [*public_url*]
# (optional) The endpoint's public url. (Defaults to 'http://127.0.0.1:9311')
# This url should *not* contain any trailing '/'.
#
# [*admin_url*]
# (optional) The endpoint's admin url. (Defaults to 'http://127.0.0.1:9311')
# This url should *not* contain any trailing '/'.
#
# [*internal_url*]
# (optional) The endpoint's internal url. (Defaults to 'http://127.0.0.1:9311')
# This url should *not* contain any trailing '/'.
#
class aodh::keystone::auth (
$password,
@ -72,45 +59,29 @@ class aodh::keystone::auth (
$configure_user_role = true,
$service_name = undef,
$service_type = 'alarming',
$public_protocol = 'http',
$public_address = '127.0.0.1',
$admin_protocol = 'http',
$admin_address = '127.0.0.1',
$internal_protocol = 'http',
$internal_address = '127.0.0.1',
$port = '8042',
$public_port = undef,
$region = 'RegionOne'
$region = 'RegionOne',
$public_url = 'http://127.0.0.1:8042',
$internal_url = 'http://127.0.0.1:8042',
$admin_url = 'http://127.0.0.1:8042',
) {
$real_service_name = pick($service_name, $auth_name)
if $configure_user_role {
Keystone_user_role["${auth_name}@${tenant}"] ~> Service <| name == 'aodh-server' |>
}
Keystone_endpoint["${region}/${real_service_name}"] ~> Service <| name == 'aodh-server' |>
if ! $public_port {
$real_public_port = $port
} else {
$real_public_port = $public_port
}
keystone::resource::service_identity { 'aodh':
configure_user => $configure_user,
configure_user_role => $configure_user_role,
configure_endpoint => $configure_endpoint,
service_name => $real_service_name,
service_type => $service_type,
service_description => 'AODH Alarming Service',
service_description => 'OpenStack Alarming Service',
region => $region,
auth_name => $auth_name,
password => $password,
email => $email,
tenant => $tenant,
public_url => "${public_protocol}://${public_address}:${real_public_port}/",
internal_url => "${internal_protocol}://${internal_address}:${port}/",
admin_url => "${admin_protocol}://${admin_address}:${port}/",
public_url => $public_url,
internal_url => $internal_url,
admin_url => $admin_url,
}
}

View File

@ -30,46 +30,43 @@ describe 'aodh::keystone::auth' do
it { is_expected.to contain_keystone_service('aodh').with(
:ensure => 'present',
:type => 'alarming',
:description => 'AODH Alarming Service'
:description => 'OpenStack Alarming Service'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh').with(
:ensure => 'present',
:public_url => "http://127.0.0.1:8042/",
:admin_url => "http://127.0.0.1:8042/",
:internal_url => "http://127.0.0.1:8042/"
:public_url => 'http://127.0.0.1:8042',
:admin_url => 'http://127.0.0.1:8042',
:internal_url => 'http://127.0.0.1:8042',
) }
end
describe 'when overriding public_protocol, public_port and public address' do
describe 'when overriding URL parameters' do
let :params do
{ :password => 'aodh_password',
:public_protocol => 'https',
:public_port => '80',
:public_address => '10.10.10.10',
:port => '81',
:internal_address => '10.10.10.11',
:admin_address => '10.10.10.12' }
{ :password => 'aodh_password',
:public_url => 'https://10.10.10.10:80',
:internal_url => 'http://10.10.10.11:81',
:admin_url => 'http://10.10.10.12:81' }
end
it { is_expected.to contain_keystone_endpoint('RegionOne/aodh').with(
:ensure => 'present',
:public_url => "https://10.10.10.10:80/",
:internal_url => "http://10.10.10.11:81/",
:admin_url => "http://10.10.10.12:81/"
:public_url => 'https://10.10.10.10:80',
:internal_url => 'http://10.10.10.11:81',
:admin_url => 'http://10.10.10.12:81'
) }
end
describe 'when overriding auth name' do
let :params do
{ :password => 'foo',
:auth_name => 'aodhy' }
:auth_name => 'aodhany' }
end
it { is_expected.to contain_keystone_user('aodhy') }
it { is_expected.to contain_keystone_user_role('aodhy@services') }
it { is_expected.to contain_keystone_service('aodhy') }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodhy') }
it { is_expected.to contain_keystone_user('aodhany') }
it { is_expected.to contain_keystone_user_role('aodhany@services') }
it { is_expected.to contain_keystone_service('aodhany') }
it { is_expected.to contain_keystone_endpoint('RegionOne/aodhany') }
end
describe 'when overriding service name' do
@ -99,7 +96,7 @@ describe 'aodh::keystone::auth' do
it { is_expected.to contain_keystone_service('aodh').with(
:ensure => 'present',
:type => 'alarming',
:description => 'AODH Alarming Service'
:description => 'OpenStack Alarming Service'
) }
end
@ -119,7 +116,7 @@ describe 'aodh::keystone::auth' do
it { is_expected.to contain_keystone_service('aodh').with(
:ensure => 'present',
:type => 'alarming',
:description => 'AODH Alarming Service'
:description => 'OpenStack Alarming Service'
) }
end