diff --git a/CHANGELOG.md b/CHANGELOG.md index 8467960..7f814b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ openstack-block-storage Cookbook CHANGELOG This file is used to list changes made in each version of the openstack-block-storage cookbook. ## 10.1.0 * Add disable logic for stage fix to tgtd issue on RHEL 7 +* Use common specific_endpoint routines (bug 1412919) ## 10.0.1 # Update cinder.conf mode from 0644 to 0640 diff --git a/recipes/cinder-common.rb b/recipes/cinder-common.rb index cf52a4c..8a9d4b9 100644 --- a/recipes/cinder-common.rb +++ b/recipes/cinder-common.rb @@ -58,7 +58,7 @@ when 'cinder.volume.drivers.vmware.vmdk.VMwareVcVmdkDriver' vmware_host_pass = get_secret node['openstack']['block-storage']['vmware']['secret_name'] end -glance_api_endpoint = endpoint 'image-api' +glance_api_endpoint = internal_endpoint 'image-api' cinder_api_bind = endpoint 'block-storage-api-bind' directory '/etc/cinder' do @@ -84,8 +84,8 @@ else end end -identity_endpoint = endpoint 'identity-api' -identity_admin_endpoint = endpoint 'identity-admin' +identity_endpoint = internal_endpoint 'identity-internal' +identity_admin_endpoint = admin_endpoint 'identity-admin' service_pass = get_password 'service', 'openstack-block-storage' auth_uri = auth_uri_transform(identity_endpoint.to_s, node['openstack']['block-storage']['api']['auth']['version']) diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb index e8758f5..cda7905 100644 --- a/recipes/identity_registration.rb +++ b/recipes/identity_registration.rb @@ -26,10 +26,12 @@ class ::Chef::Recipe # rubocop:disable Documentation include ::Openstack end -identity_admin_endpoint = endpoint 'identity-admin' +identity_admin_endpoint = admin_endpoint 'identity-admin' bootstrap_token = get_secret 'openstack_identity_bootstrap_token' auth_uri = ::URI.decode identity_admin_endpoint.to_s -cinder_api_endpoint = endpoint 'block-storage-api' +admin_cinder_api_endpoint = admin_endpoint 'block-storage-api' +internal_cinder_api_endpoint = internal_endpoint 'block-storage-api' +public_cinder_api_endpoint = public_endpoint 'block-storage-api' service_pass = get_password 'service', 'openstack-block-storage' region = node['openstack']['block-storage']['region'] service_tenant_name = node['openstack']['block-storage']['service_tenant_name'] @@ -52,9 +54,9 @@ openstack_identity_register 'Register Cinder V2 Volume Service' do service_type 'volumev2' service_description 'Cinder Volume Service V2' endpoint_region region - endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s - endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s - endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s + endpoint_adminurl ::URI.decode admin_cinder_api_endpoint.to_s + endpoint_internalurl ::URI.decode internal_cinder_api_endpoint.to_s + endpoint_publicurl ::URI.decode public_cinder_api_endpoint.to_s action :create_service end @@ -65,9 +67,9 @@ openstack_identity_register 'Register Cinder V2 Volume Endpoint' do service_type 'volumev2' service_description 'Cinder Volume Service V2' endpoint_region region - endpoint_adminurl ::URI.decode cinder_api_endpoint.to_s - endpoint_internalurl ::URI.decode cinder_api_endpoint.to_s - endpoint_publicurl ::URI.decode cinder_api_endpoint.to_s + endpoint_adminurl ::URI.decode admin_cinder_api_endpoint.to_s + endpoint_internalurl ::URI.decode internal_cinder_api_endpoint.to_s + endpoint_publicurl ::URI.decode public_cinder_api_endpoint.to_s action :create_endpoint end diff --git a/spec/cinder_common_spec.rb b/spec/cinder_common_spec.rb index f77efef..27409c5 100644 --- a/spec/cinder_common_spec.rb +++ b/spec/cinder_common_spec.rb @@ -43,14 +43,14 @@ describe 'openstack-block-storage::cinder-common' do let(:test_pass) { 'test_pass' } before do endpoint = double(port: 'port', host: 'host', scheme: 'scheme') - allow_any_instance_of(Chef::Recipe).to receive(:endpoint) + allow_any_instance_of(Chef::Recipe).to receive(:internal_endpoint) .with('image-api') .and_return(endpoint) - allow_any_instance_of(Chef::Recipe).to receive(:endpoint) + allow_any_instance_of(Chef::Recipe).to receive(:admin_endpoint) .with('identity-admin') .and_return(endpoint) - allow_any_instance_of(Chef::Recipe).to receive(:endpoint) - .with('identity-api') + allow_any_instance_of(Chef::Recipe).to receive(:internal_endpoint) + .with('identity-internal') .and_return(endpoint) allow_any_instance_of(Chef::Recipe).to receive(:endpoint) .with('block-storage-api-bind') diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb index 0d3b1a1..89ef2a0 100644 --- a/spec/identity_registration_spec.rb +++ b/spec/identity_registration_spec.rb @@ -56,6 +56,102 @@ describe 'openstack-block-storage::identity_registration' do ) end + it 'with different admin URL' do + admin_url = 'https://admin.host:123/admin_path' + general_url = 'http://general.host:456/general_path' + + # Set the general endpoint + node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url + # Set the admin endpoint override + node.set['openstack']['endpoints']['admin']['block-storage-api']['uri'] = admin_url + + expect(chef_run).to create_endpoint_openstack_identity_register( + 'Register Cinder V2 Volume Endpoint' + ).with( + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_name: 'cinderv2', + service_type: 'volumev2', + service_description: 'Cinder Volume Service V2', + endpoint_region: 'RegionOne', + endpoint_adminurl: admin_url, + endpoint_internalurl: general_url, + endpoint_publicurl: general_url + ) + end + + it 'with different public URL' do + public_url = 'https://public.host:789/public_path' + general_url = 'http://general.host:456/general_path' + + # Set the general endpoint + node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url + # Set the public endpoint override + node.set['openstack']['endpoints']['public']['block-storage-api']['uri'] = public_url + + expect(chef_run).to create_endpoint_openstack_identity_register( + 'Register Cinder V2 Volume Endpoint' + ).with( + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_name: 'cinderv2', + service_type: 'volumev2', + service_description: 'Cinder Volume Service V2', + endpoint_region: 'RegionOne', + endpoint_adminurl: general_url, + endpoint_internalurl: general_url, + endpoint_publicurl: public_url + ) + end + + it 'with different internal URL' do + internal_url = 'http://internal.host:456/internal_path' + general_url = 'http://general.host:456/general_path' + + # Set the general endpoint + node.set['openstack']['endpoints']['block-storage-api']['uri'] = general_url + # Set the internal endpoint override + node.set['openstack']['endpoints']['internal']['block-storage-api']['uri'] = internal_url + + expect(chef_run).to create_endpoint_openstack_identity_register( + 'Register Cinder V2 Volume Endpoint' + ).with( + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_name: 'cinderv2', + service_type: 'volumev2', + service_description: 'Cinder Volume Service V2', + endpoint_region: 'RegionOne', + endpoint_adminurl: general_url, + endpoint_internalurl: internal_url, + endpoint_publicurl: general_url + ) + end + + it 'with all different URLs' do + admin_url = 'https://admin.host:123/admin_path' + internal_url = 'http://internal.host:456/internal_path' + public_url = 'https://public.host:789/public_path' + + node.set['openstack']['endpoints']['internal']['block-storage-api']['uri'] = internal_url + node.set['openstack']['endpoints']['admin']['block-storage-api']['uri'] = admin_url + node.set['openstack']['endpoints']['public']['block-storage-api']['uri'] = public_url + + expect(chef_run).to create_endpoint_openstack_identity_register( + 'Register Cinder V2 Volume Endpoint' + ).with( + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_name: 'cinderv2', + service_type: 'volumev2', + service_description: 'Cinder Volume Service V2', + endpoint_region: 'RegionOne', + endpoint_adminurl: admin_url, + endpoint_internalurl: internal_url, + endpoint_publicurl: public_url + ) + end + it 'with custom region override' do node.set['openstack']['block-storage']['region'] = 'volumeRegion' expect(chef_run).to create_endpoint_openstack_identity_register(