Refactor endpoint code
This commit refactors the nova::keystone::auth code. - makes the configuration of public,internal, and admin address separate. makes region configurable.
This commit is contained in:
parent
8c32b4a7b5
commit
32c233347c
|
@ -1,12 +1,14 @@
|
|||
class nova::keystone::auth(
|
||||
$auth_name = 'nova',
|
||||
$password = 'nova_password',
|
||||
$service = 'compute',
|
||||
$address = '127.0.0.1',
|
||||
$compute_port = '8774',
|
||||
$volume_port = '8776',
|
||||
$ec2_port = '8773',
|
||||
$version = 'v1.1'
|
||||
$auth_name = 'nova',
|
||||
$password = 'nova_password',
|
||||
$public_address = '127.0.0.1',
|
||||
$admin_address = '127.0.0.1',
|
||||
$internal_address = '127.0.0.1',
|
||||
$compute_port = '8774',
|
||||
$volume_port = '8776',
|
||||
$ec2_port = '8773',
|
||||
$version = 'v1.1',
|
||||
$region = 'RegionOne'
|
||||
) {
|
||||
|
||||
keystone_user { $auth_name:
|
||||
|
@ -16,19 +18,18 @@ class nova::keystone::auth(
|
|||
keystone_user_role { "${auth_name}@services":
|
||||
ensure => present,
|
||||
roles => 'admin',
|
||||
require => Keystone_user[$auth_name]
|
||||
}
|
||||
keystone_service { $auth_name:
|
||||
ensure => present,
|
||||
ensure => present,
|
||||
type => 'compute',
|
||||
description => "Openstack Compute Service",
|
||||
}
|
||||
keystone_endpoint { $auth_name:
|
||||
ensure => present,
|
||||
region => 'RegionOne',
|
||||
public_url => "http://${address}:${compute_port}/${version}/%(tenant_id)s",
|
||||
admin_url => "http://${address}:${compute_port}/${version}/%(tenant_id)s",
|
||||
internal_url => "http://${address}:${compute_port}/${version}/%(tenant_id)s",
|
||||
region => $region,
|
||||
public_url => "http://${public_address}:${compute_port}/${version}/%(tenant_id)s",
|
||||
admin_url => "http://${admin_address}:${compute_port}/${version}/%(tenant_id)s",
|
||||
internal_url => "http://${internal_address}:${compute_port}/${version}/%(tenant_id)s",
|
||||
}
|
||||
|
||||
keystone_service { "${auth_name}_volume":
|
||||
|
@ -38,23 +39,23 @@ class nova::keystone::auth(
|
|||
}
|
||||
keystone_endpoint { "${auth_name}_volume":
|
||||
ensure => present,
|
||||
region => 'RegionOne',
|
||||
public_url => "http://${address}:${volume_port}/${version}/%(tenant_id)s",
|
||||
admin_url => "http://${address}:${volume_port}/${version}/%(tenant_id)s",
|
||||
internal_url => "http://${address}:${volume_port}/${version}/%(tenant_id)s",
|
||||
region => $region,
|
||||
public_url => "http://${public_address}:${volume_port}/${version}/%(tenant_id)s",
|
||||
admin_url => "http://${admin_address}:${volume_port}/${version}/%(tenant_id)s",
|
||||
internal_url => "http://${internal_address}:${volume_port}/${version}/%(tenant_id)s",
|
||||
}
|
||||
|
||||
keystone_service { "${auth_name}_ec2":
|
||||
ensure => present,
|
||||
type => 'ec2',
|
||||
description => 'EC2 service',
|
||||
description => 'EC2 Service',
|
||||
}
|
||||
keystone_endpoint { "${auth_name}_ec2":
|
||||
ensure => present,
|
||||
region => 'RegionOne',
|
||||
public_url => "http://${address}:${ec2_port}/services/Cloud",
|
||||
admin_url => "http://${address}:${ec2_port}/services/Admin",
|
||||
internal_url => "http://${address}:${ec2_port}/services/Cloud",
|
||||
region => $region,
|
||||
public_url => "http://${public_address}:${ec2_port}/services/Cloud",
|
||||
admin_url => "http://${admin_address}:${ec2_port}/services/Admin",
|
||||
internal_url => "http://${internal_address}:${ec2_port}/services/Cloud",
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,152 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'nova::keystone::auth' do
|
||||
|
||||
describe 'with defaults' do
|
||||
|
||||
it { should contain_keystone_user('nova').with(
|
||||
:ensure => 'present',
|
||||
:password => 'nova_password'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_user_role('nova@services').with(
|
||||
:ensure => 'present',
|
||||
:roles => 'admin'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('nova').with(
|
||||
:ensure => 'present',
|
||||
:type => 'compute',
|
||||
:description => 'Openstack Compute Service'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('nova_volume').with(
|
||||
:ensure => 'present',
|
||||
:type => 'volume',
|
||||
:description => 'Volume Service'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('nova_ec2').with(
|
||||
:ensure => 'present',
|
||||
:type => 'ec2',
|
||||
:description => 'EC2 Service'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_endpoint('nova').with(
|
||||
:ensure => 'present',
|
||||
:region => 'RegionOne',
|
||||
:public_url => 'http://127.0.0.1:8774/v1.1/%(tenant_id)s',
|
||||
:admin_url => 'http://127.0.0.1:8774/v1.1/%(tenant_id)s',
|
||||
:internal_url => 'http://127.0.0.1:8774/v1.1/%(tenant_id)s'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_endpoint('nova_volume').with(
|
||||
:ensure => 'present',
|
||||
:region => 'RegionOne',
|
||||
:public_url => 'http://127.0.0.1:8776/v1.1/%(tenant_id)s',
|
||||
:admin_url => 'http://127.0.0.1:8776/v1.1/%(tenant_id)s',
|
||||
:internal_url => 'http://127.0.0.1:8776/v1.1/%(tenant_id)s'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_endpoint('nova_ec2').with(
|
||||
:ensure => 'present',
|
||||
:region => 'RegionOne',
|
||||
:public_url => 'http://127.0.0.1:8773/services/Cloud',
|
||||
:admin_url => 'http://127.0.0.1:8773/services/Admin',
|
||||
:internal_url => 'http://127.0.0.1:8773/services/Cloud'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
describe 'when setting auth name' do
|
||||
|
||||
let :params do
|
||||
{:auth_name => 'foo' }
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('foo').with(
|
||||
:ensure => 'present',
|
||||
:password => 'nova_password'
|
||||
) }
|
||||
|
||||
it { should contain_keystone_user_role('foo@services').with(
|
||||
:ensure => 'present',
|
||||
:roles => 'admin'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('foo').with(
|
||||
:ensure => 'present',
|
||||
:type => 'compute',
|
||||
:description => 'Openstack Compute Service'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('foo_volume').with(
|
||||
:ensure => 'present',
|
||||
:type => 'volume',
|
||||
:description => 'Volume Service'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_service('foo_ec2').with(
|
||||
:ensure => 'present',
|
||||
:type => 'ec2',
|
||||
:description => 'EC2 Service'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
describe 'when setting password' do
|
||||
|
||||
let :params do
|
||||
{ :password => 'pass'}
|
||||
end
|
||||
|
||||
it { should contain_keystone_user('nova').with(
|
||||
:ensure => 'present',
|
||||
:password => 'pass'
|
||||
) }
|
||||
|
||||
end
|
||||
|
||||
|
||||
describe 'when overriding endpoint params' do
|
||||
|
||||
let :params do
|
||||
{
|
||||
:public_address => '10.0.0.1',
|
||||
:admin_address => '10.0.0.2',
|
||||
:internal_address => '10.0.0.3',
|
||||
:compute_port => '9774',
|
||||
:volume_port => '9776',
|
||||
:ec2_port => '9773',
|
||||
:version => 'v2.1',
|
||||
:region => 'RegionTwo'
|
||||
}
|
||||
end
|
||||
|
||||
it { should contain_keystone_endpoint('nova').with(
|
||||
:ensure => 'present',
|
||||
:region => 'RegionTwo',
|
||||
:public_url => 'http://10.0.0.1:9774/v2.1/%(tenant_id)s',
|
||||
:admin_url => 'http://10.0.0.2:9774/v2.1/%(tenant_id)s',
|
||||
:internal_url => 'http://10.0.0.3:9774/v2.1/%(tenant_id)s'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_endpoint('nova_volume').with(
|
||||
:ensure => 'present',
|
||||
:region => 'RegionTwo',
|
||||
:public_url => 'http://10.0.0.1:9776/v2.1/%(tenant_id)s',
|
||||
:admin_url => 'http://10.0.0.2:9776/v2.1/%(tenant_id)s',
|
||||
:internal_url => 'http://10.0.0.3:9776/v2.1/%(tenant_id)s'
|
||||
)}
|
||||
|
||||
it { should contain_keystone_endpoint('nova_ec2').with(
|
||||
:ensure => 'present',
|
||||
:region => 'RegionTwo',
|
||||
:public_url => 'http://10.0.0.1:9773/services/Cloud',
|
||||
:admin_url => 'http://10.0.0.2:9773/services/Admin',
|
||||
:internal_url => 'http://10.0.0.3:9773/services/Cloud'
|
||||
)}
|
||||
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue