Use new common specific_endpoint routines

Now that admin_endpoint, public_endpoint, and internal_endpoint
in the common library are (nearly) working, these are the
changes to use them in the openstack-image recipes.

Partial-Bug: 1412919

Change-Id: If81fc2a56f540a460325de879555e95d108aac77
This commit is contained in:
Ken Thomas 2015-01-27 19:31:10 +00:00
parent 3e468ddd95
commit 31e7f0d232
8 changed files with 111 additions and 21 deletions

View File

@ -7,6 +7,7 @@ This file is used to list changes made in each version of cookbook-openstack-ima
### Blue print
* Make container_formats and disk_formats configurable
* Set the owner/group of openstack image cache directory to glance/glance.
* Use common specific_endpoint routines (bug 1412919)
## 10.0.0
* Upgrading to Juno

View File

@ -99,8 +99,8 @@ end
glance = node['openstack']['image']
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-image'
auth_uri = auth_uri_transform identity_endpoint.to_s, node['openstack']['image']['api']['auth']['version']
@ -118,9 +118,9 @@ elsif mq_service_type == 'qpid'
mq_password = get_password 'user', node['openstack']['mq']['image']['qpid']['username']
end
registry_endpoint = endpoint 'image-registry'
api_bind = endpoint 'image-api-bind'
cinder_endpoint = endpoint 'block-storage-api'
registry_endpoint = internal_endpoint 'image-registry'
api_bind = internal_endpoint 'image-api-bind'
cinder_endpoint = internal_endpoint 'block-storage-api'
# Possible combinations of options here
# - default_store=file

View File

@ -26,12 +26,14 @@ class ::Chef::Recipe # rubocop:disable Documentation
include ::Openstack
end
identity_admin_endpoint = endpoint 'identity-admin'
identity_admin_endpoint = admin_endpoint 'identity-admin'
token = get_secret 'openstack_identity_bootstrap_token'
auth_url = ::URI.decode identity_admin_endpoint.to_s
api_endpoint = endpoint 'image-api'
api_internal_endpoint = internal_endpoint 'image-api'
api_public_endpoint = public_endpoint 'image-api'
api_admin_endpoint = admin_endpoint 'image-api'
service_pass = get_password 'service', 'openstack-image'
service_tenant_name = node['openstack']['image']['service_tenant_name']
@ -56,9 +58,9 @@ openstack_identity_register 'Register Image Endpoint' do
bootstrap_token token
service_type 'image'
endpoint_region region
endpoint_adminurl api_endpoint.to_s
endpoint_internalurl api_endpoint.to_s
endpoint_publicurl api_endpoint.to_s
endpoint_adminurl api_admin_endpoint.to_s
endpoint_internalurl api_internal_endpoint.to_s
endpoint_publicurl api_public_endpoint.to_s
action :create_endpoint
end

View File

@ -33,7 +33,7 @@ platform_options['image_client_packages'].each do |pkg|
end
end
identity_endpoint = endpoint 'identity-api'
identity_endpoint = internal_endpoint 'identity-internal'
# For glance client, only identity v2 is supported. See discussion on
# https://bugs.launchpad.net/openstack-chef/+bug/1207504

View File

@ -48,9 +48,9 @@ elsif mq_service_type == 'qpid'
mq_password = get_password 'user', node['openstack']['mq']['image']['qpid']['username']
end
identity_endpoint = endpoint 'identity-api'
identity_admin_endpoint = endpoint 'identity-admin'
registry_bind = endpoint 'image-registry-bind'
identity_endpoint = internal_endpoint 'identity-internal'
identity_admin_endpoint = admin_endpoint 'identity-admin'
registry_bind = internal_endpoint 'image-registry-bind'
service_pass = get_password 'service', 'openstack-image'
auth_uri = auth_uri_transform identity_endpoint.to_s, node['openstack']['image']['registry']['auth']['version']

View File

@ -57,6 +57,93 @@ describe 'openstack-image::identity_registration' do
action: [:create_endpoint]
)
end
it 'with different public url' do
public_url = 'https://public.host:123/public_path'
node.set['openstack']['endpoints']['public']['image-api']['uri'] = public_url
resource = chef_run.find_resource(
'openstack-identity_register',
'Register Image Endpoint'
).to_hash
expect(resource).to include(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:9292',
endpoint_internalurl: 'http://127.0.0.1:9292',
endpoint_publicurl: public_url,
action: [:create_endpoint]
)
end
it 'with different admin url' do
admin_url = 'http://admin.host:456/admin_path'
node.set['openstack']['endpoints']['admin']['image-api']['uri'] = admin_url
node.set['openstack']['endpoints']['identity-admin']['uri'] = 'http://127.0.0.1:35357/v2.0'
resource = chef_run.find_resource(
'openstack-identity_register',
'Register Image Endpoint'
).to_hash
expect(resource).to include(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: admin_url,
endpoint_internalurl: 'http://127.0.0.1:9292',
endpoint_publicurl: 'http://127.0.0.1:9292',
action: [:create_endpoint]
)
end
it 'with different internal url' do
internal_url = 'http://internal.host:789/internal_path'
node.set['openstack']['endpoints']['internal']['image-api']['uri'] = internal_url
resource = chef_run.find_resource(
'openstack-identity_register',
'Register Image Endpoint'
).to_hash
expect(resource).to include(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:9292',
endpoint_internalurl: internal_url,
endpoint_publicurl: 'http://127.0.0.1:9292',
action: [:create_endpoint]
)
end
it 'with different admin,internal,public urls' do
internal_url = 'http://internal.host:789/internal_path'
admin_url = 'http://admin.host:456/admin_path'
public_url = 'https://public.host:123/public_path'
node.set['openstack']['endpoints']['internal']['image-api']['uri'] = internal_url
node.set['openstack']['endpoints']['admin']['image-api']['uri'] = admin_url
node.set['openstack']['endpoints']['identity-admin']['uri'] = 'http://127.0.0.1:35357/v2.0'
node.set['openstack']['endpoints']['public']['image-api']['uri'] = public_url
resource = chef_run.find_resource(
'openstack-identity_register',
'Register Image Endpoint'
).to_hash
expect(resource).to include(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'image',
endpoint_region: 'RegionOne',
endpoint_adminurl: admin_url,
endpoint_internalurl: internal_url,
endpoint_publicurl: public_url,
action: [:create_endpoint]
)
end
end
it 'registers service tenant' do

View File

@ -93,7 +93,7 @@ describe 'openstack-image::registry' do
include_context 'sql-stubs'
before do
allow_any_instance_of(Chef::Recipe).to receive(:endpoint)
allow_any_instance_of(Chef::Recipe).to receive(:internal_endpoint)
.with('image-registry-bind')
.and_return(double(host: 'registry_host_value', port: 'registry_port_value'))
end

View File

@ -154,22 +154,22 @@ end
shared_context 'endpoint-stubs' do
before do
allow_any_instance_of(Chef::Recipe).to receive(:endpoint)
allow_any_instance_of(Chef::Recipe).to receive(:internal_endpoint)
.with('image-registry')
.and_return(double(host: 'registry_host_value', port: 'registry_port_value'))
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('identity_endpoint_value')
identity_admin_endpoint = double(host: 'identity_admin_endpoint_host_value',
port: 'identity_admin_endpoint_port_value',
scheme: 'identity_admin_endpoint_protocol_value')
allow_any_instance_of(Chef::Recipe).to receive(:endpoint)
allow_any_instance_of(Chef::Recipe).to receive(:admin_endpoint)
.with('identity-admin')
.and_return(identity_admin_endpoint)
allow_any_instance_of(Chef::Recipe).to receive(:endpoint)
allow_any_instance_of(Chef::Recipe).to receive(:internal_endpoint)
.with('image-api-bind')
.and_return(double(host: 'bind_host_value', port: 'bind_port_value'))
allow_any_instance_of(Chef::Recipe).to receive(:endpoint)
allow_any_instance_of(Chef::Recipe).to receive(:internal_endpoint)
.with('block-storage-api')
.and_return(double(scheme: 'scheme', host: 'host', port: 'port', path: '/path'))
allow_any_instance_of(Chef::Recipe).to receive(:auth_uri_transform)