From 6b971755f964c7fbcaf5c1f31f06be336bd0d4b2 Mon Sep 17 00:00:00 2001 From: Tim Rozet Date: Wed, 23 Dec 2015 14:22:20 -0500 Subject: [PATCH] Adds the ability to force metadata with dhcp agent Functionality added to neutron in https://review.openstack.org/#/c/211963 Change-Id: I0eadf1f22dbe84572c891c4bbf91e2e46a1c5742 Signed-off-by: Tim Rozet --- manifests/agents/dhcp.pp | 10 +++++++-- spec/classes/neutron_agents_dhcp_spec.rb | 27 +++++++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/manifests/agents/dhcp.pp b/manifests/agents/dhcp.pp index b359748e5..2cf91d255 100644 --- a/manifests/agents/dhcp.pp +++ b/manifests/agents/dhcp.pp @@ -53,6 +53,10 @@ # (optional) enable metadata support on isolated networks. # Defaults to false. # +# [*enable_force_metadata*] +# (optional) enable metadata support on all networks. +# Defaults to $::os_service_default +# # [*enable_metadata_network*] # (optional) Allows for serving metadata requests coming from a dedicated metadata # access network whose cidr is 169.254.169.254/16 (or larger prefix), and is @@ -86,6 +90,7 @@ class neutron::agents::dhcp ( $dnsmasq_config_file = $::os_service_default, $dhcp_delete_namespaces = true, $enable_isolated_metadata = false, + $enable_force_metadata = $::os_service_default, $enable_metadata_network = false, $dhcp_broadcast_reply = $::os_service_default, # DEPRECATED PARAMETERS @@ -110,11 +115,12 @@ class neutron::agents::dhcp ( } } - if (! $enable_isolated_metadata) and $enable_metadata_network { - fail('enable_metadata_network to true requires enable_isolated_metadata also enabled.') + if (! ($enable_isolated_metadata or $enable_force_metadata)) and $enable_metadata_network { + fail('enable_metadata_network to true requires enable_isolated_metadata or enable_force_metadata also enabled.') } else { neutron_dhcp_agent_config { 'DEFAULT/enable_isolated_metadata': value => $enable_isolated_metadata; + 'DEFAULT/force_metadata': value => $enable_force_metadata; 'DEFAULT/enable_metadata_network': value => $enable_metadata_network; } } diff --git a/spec/classes/neutron_agents_dhcp_spec.rb b/spec/classes/neutron_agents_dhcp_spec.rb index d16ca803f..ed4f61f32 100644 --- a/spec/classes/neutron_agents_dhcp_spec.rb +++ b/spec/classes/neutron_agents_dhcp_spec.rb @@ -48,6 +48,7 @@ describe 'neutron::agents::dhcp' do is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/root_helper').with_value(p[:root_helper]); is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/dhcp_delete_namespaces').with_value(p[:dhcp_delete_namespaces]); is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value(p[:enable_isolated_metadata]); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/force_metadata').with_value(''); is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value(p[:enable_metadata_network]); is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/dhcp_broadcast_reply').with_value(''); end @@ -107,12 +108,32 @@ describe 'neutron::agents::dhcp' do end end - context 'when enabling metadata networks without enabling isolated metadata' do + context 'when enabling metadata networks without enabling isolated metadata or force metadata' do before :each do - params.merge!(:enable_isolated_metadata => false, :enable_metadata_network => true) + params.merge!(:enable_isolated_metadata => false, :enable_force_metadata => false, :enable_metadata_network => true) end - it_raises 'a Puppet::Error', /enable_metadata_network to true requires enable_isolated_metadata also enabled./ + it_raises 'a Puppet::Error', /enable_metadata_network to true requires enable_isolated_metadata or enable_force_metadata also enabled./ + end + + context 'when enabling force metadata only' do + before :each do + params.merge!(:enable_force_metadata => true, :enable_metadata_network => false) + end + it 'should enable force_metadata only' do + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/force_metadata').with_value('true'); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('false'); + end + end + + context 'when enabling force metadata with metadata networks' do + before :each do + params.merge!(:enable_force_metadata => true, :enable_metadata_network => true) + end + it 'should enable both force_metadata and metadata_network' do + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/force_metadata').with_value('true'); + is_expected.to contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('true'); + end end context 'with use_namespaces as false' do