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-compute recipes.

Change-Id: I4c90f4c7222f2f0b7fb7eba91f68e47841970e7c
Partial-Bug: 1412919
This commit is contained in:
Ken Thomas 2015-02-02 21:52:42 +00:00
parent 557afe0989
commit 030642ec4e
4 changed files with 195 additions and 14 deletions

View File

@ -26,6 +26,7 @@ This file is used to list changes made in each version of cookbook-openstack-com
* Make libvirtd service started prior to nova compute service
* Add [upgrade_levels] in nova.conf to enable rpc API compatible with order version
* Add dependency on upstream ceph cookbook for better key management
* Use common specific_endpoint routines (bug 1412919)
## 9.3.1
* Move auth configuration from api-paste.ini to nova.conf

View File

@ -25,16 +25,22 @@ 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
service_pass = get_password 'service', 'openstack-compute'
service_user = node['openstack']['compute']['service_user']
service_role = node['openstack']['compute']['service_role']
service_tenant_name = node['openstack']['compute']['service_tenant_name']
nova_api_endpoint = endpoint 'compute-api'
ec2_admin_endpoint = endpoint 'compute-ec2-admin'
ec2_public_endpoint = endpoint 'compute-ec2-api'
public_nova_api_endpoint = public_endpoint 'compute-api'
admin_nova_api_endpoint = admin_endpoint 'compute-api'
internal_nova_api_endpoint = internal_endpoint 'compute-api'
# TBD, another clean up opportunity. We could use the 'admin', and
# 'internal' endpoints for a single service name. For now, we'll
# leave the old names in place.
ec2_admin_endpoint = admin_endpoint 'compute-ec2-admin'
ec2_public_endpoint = public_endpoint 'compute-ec2-api'
ec2_internal_endpoint = internal_endpoint 'compute-ec2-api'
region = node['openstack']['compute']['region']
# Register Service Tenant
@ -86,9 +92,9 @@ openstack_identity_register 'Register Compute Endpoint' do
bootstrap_token bootstrap_token
service_type 'compute'
endpoint_region region
endpoint_adminurl ::URI.decode nova_api_endpoint.to_s
endpoint_internalurl ::URI.decode nova_api_endpoint.to_s
endpoint_publicurl ::URI.decode nova_api_endpoint.to_s
endpoint_adminurl ::URI.decode admin_nova_api_endpoint.to_s
endpoint_internalurl ::URI.decode internal_nova_api_endpoint.to_s
endpoint_publicurl ::URI.decode public_nova_api_endpoint.to_s
action :create_endpoint
end
@ -112,7 +118,7 @@ if node['openstack']['compute']['enabled_apis'].include?('ec2')
service_type 'ec2'
endpoint_region region
endpoint_adminurl ::URI.decode ec2_admin_endpoint.to_s
endpoint_internalurl ::URI.decode ec2_public_endpoint.to_s
endpoint_internalurl ::URI.decode ec2_internal_endpoint.to_s
endpoint_publicurl ::URI.decode ec2_public_endpoint.to_s
action :create_endpoint

View File

@ -90,7 +90,10 @@ end
memcache_servers = memcached_servers.join ','
# find the node attribute endpoint settings for the server holding a given role
identity_endpoint = endpoint 'identity-api'
# Note that the bind and vnc endpoints don't have possible different values for
# internal/admin/public. We'll stick with the general endpoint routine
# for those.
identity_endpoint = internal_endpoint 'identity-internal'
xvpvnc_endpoint = endpoint 'compute-xvpvnc' || {}
xvpvnc_bind = endpoint 'compute-xvpvnc-bind' || {}
novnc_endpoint = endpoint 'compute-novnc' || {}
@ -98,11 +101,11 @@ novnc_bind = endpoint 'compute-novnc-bind' || {}
vnc_bind = endpoint 'compute-vnc-bind' || {}
vnc_proxy_bind = endpoint 'compute-vnc-proxy-bind' || {}
compute_api_bind = endpoint 'compute-api-bind' || {}
compute_api_endpoint = endpoint 'compute-api' || {}
compute_api_endpoint = internal_endpoint 'compute-api' || {}
ec2_api_bind = endpoint 'compute-ec2-api-bind' || {}
ec2_public_endpoint = endpoint 'compute-ec2-api' || {}
network_endpoint = endpoint 'network-api' || {}
image_endpoint = endpoint 'image-api'
ec2_public_endpoint = public_endpoint 'compute-ec2-api' || {}
network_endpoint = internal_endpoint 'network-api' || {}
image_endpoint = internal_endpoint 'image-api'
Chef::Log.debug("openstack-compute::nova-common:identity_endpoint|#{identity_endpoint.to_s}")
Chef::Log.debug("openstack-compute::nova-common:xvpvnc_endpoint|#{xvpvnc_endpoint.to_s}")
@ -121,7 +124,7 @@ if node['openstack']['compute']['driver'].split('.').first == 'vmwareapi'
vmware_host_pass = get_secret node['openstack']['compute']['vmware']['secret_name']
end
identity_admin_endpoint = endpoint 'identity-admin'
identity_admin_endpoint = admin_endpoint 'identity-admin'
auth_uri = auth_uri_transform identity_endpoint.to_s, node['openstack']['compute']['api']['auth']['version']
service_pass = get_password 'service', 'openstack-compute'

View File

@ -72,6 +72,90 @@ describe 'openstack-compute::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']['compute-api']['uri'] = general_url
# Set the admin endpoint override
node.set['openstack']['endpoints']['admin']['compute-api']['uri'] = admin_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Compute Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'compute',
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']['compute-api']['uri'] = general_url
# Set the public endpoint override
node.set['openstack']['endpoints']['public']['compute-api']['uri'] = public_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Compute Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'compute',
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']['compute-api']['uri'] = general_url
# Set the internal endpoint override
node.set['openstack']['endpoints']['internal']['compute-api']['uri'] = internal_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Compute Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'compute',
endpoint_region: 'RegionOne',
endpoint_adminurl: general_url,
endpoint_internalurl: internal_url,
endpoint_publicurl: general_url
)
end
it 'with different URLs for all endpoints' do
admin_url = 'https://admin.host:123/admin_path'
public_url = 'https://public.host:789/public_path'
internal_url = 'http://internal.host:456/internal_path'
node.set['openstack']['endpoints']['admin']['compute-api']['uri'] = admin_url
node.set['openstack']['endpoints']['internal']['compute-api']['uri'] = internal_url
node.set['openstack']['endpoints']['public']['compute-api']['uri'] = public_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register Compute Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'compute',
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']['compute']['region'] = 'computeRegion'
expect(chef_run).to create_endpoint_openstack_identity_register(
@ -107,6 +191,93 @@ describe 'openstack-compute::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']['compute-ec2-api']['uri'] = general_url
node.set['openstack']['endpoints']['compute-ec2-admin']['uri'] = general_url
# Set the admin endpoint override
node.set['openstack']['endpoints']['admin']['compute-ec2-admin']['uri'] = admin_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register EC2 Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'ec2',
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']['compute-ec2-api']['uri'] = general_url
node.set['openstack']['endpoints']['compute-ec2-admin']['uri'] = general_url
# Set the public endpoint override
node.set['openstack']['endpoints']['public']['compute-ec2-api']['uri'] = public_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register EC2 Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'ec2',
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']['compute-ec2-api']['uri'] = general_url
node.set['openstack']['endpoints']['compute-ec2-admin']['uri'] = general_url
# Set the internal endpoint override
node.set['openstack']['endpoints']['internal']['compute-ec2-api']['uri'] = internal_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register EC2 Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'ec2',
endpoint_region: 'RegionOne',
endpoint_adminurl: general_url,
endpoint_internalurl: internal_url,
endpoint_publicurl: general_url
)
end
it 'with different URLs for all endpoints' do
admin_url = 'https://admin.host:123/admin_path'
public_url = 'https://public.host:789/public_path'
internal_url = 'http://internal.host:456/internal_path'
node.set['openstack']['endpoints']['admin']['compute-ec2-admin']['uri'] = admin_url
node.set['openstack']['endpoints']['internal']['compute-ec2-api']['uri'] = internal_url
node.set['openstack']['endpoints']['public']['compute-ec2-api']['uri'] = public_url
expect(chef_run).to create_endpoint_openstack_identity_register(
'Register EC2 Endpoint'
).with(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'ec2',
endpoint_region: 'RegionOne',
endpoint_adminurl: admin_url,
endpoint_internalurl: internal_url,
endpoint_publicurl: public_url
)
end
it 'with customer region override' do
node.set['openstack']['compute']['region'] = 'ec2Region'
expect(chef_run).to create_endpoint_openstack_identity_register(