Add ability to not configure EC2 endpoint

As EC2 api can be disabled by removing it from enabled_apis
in nova::api, this patch adds the ability to not configure
the EC2 service and endpoint in keystone.

Change-Id: I97790cc44418a00696cf294158ce47511fdc1918
This commit is contained in:
Mathieu Gagné
2013-05-14 19:50:11 -04:00
parent f0674053aa
commit 7de7e1bed7
2 changed files with 47 additions and 53 deletions

View File

@@ -1,19 +1,20 @@
class nova::keystone::auth(
$password,
$auth_name = 'nova',
$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',
$compute_version = 'v2',
$volume_version = 'v1',
$region = 'RegionOne',
$tenant = 'services',
$email = 'nova@localhost',
$cinder = false,
$public_protocol = 'http'
$auth_name = 'nova',
$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',
$compute_version = 'v2',
$volume_version = 'v1',
$region = 'RegionOne',
$tenant = 'services',
$email = 'nova@localhost',
$configure_ec2_endpoint = true,
$cinder = false,
$public_protocol = 'http'
) {
keystone_user { $auth_name:
@@ -52,16 +53,17 @@ class nova::keystone::auth(
}
}
keystone_service { "${auth_name}_ec2":
ensure => present,
type => 'ec2',
description => 'EC2 Service',
if $configure_ec2_endpoint {
keystone_service { "${auth_name}_ec2":
ensure => present,
type => 'ec2',
description => 'EC2 Service',
}
keystone_endpoint { "${region}/${auth_name}_ec2":
ensure => present,
public_url => "${public_protocol}://${public_address}:${ec2_port}/services/Cloud",
admin_url => "http://${admin_address}:${ec2_port}/services/Admin",
internal_url => "http://${internal_address}:${ec2_port}/services/Cloud",
}
}
keystone_endpoint { "${region}/${auth_name}_ec2":
ensure => present,
public_url => "${public_protocol}://${public_address}:${ec2_port}/services/Cloud",
admin_url => "http://${admin_address}:${ec2_port}/services/Admin",
internal_url => "http://${internal_address}:${ec2_port}/services/Cloud",
}
}

View File

@@ -2,11 +2,11 @@ require 'spec_helper'
describe 'nova::keystone::auth' do
describe 'with defaults' do
let :params do
{:password => 'nova_password'}
end
let :params do
{:password => 'nova_password'}
end
context 'with default parameters' do
it { should contain_keystone_user('nova').with(
:ensure => 'present',
@@ -59,10 +59,9 @@ describe 'nova::keystone::auth' do
end
describe 'when setting auth name' do
let :params do
{:password => 'nova_password', :auth_name => 'foo' }
context 'when setting auth name' do
before do
params.merge!( :auth_name => 'foo' )
end
it { should contain_keystone_user('foo').with(
@@ -95,25 +94,9 @@ describe 'nova::keystone::auth' do
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
{
:password => 'nova_password',
context 'when overriding endpoint params' do
before do
params.merge!(
:public_address => '10.0.0.1',
:admin_address => '10.0.0.2',
:internal_address => '10.0.0.3',
@@ -123,7 +106,7 @@ describe 'nova::keystone::auth' do
:volume_version => 'v2.1',
:compute_version => 'v2.2',
:region => 'RegionTwo'
}
)
end
it { should contain_keystone_endpoint('RegionTwo/nova').with(
@@ -149,4 +132,13 @@ describe 'nova::keystone::auth' do
end
describe 'when disabling EC2 endpoint' do
before do
params.merge!( :configure_ec2_endpoint => false )
end
it { should_not contain_keystone_service('nova_ec2') }
it { should_not contain_keystone_endpoint('RegionOne/nova_ec2') }
end
end