Add namespace cleanup options

Adds a configuration option to tell the network agents to delete
namespaces when they are no longer in use. The option defaults to
False so that the agent will not attempt to delete namespaces in
environments where this is not safe.

It affects only L3 & DHCP agents for now.

Change-Id: Ie9e27ae55b796ec12601dbfbeda45184188864f5
Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
Emilien Macchi
2013-12-24 17:26:37 +01:00
parent dcec6d6084
commit e1d44c2aee
4 changed files with 45 additions and 30 deletions

View File

@@ -42,17 +42,22 @@
# (optional) Override the default dnsmasq settings with this file.
# Defaults to undef
#
# [*dhcp_delete_namespaces*]
# (optional) Delete namespace after removing a dhcp server
# Defaults to false.
#
class neutron::agents::dhcp (
$package_ensure = present,
$enabled = true,
$debug = false,
$state_path = '/var/lib/neutron',
$resync_interval = 30,
$interface_driver = 'neutron.agent.linux.interface.OVSInterfaceDriver',
$dhcp_driver = 'neutron.agent.linux.dhcp.Dnsmasq',
$root_helper = 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf',
$use_namespaces = true,
$dnsmasq_config_file = undef
$package_ensure = present,
$enabled = true,
$debug = false,
$state_path = '/var/lib/neutron',
$resync_interval = 30,
$interface_driver = 'neutron.agent.linux.interface.OVSInterfaceDriver',
$dhcp_driver = 'neutron.agent.linux.dhcp.Dnsmasq',
$root_helper = 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf',
$use_namespaces = true,
$dnsmasq_config_file = undef,
$dhcp_delete_namespaces = false
) {
include neutron::params
@@ -74,13 +79,14 @@ class neutron::agents::dhcp (
# This only lists config specific to the agent. neutron.ini supplies
# the rest.
neutron_dhcp_agent_config {
'DEFAULT/debug': value => $debug;
'DEFAULT/state_path': value => $state_path;
'DEFAULT/resync_interval': value => $resync_interval;
'DEFAULT/interface_driver': value => $interface_driver;
'DEFAULT/dhcp_driver': value => $dhcp_driver;
'DEFAULT/use_namespaces': value => $use_namespaces;
'DEFAULT/root_helper': value => $root_helper;
'DEFAULT/debug': value => $debug;
'DEFAULT/state_path': value => $state_path;
'DEFAULT/resync_interval': value => $resync_interval;
'DEFAULT/interface_driver': value => $interface_driver;
'DEFAULT/dhcp_driver': value => $dhcp_driver;
'DEFAULT/use_namespaces': value => $use_namespaces;
'DEFAULT/root_helper': value => $root_helper;
'DEFAULT/dhcp_delete_namespaces': value => $dhcp_delete_namespaces;
}
if $dnsmasq_config_file {

View File

@@ -67,6 +67,10 @@
# (optional) The MTU size for the interfaces managed by the L3 agent
# Defaults to undef
#
# [*router_delete_namespaces*]
# (optional) namespaces can be deleted cleanly on the host running the L3 agent
# Defaults to False
#
class neutron::agents::l3 (
$package_ensure = 'present',
$enabled = true,
@@ -82,7 +86,8 @@ class neutron::agents::l3 (
$periodic_interval = '40',
$periodic_fuzzy_delay = '5',
$enable_metadata_proxy = true,
$network_device_mtu = undef
$network_device_mtu = undef,
$router_delete_namespaces = false
) {
include neutron::params
@@ -103,6 +108,7 @@ class neutron::agents::l3 (
'DEFAULT/periodic_interval': value => $periodic_interval;
'DEFAULT/periodic_fuzzy_delay': value => $periodic_fuzzy_delay;
'DEFAULT/enable_metadata_proxy': value => $enable_metadata_proxy;
'DEFAULT/router_delete_namespaces': value => $router_delete_namespaces;
}
if $network_device_mtu {

View File

@@ -11,16 +11,17 @@ describe 'neutron::agents::dhcp' do
end
let :default_params do
{ :package_ensure => 'present',
:enabled => true,
:debug => false,
:state_path => '/var/lib/neutron',
:resync_interval => 30,
:interface_driver => 'neutron.agent.linux.interface.OVSInterfaceDriver',
:dhcp_driver => 'neutron.agent.linux.dhcp.Dnsmasq',
:root_helper => 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf',
:use_namespaces => true,
:dnsmasq_config_file => nil }
{ :package_ensure => 'present',
:enabled => true,
:debug => false,
:state_path => '/var/lib/neutron',
:resync_interval => 30,
:interface_driver => 'neutron.agent.linux.interface.OVSInterfaceDriver',
:dhcp_driver => 'neutron.agent.linux.dhcp.Dnsmasq',
:root_helper => 'sudo neutron-rootwrap /etc/neutron/rootwrap.conf',
:use_namespaces => true,
:dnsmasq_config_file => nil,
:dhcp_delete_namespaces => false }
end
@@ -41,6 +42,7 @@ describe 'neutron::agents::dhcp' do
should contain_neutron_dhcp_agent_config('DEFAULT/dhcp_driver').with_value(p[:dhcp_driver]);
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]);
end
it 'installs neutron dhcp agent package' do

View File

@@ -21,7 +21,8 @@ describe 'neutron::agents::l3' do
:periodic_interval => '40',
:periodic_fuzzy_delay => '5',
:enable_metadata_proxy => true,
:network_device_mtu => nil }
:network_device_mtu => nil,
:router_delete_namespaces => false }
end
let :params do
@@ -48,8 +49,8 @@ describe 'neutron::agents::l3' do
should contain_neutron_l3_agent_config('DEFAULT/periodic_interval').with_value(p[:periodic_interval])
should contain_neutron_l3_agent_config('DEFAULT/periodic_fuzzy_delay').with_value(p[:periodic_fuzzy_delay])
should contain_neutron_l3_agent_config('DEFAULT/enable_metadata_proxy').with_value(p[:enable_metadata_proxy])
should contain_neutron_l3_agent_config('DEFAULT/network_device_mtu').with_ensure('absent')
should contain_neutron_l3_agent_config('DEFAULT/router_delete_namespaces').with_value(p[:router_delete_namespaces])
end
it 'installs neutron l3 agent package' do