From e437b44d44c0fb584a7071bfa314be3b4e72f11e Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Mon, 21 Jan 2013 10:30:18 +0100 Subject: [PATCH] Allow to have a different internal address and public address Change-Id: Id87323393a3bfd0ac3c9bc80fa2f46775e102eea --- manifests/keystone/auth.pp | 12 ++++++++++-- spec/classes/swift_keystone_auth_spec.rb | 9 +++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/manifests/keystone/auth.pp b/manifests/keystone/auth.pp index fc7d251e..264b348e 100644 --- a/manifests/keystone/auth.pp +++ b/manifests/keystone/auth.pp @@ -7,6 +7,7 @@ class swift::keystone::auth( $email = 'swift@localhost', $region = 'RegionOne', $public_protocol = 'http', + $public_address = undef, $public_port = undef ) { @@ -15,6 +16,13 @@ class swift::keystone::auth( } else { $real_public_port = $public_port } + + if ! $public_address { + $real_public_address = $address + } else { + $real_public_address = $public_address + } + keystone_user { $auth_name: ensure => present, password => $password, @@ -34,7 +42,7 @@ class swift::keystone::auth( } keystone_endpoint { "${region}/${auth_name}": ensure => present, - public_url => "${public_protocol}://${address}:${real_public_port}/v1/AUTH_%(tenant_id)s", + public_url => "${public_protocol}://${real_public_address}:${real_public_port}/v1/AUTH_%(tenant_id)s", admin_url => "http://${address}:${port}/", internal_url => "http://${address}:${port}/v1/AUTH_%(tenant_id)s", } @@ -46,7 +54,7 @@ class swift::keystone::auth( } keystone_endpoint { "${region}/${auth_name}_s3": ensure => present, - public_url => "${public_protocol}://${address}:${real_public_port}", + public_url => "${public_protocol}://${real_public_address}:${real_public_port}", admin_url => "http://${address}:${port}", internal_url => "http://${address}:${port}", } diff --git a/spec/classes/swift_keystone_auth_spec.rb b/spec/classes/swift_keystone_auth_spec.rb index ee39c089..bb336cf4 100644 --- a/spec/classes/swift_keystone_auth_spec.rb +++ b/spec/classes/swift_keystone_auth_spec.rb @@ -42,24 +42,25 @@ describe 'swift::keystone::auth' do ) } end - describe 'when overriding public_port' do + describe 'when overriding public_port and public address' do let :params do { - :public_port => '80' + :public_port => '80', + :public_address => '10.10.10.10' } end it { should contain_keystone_endpoint('RegionOne/swift').with( :ensure => 'present', - :public_url => "http://127.0.0.1:80/v1/AUTH_%(tenant_id)s", + :public_url => "http://10.10.10.10:80/v1/AUTH_%(tenant_id)s", :admin_url => "http://127.0.0.1:8080/", :internal_url => "http://127.0.0.1:8080/v1/AUTH_%(tenant_id)s" ) } it { should contain_keystone_endpoint('RegionOne/swift_s3').with( :ensure => 'present', - :public_url => 'http://127.0.0.1:80', + :public_url => 'http://10.10.10.10:80', :admin_url => 'http://127.0.0.1:8080', :internal_url => 'http://127.0.0.1:8080' ) }