From 2918234a399054ee054eece9da00007bcca9ba9d Mon Sep 17 00:00:00 2001 From: Ken Thomas Date: Thu, 29 Jan 2015 22:46:52 +0000 Subject: [PATCH] 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-network recipes. Note that some calls to 'endpoint' that can't have separate admin, internal, public endpoints. (E.g. network-api-bind, network-linuxbridge, network-openvswitch, etc.) Those will continue to use the general endpoint routine. Partial-Bug: 1412919 Change-Id: Ia08983f6f8da8a96da22969cdb660b44f82780d6 --- CHANGELOG.md | 1 + recipes/default.rb | 6 +-- recipes/identity_registration.rb | 12 +++-- recipes/metadata_agent.rb | 2 +- spec/identity_registration_spec.rb | 84 ++++++++++++++++++++++++++++++ spec/spec_helper.rb | 8 +-- 6 files changed, 100 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 564ecd44..b50ecabb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This file is used to list changes made in each version of cookbook-openstack-net ## 10.1.1 * Removed all files not needed by the neutron cookbook * Add radvd to neutron_l3_packages to support ipv6 +* Use common specific_endpoint routines (bug 1412919) ## 10.1.0 * Add support for Neutron VPN Service diff --git a/recipes/default.rb b/recipes/default.rb index a2aaad37..362dbedb 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -116,8 +116,8 @@ elsif mq_service_type == 'qpid' mq_password = get_password 'user', node['openstack']['mq']['network']['qpid']['username'] 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' auth_uri = ::URI.decode identity_endpoint.to_s auth_uri = auth_uri_transform identity_endpoint.to_s, node['openstack']['network']['api']['auth']['version'] @@ -149,7 +149,7 @@ service 'neutron-server' do end # Nova interactions -nova_endpoint = endpoint 'compute-api' +nova_endpoint = internal_endpoint 'compute-api' # TODO(MRV): Need to allow for this in common. # Neutron will append the admin_tenant_id for these nova interaction calls, # remove the tenant_id so we don't end up with two of them on the url. diff --git a/recipes/identity_registration.rb b/recipes/identity_registration.rb index 382dae57..5664df5a 100644 --- a/recipes/identity_registration.rb +++ b/recipes/identity_registration.rb @@ -28,12 +28,14 @@ class ::Chef::Recipe 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 -api_endpoint = endpoint 'network-api' +admin_api_endpoint = admin_endpoint 'network-api' +public_api_endpoint = public_endpoint 'network-api' +internal_api_endpoint = internal_endpoint 'network-api' service_pass = get_password 'service', 'openstack-network' service_tenant_name = node['openstack']['network']['service_tenant_name'] @@ -55,9 +57,9 @@ openstack_identity_register 'Register Network Endpoint' do bootstrap_token bootstrap_token service_type node['openstack']['network']['service_type'] endpoint_region node['openstack']['network']['region'] - endpoint_adminurl api_endpoint.to_s - endpoint_internalurl api_endpoint.to_s - endpoint_publicurl api_endpoint.to_s + endpoint_adminurl admin_api_endpoint.to_s + endpoint_internalurl internal_api_endpoint.to_s + endpoint_publicurl public_api_endpoint.to_s action :create_endpoint end diff --git a/recipes/metadata_agent.rb b/recipes/metadata_agent.rb index f2f351f3..d129b393 100644 --- a/recipes/metadata_agent.rb +++ b/recipes/metadata_agent.rb @@ -24,7 +24,7 @@ include_recipe 'openstack-network' platform_options = node['openstack']['network']['platform'] -identity_endpoint = endpoint 'identity-api' +identity_endpoint = internal_endpoint 'identity-internal' service_pass = get_password 'service', 'openstack-network' metadata_secret = get_secret node['openstack']['network']['metadata']['secret_name'] diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb index 7f2ed531..cad8aef1 100644 --- a/spec/identity_registration_spec.rb +++ b/spec/identity_registration_spec.rb @@ -47,6 +47,90 @@ describe 'openstack-network::identity_registration' do ) end + it 'with different admin url values' 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']['network-api']['uri'] = general_url + # Set the admin endpoint override + node.set['openstack']['endpoints']['admin']['network-api']['uri'] = admin_url + expect(chef_run).to create_endpoint_openstack_identity_register( + 'Register Network Endpoint' + ).with( + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_type: 'network', + endpoint_region: 'RegionOne', + endpoint_adminurl: admin_url, + endpoint_internalurl: general_url, + endpoint_publicurl: general_url + ) + end + + it 'with different public url values' 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']['network-api']['uri'] = general_url + # Set the public endpoint override + node.set['openstack']['endpoints']['public']['network-api']['uri'] = public_url + expect(chef_run).to create_endpoint_openstack_identity_register( + 'Register Network Endpoint' + ).with( + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_type: 'network', + endpoint_region: 'RegionOne', + endpoint_adminurl: general_url, + endpoint_internalurl: general_url, + endpoint_publicurl: public_url + ) + end + + it 'with different internal url values' 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']['network-api']['uri'] = general_url + # Set the internal endpoint override + node.set['openstack']['endpoints']['internal']['network-api']['uri'] = internal_url + expect(chef_run).to create_endpoint_openstack_identity_register( + 'Register Network Endpoint' + ).with( + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_type: 'network', + endpoint_region: 'RegionOne', + endpoint_adminurl: general_url, + endpoint_internalurl: internal_url, + endpoint_publicurl: general_url + ) + end + + it 'with different internal,public, and admin url values' 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']['network-api']['uri'] = internal_url + node.set['openstack']['endpoints']['public']['network-api']['uri'] = public_url + node.set['openstack']['endpoints']['admin']['network-api']['uri'] = admin_url + + expect(chef_run).to create_endpoint_openstack_identity_register( + 'Register Network Endpoint' + ).with( + auth_uri: 'http://127.0.0.1:35357/v2.0', + bootstrap_token: 'bootstrap-token', + service_type: 'network', + 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']['network']['region'] = 'netRegion' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c9a2424d..8d7c4fed 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -121,21 +121,21 @@ shared_context 'endpoint-stubs' do allow_any_instance_of(Chef::Recipe).to receive(:endpoint) .with('network-api-bind') .and_return(double(host: 'network_host', port: 'network_port')) - allow_any_instance_of(Chef::Recipe).to receive(:endpoint) + allow_any_instance_of(Chef::Recipe).to receive(:internal_endpoint) .with('compute-api') .and_return(double( scheme: 'compute_scheme', host: 'compute_host', port: 'compute_port')) - allow_any_instance_of(Chef::Recipe).to receive(:endpoint) + allow_any_instance_of(Chef::Recipe).to receive(:admin_endpoint) .with('identity-admin') .and_return(double( host: 'identity_host', port: 'identity_port', scheme: 'identity_scheme', to_s: 'identity_uri')) - 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') end end