Skip to content

Commit

Permalink
Isolated network support
Browse files Browse the repository at this point in the history
This patch aims to enable support for both:
- isolated metadata which enable metadata support on isolated networks.
- metadata networks which allows for serving metadata requests coming
  from a dedicated metadata access network

Change-Id: I0e892c4183bd2bf1910b9b6758c1759475053529
Signed-off-by: Emilien Macchi <[email protected]>
  • Loading branch information
Emilien Macchi committed Jan 14, 2014
1 parent 5abee51 commit 8654569
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
24 changes: 23 additions & 1 deletion manifests/agents/dhcp.pp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@
# (optional) Delete namespace after removing a dhcp server
# Defaults to false.
#
# [*enable_isolated_metadata*]
# (optional) enable metadata support on isolated networks.
# Defaults to false.
#
# [*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
# connected to a Neutron router from which the VMs send metadata request.
# This option requires enable_isolated_metadata = True
# Defaults to false.
#
class neutron::agents::dhcp (
$package_ensure = present,
$enabled = true,
Expand All @@ -57,7 +68,9 @@
$root_helper = 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf',
$use_namespaces = true,
$dnsmasq_config_file = undef,
$dhcp_delete_namespaces = false
$dhcp_delete_namespaces = false,
$enable_isolated_metadata = false,
$enable_metadata_network = false
) {

include neutron::params
Expand All @@ -75,6 +88,15 @@
}
}

if (! $enable_isolated_metadata) and $enable_metadata_network {
fail('enable_metadata_network to true requires enable_isolated_metadata also enabled.')
} else {
neutron_dhcp_agent_config {
'DEFAULT/enable_isolated_metadata': value => $enable_isolated_metadata;
'DEFAULT/enable_metadata_network': value => $enable_metadata_network;
}
}

# The DHCP agent loads both neutron.ini and its own file.
# This only lists config specific to the agent. neutron.ini supplies
# the rest.
Expand Down
35 changes: 34 additions & 1 deletion spec/classes/neutron_agents_dhcp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
:root_helper => 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf',
:use_namespaces => true,
:dnsmasq_config_file => nil,
:dhcp_delete_namespaces => false }
:dhcp_delete_namespaces => false,
:enable_isolated_metadata => false,
:enable_metadata_network => false }
end


Expand All @@ -43,6 +45,8 @@
should contain_neutron_dhcp_agent_config('DEFAULT/root_helper').with_value(p[:root_helper]);
should contain_neutron_dhcp_agent_config('DEFAULT/use_namespaces').with_value(p[:use_namespaces]);
should contain_neutron_dhcp_agent_config('DEFAULT/dhcp_delete_namespaces').with_value(p[:dhcp_delete_namespaces]);
should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value(p[:enable_isolated_metadata]);
should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value(p[:enable_metadata_network]);
end

it 'installs neutron dhcp agent package' do
Expand All @@ -67,6 +71,35 @@
:require => 'Class[Neutron]'
)
end

context 'when enabling isolated metadata only' do
before :each do
params.merge!(:enable_isolated_metadata => true, :enable_metadata_network => false)
end
it 'should enable isolated_metadata only' do
should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true');
should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('false');
end
end

context 'when enabling isolated metadata with metadata networks' do
before :each do
params.merge!(:enable_isolated_metadata => true, :enable_metadata_network => true)
end
it 'should enable both isolated_metadata and metadata_network' do
should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value('true');
should contain_neutron_dhcp_agent_config('DEFAULT/enable_metadata_network').with_value('true');
end
end

context 'when enabling metadata networks without enabling isolated metadata' do
before :each do
params.merge!(:enable_isolated_metadata => false, :enable_metadata_network => true)
end
it 'should fails to configure metadata_network without isolated_metadata' do
expect { subject }.to raise_error(Puppet::Error, /enable_metadata_network to true requires enable_isolated_metadata also enabled./)
end
end
end

shared_examples_for 'neutron dhcp agent with dnsmasq_config_file specified' do
Expand Down

0 comments on commit 8654569

Please sign in to comment.