From 7de7e1bed78feec516786304521f4017cf619d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Gagne=CC=81?= Date: Tue, 14 May 2013 19:50:11 -0400 Subject: [PATCH] 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 --- manifests/keystone/auth.pp | 52 +++++++++++---------- spec/classes/nova_keystone_endpoint_spec.rb | 48 ++++++++----------- 2 files changed, 47 insertions(+), 53 deletions(-) diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index f893291dd..8d7396142 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -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", - } - } diff --git a/spec/classes/nova_keystone_endpoint_spec.rb b/spec/classes/nova_keystone_endpoint_spec.rb index 70e3d73ba..ddceb2f6c 100644 --- a/spec/classes/nova_keystone_endpoint_spec.rb +++ b/spec/classes/nova_keystone_endpoint_spec.rb @@ -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