Use new common specific_endpoint routines

Now that admin_endpoint, public_endpoint, and internal_endpoint
in the common library are working, these are the changes to use
them in the openstack-block-storge recipes.

Change-Id: Ief4b9d011f55236270a4dc18f2b1f3f769d0a493
Partial-Bug: 1412919
This commit is contained in:
Ken Thomas 2015-02-02 21:44:11 +00:00
parent f75d819c2f
commit b25e15d32d
5 changed files with 114 additions and 15 deletions

View File

@ -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

View File

@ -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'])

View File

@ -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

View File

@ -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')

View File

@ -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(