Add compute metadata api to common endpoints

Nova metadata api endpoint was missing from common endpoints.
This patch will be follow by one for compute and network to
make use of these new endpoint.

Change-Id: Ie3e9f27f7d6eec4f4ebb0b1dbebd0b12a03a0b65
Partial-Bug: #1425633
This commit is contained in:
Mark Vanderwiel 2015-02-25 15:22:10 -06:00
parent f17990d717
commit 6ec0caf181
7 changed files with 18 additions and 23 deletions

View File

@ -7,6 +7,7 @@ This file is used to list changes made in each version of cookbook-openstack-net
* Use common specific_endpoint routines (bug 1412919) * Use common specific_endpoint routines (bug 1412919)
* Parameterize dhcp_agents_per_network * Parameterize dhcp_agents_per_network
* Parameterize neutron l3 agent HA parameters * Parameterize neutron l3 agent HA parameters
* Make use of new metadata endpoint in common
## 10.1.0 ## 10.1.0
* Add support for Neutron VPN Service * Add support for Neutron VPN Service

View File

@ -396,10 +396,6 @@ default['openstack']['network']['vpn']['ipsec_status_check_interval'] = 60
# ============================= Metadata Agent Configuration =============== # ============================= Metadata Agent Configuration ===============
# The location of the Nova Metadata API service to proxy to (nil uses default)
default['openstack']['network']['metadata']['nova_metadata_ip'] = '127.0.0.1'
default['openstack']['network']['metadata']['nova_metadata_port'] = 8775
# The name of the secret databag containing the metadata secret # The name of the secret databag containing the metadata secret
default['openstack']['network']['metadata']['secret_name'] = 'neutron_metadata_secret' default['openstack']['network']['metadata']['secret_name'] = 'neutron_metadata_secret'

View File

@ -17,5 +17,5 @@ recipe 'openstack-network::vpn_agent', 'Installs packages required fo
supports os supports os
end end
depends 'openstack-common', '>= 10.2.0' depends 'openstack-common', '>= 10.4.0'
depends 'openstack-identity', '>= 10.0.0' depends 'openstack-identity', '>= 10.0.0'

View File

@ -27,6 +27,7 @@ platform_options = node['openstack']['network']['platform']
identity_endpoint = internal_endpoint 'identity-internal' identity_endpoint = internal_endpoint 'identity-internal'
service_pass = get_password 'service', 'openstack-network' service_pass = get_password 'service', 'openstack-network'
metadata_secret = get_secret node['openstack']['network']['metadata']['secret_name'] metadata_secret = get_secret node['openstack']['network']['metadata']['secret_name']
compute_metadata_api = internal_endpoint 'compute-metadata-api'
platform_options['neutron_metadata_agent_packages'].each do |pkg| platform_options['neutron_metadata_agent_packages'].each do |pkg|
package pkg do package pkg do
@ -43,7 +44,9 @@ template '/etc/neutron/metadata_agent.ini' do
variables( variables(
identity_endpoint: identity_endpoint, identity_endpoint: identity_endpoint,
metadata_secret: metadata_secret, metadata_secret: metadata_secret,
service_pass: service_pass service_pass: service_pass,
compute_metadata_ip: compute_metadata_api.host,
compute_metadata_port: compute_metadata_api.port
) )
notifies :restart, 'service[neutron-metadata-agent]', :immediately notifies :restart, 'service[neutron-metadata-agent]', :immediately
action :create action :create

View File

@ -72,15 +72,10 @@ describe 'openstack-network::metadata_agent' do
expect(chef_run).to render_file(file.name).with_content(/^admin_password = admin_password_value$/) expect(chef_run).to render_file(file.name).with_content(/^admin_password = admin_password_value$/)
end end
%w[nova_metadata_ip nova_metadata_port].each do |conditional_attr| it 'has default metadata ip and port options set' do
it "displays the #{conditional_attr} attribute when present" do [/^nova_metadata_ip = 127.0.0.1$/,
node.set['openstack']['network']['metadata'][conditional_attr] = "network_metadata_#{conditional_attr}_value" /^nova_metadata_port = 8775$/].each do |line|
expect(chef_run).to render_file(file.name).with_content(/^#{conditional_attr} = network_metadata_#{conditional_attr}_value$/) expect(chef_run).to render_file(file.name).with_content(line)
end
it "does not display the #{conditional_attr} attribute if not set" do
node.set['openstack']['network']['metadata'][conditional_attr] = false
expect(chef_run).not_to render_file(file.name).with_content(/^#{conditional_attr} = /)
end end
end end

View File

@ -127,6 +127,12 @@ shared_context 'endpoint-stubs' do
scheme: 'compute_scheme', scheme: 'compute_scheme',
host: 'compute_host', host: 'compute_host',
port: 'compute_port')) port: 'compute_port'))
allow_any_instance_of(Chef::Recipe).to receive(:internal_endpoint)
.with('compute-metadata-api')
.and_return(double(
scheme: 'compute_metadata_scheme',
host: 'compute_metadata_host',
port: 'compute_metadata_port'))
allow_any_instance_of(Chef::Recipe).to receive(:admin_endpoint) allow_any_instance_of(Chef::Recipe).to receive(:admin_endpoint)
.with('identity-admin') .with('identity-admin')
.and_return(double( .and_return(double(

View File

@ -12,16 +12,10 @@ admin_user = <%= node["openstack"]["network"]["service_user"] %>
admin_password = <%= @service_pass %> admin_password = <%= @service_pass %>
# IP address used by Nova metadata server # IP address used by Nova metadata server
# Default: nova_metadata_ip = 127.0.0.1 nova_metadata_ip = <%= @compute_metadata_ip %>
<% if node["openstack"]["network"]["metadata"]["nova_metadata_ip"] -%>
nova_metadata_ip = <%= node["openstack"]["network"]["metadata"]["nova_metadata_ip"] %>
<% end -%>
# TCP Port used by Nova metadata server # TCP Port used by Nova metadata server
# Default: nova_metadata_port = 8775 nova_metadata_port = <%= @compute_metadata_port %>
<% if node["openstack"]["network"]["metadata"]["nova_metadata_port"] -%>
nova_metadata_port = <%= node["openstack"]["network"]["metadata"]["nova_metadata_port"] %>
<% end -%>
# Which protocol to use for requests to Nova metadata server, http or https # Which protocol to use for requests to Nova metadata server, http or https
# nova_metadata_protocol = http # nova_metadata_protocol = http