diff --git a/manifests/resource/service_identity.pp b/manifests/resource/service_identity.pp index 5ad3f9ce6..2298201b0 100644 --- a/manifests/resource/service_identity.pp +++ b/manifests/resource/service_identity.pp @@ -168,9 +168,8 @@ define keystone::resource::service_identity( if $configure_service { if $service_type { - ensure_resource('keystone_service', $service_name_real, { + ensure_resource('keystone_service', "${service_name_real}::${service_type}", { 'ensure' => 'present', - 'type' => $service_type, 'description' => $service_description, }) } else { @@ -179,15 +178,29 @@ define keystone::resource::service_identity( } if $configure_endpoint { - if $public_url and $admin_url and $internal_url { - ensure_resource('keystone_endpoint', "${region}/${service_name_real}", { - 'ensure' => 'present', - 'public_url' => $public_url, - 'admin_url' => $admin_url, - 'internal_url' => $internal_url, - }) + if $service_type { + if $public_url and $admin_url and $internal_url { + ensure_resource('keystone_endpoint', "${region}/${service_name_real}::${service_type}", { + 'ensure' => 'present', + 'public_url' => $public_url, + 'admin_url' => $admin_url, + 'internal_url' => $internal_url, + }) + } else { + fail ('When configuring an endpoint, you need to set the _url parameters.') + } } else { - fail ('When configuring an endpoint, you need to set the _url parameters.') + if $public_url and $admin_url and $internal_url { + ensure_resource('keystone_endpoint', "${region}/${service_name_real}", { + 'ensure' => 'present', + 'public_url' => $public_url, + 'admin_url' => $admin_url, + 'internal_url' => $internal_url, + }) + } else { + fail ('When configuring an endpoint, you need to set the _url parameters.') + } + warning('Defining a endpoint without the type is supported in Liberty and will be dropped in Mitaka. See https://bugs.launchpad.net/puppet-keystone/+bug/1506996') } } } diff --git a/spec/classes/keystone_endpoint_spec.rb b/spec/classes/keystone_endpoint_spec.rb index bafad575e..ec6f6751d 100644 --- a/spec/classes/keystone_endpoint_spec.rb +++ b/spec/classes/keystone_endpoint_spec.rb @@ -2,14 +2,13 @@ require 'spec_helper' describe 'keystone::endpoint' do - it { is_expected.to contain_keystone_service('keystone').with( + it { is_expected.to contain_keystone_service('keystone::identity').with( :ensure => 'present', - :type => 'identity', :description => 'OpenStack Identity Service' )} describe 'with default parameters' do - it { is_expected.to contain_keystone_endpoint('RegionOne/keystone').with( + it { is_expected.to contain_keystone_endpoint('RegionOne/keystone::identity').with( :ensure => 'present', :public_url => 'http://127.0.0.1:5000/v2.0', :admin_url => 'http://127.0.0.1:35357/v2.0', @@ -26,7 +25,7 @@ describe 'keystone::endpoint' do :internal_url => 'https://identity-int.some.tld/some/internal/endpoint' } end - it { is_expected.to contain_keystone_endpoint('RegionOne/keystone').with( + it { is_expected.to contain_keystone_endpoint('RegionOne/keystone::identity').with( :ensure => 'present', :public_url => 'https://identity.some.tld/the/main/endpoint/v42.6', :admin_url => 'https://identity-int.some.tld/some/admin/endpoint/v42.6', @@ -41,7 +40,7 @@ describe 'keystone::endpoint' do { :version => '' } end - it { is_expected.to contain_keystone_endpoint('RegionOne/keystone').with( + it { is_expected.to contain_keystone_endpoint('RegionOne/keystone::identity').with( :ensure => 'present', :public_url => 'http://127.0.0.1:5000', :admin_url => 'http://127.0.0.1:35357', @@ -56,7 +55,7 @@ describe 'keystone::endpoint' do end it 'internal_url should default to public_url' do - is_expected.to contain_keystone_endpoint('RegionOne/keystone').with( + is_expected.to contain_keystone_endpoint('RegionOne/keystone::identity').with( :ensure => 'present', :public_url => 'https://identity.some.tld/the/main/endpoint/v2.0', :internal_url => 'https://identity.some.tld/the/main/endpoint/v2.0' diff --git a/spec/defines/keystone_resource_service_identity_spec.rb b/spec/defines/keystone_resource_service_identity_spec.rb index ae4dad9c6..2e5834b4d 100644 --- a/spec/defines/keystone_resource_service_identity_spec.rb +++ b/spec/defines/keystone_resource_service_identity_spec.rb @@ -47,12 +47,26 @@ describe 'keystone::resource::service_identity' do :roles => ['admin'], )} - it { is_expected.to contain_keystone_service(title).with( + it { is_expected.to contain_keystone_service("#{title}::network").with( :ensure => 'present', - :type => 'network', :description => 'neutron service', )} + it { is_expected.to contain_keystone_endpoint("RegionOne/#{title}::network").with( + :ensure => 'present', + :public_url => 'http://7.7.7.7:9696', + :internal_url => 'http://10.0.0.1:9696', + :admin_url => 'http://192.168.0.1:9696', + )} + end + + context 'when trying to create an endpoint without service_type (will be dropped in Mitaka)' do + let :params do + required_params.merge( + :configure_service => false, + :service_type => false, + ) + end it { is_expected.to contain_keystone_endpoint("RegionOne/#{title}").with( :ensure => 'present', :public_url => 'http://7.7.7.7:9696',