Merge "Introduce public_url, internal_url and admin_url"

This commit is contained in:
Jenkins 2015-06-27 15:18:27 +00:00 committed by Gerrit Code Review
commit d64f2e92f2
2 changed files with 258 additions and 76 deletions

View File

@ -58,30 +58,101 @@
# [*port*]
# Port for endpoint. Optional. Defaults to '8776'.
#
# [*volume_version*]
# Cinder API version. Optional. Defaults to 'v1'.
#
# [*region*]
# Region for endpoint. Optional. Defaults to 'RegionOne'.
#
# [*tenant*]
# Tenant for Cinder user. Optional. Defaults to 'services'.
#
# [*public_url*]
# (optional) The endpoint's public url. (Defaults to 'http://127.0.0.1:8776/v1/%(tenant_id)s')
# This url should *not* contain any trailing '/'.
#
# [*internal_url*]
# (optional) The endpoint's internal url. (Defaults to 'http://127.0.0.1:8776/v1/%(tenant_id)s')
# This url should *not* contain any trailing '/'.
#
# [*admin_url*]
# (optional) The endpoint's admin url. (Defaults to 'http://127.0.0.1:8776/v1/%(tenant_id)s')
# This url should *not* contain any trailing '/'.
#
# [*public_url_v2*]
# (optional) The v2 endpoint's public url. (Defaults to 'http://127.0.0.1:8776/v2/%(tenant_id)s')
# This url should *not* contain any trailing '/'.
#
# [*internal_url_v2*]
# (optional) The v2 endpoint's internal url. (Defaults to 'http://127.0.0.1:8776/v2/%(tenant_id)s')
# This url should *not* contain any trailing '/'.
#
# [*admin_url_v2*]
# (optional) The v2 endpoint's admin url. (Defaults to 'http://127.0.0.1:8776/v2/%(tenant_id)s')
# This url should *not* contain any trailing '/'.
#
# [*volume_version*]
# (optional) DEPRECATED: Use public_url, internal_url and admin_url instead.
# Cinder API version. (Defaults to 'v1')
# Setting this parameter overrides public_url, internal_url and admin_url parameters.
#
# [*port*]
# (optional) DEPRECATED: Use public_url, internal_url and admin_url instead.
# Port for endpoint. (Defaults to 8776)
# Setting this parameter overrides public_url, internal_url and admin_url parameters.
#
# [*public_protocol*]
# Protocol for public endpoint. Optional. Defaults to 'http'.
# (optional) DEPRECATED: Use public_url instead.
# Protocol for public endpoint. (Defaults to 'http')
# Setting this parameter overrides public_url parameter.
#
# [*internal_protocol*]
# Protocol for internal endpoint. Optional. Defaults to 'http'.
# (optional) DEPRECATED: Use internal_url and internal_url_v2 instead.
# Protocol for internal endpoint. (Defaults to 'http')
# Setting this parameter overrides internal_url and internal_url_v2 parameter.
#
# [*admin_protocol*]
# Protocol for admin endpoint. Optional. Defaults to 'http'.
# (optional) DEPRECATED: Use admin_url and admin_url_v2 instead.
# Protocol for admin endpoint. (Defaults to 'http')
# Setting this parameter overrides admin_url and admin_url_v2 parameter.
#
# [*public_address*]
# (optional) DEPRECATED: Use public_url instead.
# Public address for endpoint. (Defaults to '127.0.0.1')
# Setting this parameter overrides public_url and public_url_v2 parameter.
#
# [*internal_address*]
# (optional) DEPRECATED: Use internal_url instead.
# Internal address for endpoint. (Defaults to '127.0.0.1')
# Setting this parameter overrides internal_url and internal_url_v2 parameter.
#
# [*admin_address*]
# (optional) DEPRECATED: Use admin_url instead.
# Admin address for endpoint. (Defaults to '127.0.0.1')
# Setting this parameter overrides admin_url and admin_url_v2 parameter.
#
# === Deprecation notes
#
# If any value is provided for public_protocol, public_address or public_port parameters,
# public_url will be completely ignored. The same applies for internal and admin parameters.
#
# === Examples
#
# class { 'cinder::keystone::auth':
# public_url => 'https://10.0.0.10:8776/v1/%(tenant_id)s',
# internal_url => 'https://10.0.0.20:8776/v1/%(tenant_id)s',
# admin_url => 'https://10.0.0.30:8776/v1/%(tenant_id)s',
# }
#
class cinder::keystone::auth (
$password,
$auth_name = 'cinder',
$auth_name_v2 = 'cinderv2',
$email = 'cinder@localhost',
$tenant = 'services',
$email = 'cinder@localhost',
$public_url = 'http://127.0.0.1:8776/v1/%(tenant_id)s',
$internal_url = 'http://127.0.0.1:8776/v1/%(tenant_id)s',
$admin_url = 'http://127.0.0.1:8776/v1/%(tenant_id)s',
$public_url_v2 = 'http://127.0.0.1:8776/v2/%(tenant_id)s',
$internal_url_v2 = 'http://127.0.0.1:8776/v2/%(tenant_id)s',
$admin_url_v2 = 'http://127.0.0.1:8776/v2/%(tenant_id)s',
$configure_endpoint = true,
$configure_endpoint_v2 = true,
$configure_user = true,
@ -90,30 +161,114 @@ class cinder::keystone::auth (
$service_name_v2 = undef,
$service_type = 'volume',
$service_type_v2 = 'volumev2',
$public_address = '127.0.0.1',
$admin_address = '127.0.0.1',
$internal_address = '127.0.0.1',
$port = '8776',
$volume_version = 'v1',
$region = 'RegionOne',
$public_protocol = 'http',
$admin_protocol = 'http',
$internal_protocol = 'http'
# DEPRECATED PARAMETERS
$port = undef,
$volume_version = undef,
$public_address = undef,
$admin_address = undef,
$internal_address = undef,
$public_protocol = undef,
$admin_protocol = undef,
$internal_protocol = undef
) {
if $service_name {
$real_service_name = $service_name
} else {
$real_service_name = $auth_name
if $volume_version {
warning('The volume_version parameter is deprecated, use public_url, internal_url and admin_url instead.')
}
if $service_name_v2 {
$real_service_name_v2 = $service_name_v2
} else {
$real_service_name_v2 = $auth_name_v2
if $port {
warning('The port parameter is deprecated, use public_url, internal_url and admin_url instead.')
}
if $public_protocol {
warning('The public_protocol parameter is deprecated, use public_url instead.')
}
if $internal_protocol {
warning('The internal_protocol parameter is deprecated, use internal_url instead.')
}
if $admin_protocol {
warning('The admin_protocol parameter is deprecated, use admin_url instead.')
}
if $public_address {
warning('The public_address parameter is deprecated, use public_url instead.')
}
if $internal_address {
warning('The internal_address parameter is deprecated, use internal_url instead.')
}
if $admin_address {
warning('The admin_address parameter is deprecated, use admin_url instead.')
}
$real_service_name = pick($service_name, $auth_name)
$real_service_name_v2 = pick($service_name_v2, $auth_name_v2)
if $real_service_name == $real_service_name_v2 {
fail('cinder::keystone::auth parameters service_name and service_name_v2 must be different.')
}
if ($public_protocol or $public_address or $port or $volume_version) {
$public_url_real = sprintf('%s://%s:%s/%s/%%(tenant_id)s',
pick($public_protocol, 'http'),
pick($public_address, '127.0.0.1'),
pick($port, '8776'),
pick($volume_version, 'v1'))
} else {
$public_url_real = $public_url
}
if ($internal_protocol or $internal_address or $port or $volume_version) {
$internal_url_real = sprintf('%s://%s:%s/%s/%%(tenant_id)s',
pick($internal_protocol, 'http'),
pick($internal_address, '127.0.0.1'),
pick($port, '8776'),
pick($volume_version, 'v1'))
} else {
$internal_url_real = $internal_url
}
if ($admin_protocol or $admin_address or $port or $volume_version) {
$admin_url_real = sprintf('%s://%s:%s/%s/%%(tenant_id)s',
pick($admin_protocol, 'http'),
pick($admin_address, '127.0.0.1'),
pick($port, '8776'),
pick($volume_version, 'v1'))
} else {
$admin_url_real = $admin_url
}
if ($public_protocol or $public_address or $port) {
$public_url_v2_real = sprintf('%s://%s:%s/v2/%%(tenant_id)s',
pick($public_protocol, 'http'),
pick($public_address, '127.0.0.1'),
pick($port, '8776'))
} else {
$public_url_v2_real = $public_url_v2
}
if ($internal_protocol or $internal_address or $port) {
$internal_url_v2_real = sprintf('%s://%s:%s/v2/%%(tenant_id)s',
pick($internal_protocol, 'http'),
pick($internal_address, '127.0.0.1'),
pick($port, '8776'))
} else {
$internal_url_v2_real = $internal_url_v2
}
if ($admin_protocol or $admin_address or $port) {
$admin_url_v2_real = sprintf('%s://%s:%s/v2/%%(tenant_id)s',
pick($admin_protocol, 'http'),
pick($admin_address, '127.0.0.1'),
pick($port, '8776'))
} else {
$admin_url_v2_real = $admin_url_v2
}
keystone::resource::service_identity { 'cinder':
configure_user => $configure_user,
configure_user_role => $configure_user_role,
@ -126,9 +281,9 @@ class cinder::keystone::auth (
password => $password,
email => $email,
tenant => $tenant,
public_url => "${public_protocol}://${public_address}:${port}/${volume_version}/%(tenant_id)s",
admin_url => "${admin_protocol}://${admin_address}:${port}/${volume_version}/%(tenant_id)s",
internal_url => "${internal_protocol}://${internal_address}:${port}/${volume_version}/%(tenant_id)s",
public_url => $public_url_real,
admin_url => $admin_url_real,
internal_url => $internal_url_real,
}
keystone::resource::service_identity { 'cinderv2':
@ -139,9 +294,9 @@ class cinder::keystone::auth (
service_description => 'Cinder Service v2',
service_name => $real_service_name_v2,
region => $region,
public_url => "${public_protocol}://${public_address}:${port}/v2/%(tenant_id)s",
admin_url => "${admin_protocol}://${admin_address}:${port}/v2/%(tenant_id)s",
internal_url => "${internal_protocol}://${internal_address}:${port}/v2/%(tenant_id)s",
public_url => $public_url_v2_real,
admin_url => $admin_url_v2_real,
internal_url => $internal_url_v2_real,
}
if $configure_user_role {

View File

@ -2,17 +2,13 @@ require 'spec_helper'
describe 'cinder::keystone::auth' do
let :req_params do
let :params do
{:password => 'pw'}
end
describe 'with only required params' do
context 'with required parameters' do
let :params do
req_params
end
it 'should contain auth info' do
it 'configures keystone user and service' do
is_expected.to contain_keystone_user('cinder').with(
:ensure => 'present',
@ -36,24 +32,57 @@ describe 'cinder::keystone::auth' do
)
end
it { is_expected.to contain_keystone_endpoint('RegionOne/cinder').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:admin_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:internal_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s'
) }
it { is_expected.to contain_keystone_endpoint('RegionOne/cinderv2').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s',
:admin_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s',
:internal_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s'
) }
it 'configures keystone endpoints' do
is_expected.to contain_keystone_endpoint('RegionOne/cinder').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:admin_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s',
:internal_url => 'http://127.0.0.1:8776/v1/%(tenant_id)s'
)
is_expected.to contain_keystone_endpoint('RegionOne/cinderv2').with(
:ensure => 'present',
:public_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s',
:admin_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s',
:internal_url => 'http://127.0.0.1:8776/v2/%(tenant_id)s'
)
end
end
context 'when overriding endpoint params' do
let :params do
req_params.merge(
context 'when overriding parameters' do
before do
params.merge!({
:region => 'RegionThree',
:public_url => 'https://10.0.42.1:4242/v41/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v41/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v41/%(tenant_id)s',
:public_url_v2 => 'https://10.0.42.1:4242/v42/%(tenant_id)s',
:admin_url_v2 => 'https://10.0.42.2:4242/v42/%(tenant_id)s',
:internal_url_v2 => 'https://10.0.42.3:4242/v42/%(tenant_id)s'
})
end
it 'configures keystone endpoints' do
is_expected.to contain_keystone_endpoint('RegionThree/cinder').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v41/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v41/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v41/%(tenant_id)s'
)
is_expected.to contain_keystone_endpoint('RegionThree/cinderv2').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v42/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v42/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v42/%(tenant_id)s'
)
end
end
context 'with deprecated parameters' do
before do
params.merge!({
:public_address => '10.0.42.1',
:admin_address => '10.0.42.2',
:internal_address => '10.0.42.3',
@ -63,28 +92,30 @@ describe 'cinder::keystone::auth' do
:internal_protocol => 'https',
:public_protocol => 'https',
:volume_version => 'v42'
)
})
end
it { is_expected.to contain_keystone_endpoint('RegionThree/cinder').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v42/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v42/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v42/%(tenant_id)s'
)}
it 'configures keystone endpoints' do
is_expected.to contain_keystone_endpoint('RegionThree/cinder').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v42/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v42/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v42/%(tenant_id)s'
)
it { is_expected.to contain_keystone_endpoint('RegionThree/cinderv2').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v2/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v2/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v2/%(tenant_id)s'
)}
is_expected.to contain_keystone_endpoint('RegionThree/cinderv2').with(
:ensure => 'present',
:public_url => 'https://10.0.42.1:4242/v2/%(tenant_id)s',
:admin_url => 'https://10.0.42.2:4242/v2/%(tenant_id)s',
:internal_url => 'https://10.0.42.3:4242/v2/%(tenant_id)s'
)
end
end
describe 'when endpoint is_expected.to not be configured' do
let :params do
req_params.merge(
before do
params.merge!(
:configure_endpoint => false,
:configure_endpoint_v2 => false
)
@ -94,16 +125,14 @@ describe 'cinder::keystone::auth' do
end
describe 'when user is_expected.to not be configured' do
let :params do
req_params.merge(
before do
params.merge!(
:configure_user => false
)
end
it { is_expected.to_not contain_keystone_user('cinder') }
it { is_expected.to contain_keystone_user_role('cinder@services') }
it { is_expected.to contain_keystone_service('cinder').with(
:ensure => 'present',
:type => 'volume',
@ -113,17 +142,15 @@ describe 'cinder::keystone::auth' do
end
describe 'when user and user role is_expected.to not be configured' do
let :params do
req_params.merge(
before do
params.merge!(
:configure_user => false,
:configure_user_role => false
)
end
it { is_expected.to_not contain_keystone_user('cinder') }
it { is_expected.to_not contain_keystone_user_role('cinder@services') }
it { is_expected.to contain_keystone_service('cinder').with(
:ensure => 'present',
:type => 'volume',
@ -134,8 +161,8 @@ describe 'cinder::keystone::auth' do
describe 'when overriding service names' do
let :params do
req_params.merge(
before do
params.merge!(
:service_name => 'cinder_service',
:service_name_v2 => 'cinder_service_v2',
)