Linuxbridge Agent with ML2: switch provider

Like we did in OVS agent when running ML2 plugin, we need to:
* use neutron_agent_linuxbridge provider to configure the right config file.

Closes-bug: #1426080
Change-Id: Icf7391563dbfcafb788d23b0367fba810a90fb48
This commit is contained in:
Emilien Macchi 2015-02-27 10:49:35 +01:00 committed by Gael Chamoulaud
parent 83dfcde975
commit 65fd4f3017
5 changed files with 119 additions and 37 deletions

View File

@ -0,0 +1,22 @@
Puppet::Type.type(:neutron_agent_linuxbridge).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
def section
resource[:name].split('/', 2).first
end
def setting
resource[:name].split('/', 2).last
end
def separator
'='
end
def file_path
'/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini'
end
end

View File

@ -0,0 +1,18 @@
Puppet::Type.newtype(:neutron_agent_linuxbridge) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from linuxbridge agent config.'
newvalues(/\S+\/\S+/)
end
newproperty(:value) do
desc 'The value of the setting to be defined.'
munge do |value|
value = value.to_s.strip
value.capitalize! if value =~ /^(true|false)$/i
value
end
end
end

View File

@ -73,8 +73,8 @@ class neutron::agents::ml2::linuxbridge (
include ::neutron::params
Package['neutron-plugin-linuxbridge-agent'] -> Neutron_plugin_linuxbridge<||>
Neutron_plugin_linuxbridge<||> ~> Service['neutron-plugin-linuxbridge-agent']
Package['neutron-plugin-linuxbridge-agent'] -> Neutron_agent_linuxbridge<||>
Neutron_agent_linuxbridge<||> ~> Service['neutron-plugin-linuxbridge-agent']
if ('vxlan' in $tunnel_types) {
@ -83,30 +83,30 @@ class neutron::agents::ml2::linuxbridge (
}
if $vxlan_group {
neutron_plugin_linuxbridge { 'vxlan/vxlan_group': value => $vxlan_group }
neutron_agent_linuxbridge { 'vxlan/vxlan_group': value => $vxlan_group }
} else {
neutron_plugin_linuxbridge { 'vxlan/vxlan_group': ensure => absent }
neutron_agent_linuxbridge { 'vxlan/vxlan_group': ensure => absent }
}
if $vxlan_ttl {
neutron_plugin_linuxbridge { 'vxlan/vxlan_ttl': value => $vxlan_ttl }
neutron_agent_linuxbridge { 'vxlan/vxlan_ttl': value => $vxlan_ttl }
} else {
neutron_plugin_linuxbridge { 'vxlan/vxlan_ttl': ensure => absent }
neutron_agent_linuxbridge { 'vxlan/vxlan_ttl': ensure => absent }
}
if $vxlan_tos {
neutron_plugin_linuxbridge { 'vxlan/vxlan_tos': value => $vxlan_tos }
neutron_agent_linuxbridge { 'vxlan/vxlan_tos': value => $vxlan_tos }
} else {
neutron_plugin_linuxbridge { 'vxlan/vxlan_tos': ensure => absent }
neutron_agent_linuxbridge { 'vxlan/vxlan_tos': ensure => absent }
}
neutron_plugin_linuxbridge {
neutron_agent_linuxbridge {
'vxlan/enable_vxlan': value => true;
'vxlan/local_ip': value => $local_ip;
'vxlan/l2_population': value => $l2_population;
}
} else {
neutron_plugin_linuxbridge {
neutron_agent_linuxbridge {
'vxlan/enable_vxlan': value => false;
'vxlan/local_ip': ensure => absent;
'vxlan/vxlan_group': ensure => absent;
@ -114,15 +114,15 @@ class neutron::agents::ml2::linuxbridge (
}
}
neutron_plugin_linuxbridge {
neutron_agent_linuxbridge {
'agent/polling_interval': value => $polling_interval;
'linux_bridge/physical_interface_mappings': value => join($physical_interface_mappings, ',');
}
if $firewall_driver {
neutron_plugin_linuxbridge { 'securitygroup/firewall_driver': value => $firewall_driver }
neutron_agent_linuxbridge { 'securitygroup/firewall_driver': value => $firewall_driver }
} else {
neutron_plugin_linuxbridge { 'securitygroup/firewall_driver': ensure => absent }
neutron_agent_linuxbridge { 'securitygroup/firewall_driver': ensure => absent }
}
if $::neutron::params::linuxbridge_agent_package {

View File

@ -30,9 +30,9 @@ describe 'neutron::agents::ml2::linuxbridge' do
it { is_expected.to contain_class('neutron::params') }
it 'configures ml2_conf.ini' do
is_expected.to contain_neutron_plugin_linuxbridge('agent/polling_interval').with_value(default_params[:polling_interval])
is_expected.to contain_neutron_plugin_linuxbridge('linux_bridge/physical_interface_mappings').with_value(default_params[:physical_interface_mappings].join(','))
is_expected.to contain_neutron_plugin_linuxbridge('securitygroup/firewall_driver').with_value(default_params[:firewall_driver])
is_expected.to contain_neutron_agent_linuxbridge('agent/polling_interval').with_value(default_params[:polling_interval])
is_expected.to contain_neutron_agent_linuxbridge('linux_bridge/physical_interface_mappings').with_value(default_params[:physical_interface_mappings].join(','))
is_expected.to contain_neutron_agent_linuxbridge('securitygroup/firewall_driver').with_value(default_params[:firewall_driver])
end
it 'installs neutron linuxbridge agent package' do
@ -48,7 +48,7 @@ describe 'neutron::agents::ml2::linuxbridge' do
:tag => 'openstack'
)
is_expected.to contain_package('neutron-plugin-linuxbridge-agent').with_before(/Neutron_plugin_linuxbridge\[.+\]/)
is_expected.to contain_package('neutron-plugin-linuxbridge-agent').with_before(/Neutron_agent_linuxbridge\[.+\]/)
end
it 'configures neutron linuxbridge agent service' do
@ -61,10 +61,10 @@ describe 'neutron::agents::ml2::linuxbridge' do
end
it 'does not configre VXLAN tunneling' do
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(false)
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_ensure('absent')
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_ensure('absent')
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_ensure('absent')
is_expected.to contain_neutron_agent_linuxbridge('vxlan/enable_vxlan').with_value(false)
is_expected.to contain_neutron_agent_linuxbridge('vxlan/local_ip').with_ensure('absent')
is_expected.to contain_neutron_agent_linuxbridge('vxlan/vxlan_group').with_ensure('absent')
is_expected.to contain_neutron_agent_linuxbridge('vxlan/l2_population').with_ensure('absent')
end
end
@ -78,12 +78,12 @@ describe 'neutron::agents::ml2::linuxbridge' do
context 'when providing all parameters' do
it 'configures ml2_conf.ini' do
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(true)
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_value(params[:local_ip])
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_value(default_params[:vxlan_group])
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_ttl').with_ensure('absent')
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_tos').with_ensure('absent')
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_value(default_params[:l2_population])
is_expected.to contain_neutron_agent_linuxbridge('vxlan/enable_vxlan').with_value(true)
is_expected.to contain_neutron_agent_linuxbridge('vxlan/local_ip').with_value(params[:local_ip])
is_expected.to contain_neutron_agent_linuxbridge('vxlan/vxlan_group').with_value(default_params[:vxlan_group])
is_expected.to contain_neutron_agent_linuxbridge('vxlan/vxlan_ttl').with_ensure('absent')
is_expected.to contain_neutron_agent_linuxbridge('vxlan/vxlan_tos').with_ensure('absent')
is_expected.to contain_neutron_agent_linuxbridge('vxlan/l2_population').with_value(default_params[:l2_population])
end
end
@ -98,12 +98,12 @@ describe 'neutron::agents::ml2::linuxbridge' do
end
it 'configures ml2_conf.ini' do
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/enable_vxlan').with_value(true)
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/local_ip').with_value(params[:local_ip])
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_group').with_value(params[:vxlan_group])
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_ttl').with_value(params[:vxlan_ttl])
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/vxlan_tos').with_value(params[:vxlan_tos])
is_expected.to contain_neutron_plugin_linuxbridge('vxlan/l2_population').with_value(params[:l2_population])
is_expected.to contain_neutron_agent_linuxbridge('vxlan/enable_vxlan').with_value(true)
is_expected.to contain_neutron_agent_linuxbridge('vxlan/local_ip').with_value(params[:local_ip])
is_expected.to contain_neutron_agent_linuxbridge('vxlan/vxlan_group').with_value(params[:vxlan_group])
is_expected.to contain_neutron_agent_linuxbridge('vxlan/vxlan_ttl').with_value(params[:vxlan_ttl])
is_expected.to contain_neutron_agent_linuxbridge('vxlan/vxlan_tos').with_value(params[:vxlan_tos])
is_expected.to contain_neutron_agent_linuxbridge('vxlan/l2_population').with_value(params[:l2_population])
end
end
end
@ -114,7 +114,7 @@ describe 'neutron::agents::ml2::linuxbridge' do
end
it 'configures physical interface mappings' do
is_expected.to contain_neutron_plugin_linuxbridge('linux_bridge/physical_interface_mappings').with_value(
is_expected.to contain_neutron_agent_linuxbridge('linux_bridge/physical_interface_mappings').with_value(
params[:physical_interface_mappings].join(',')
)
end
@ -125,7 +125,7 @@ describe 'neutron::agents::ml2::linuxbridge' do
params.merge!(:firewall_driver => false)
end
it 'removes firewall driver configuration' do
is_expected.to contain_neutron_plugin_linuxbridge('securitygroup/firewall_driver').with_ensure('absent')
is_expected.to contain_neutron_agent_linuxbridge('securitygroup/firewall_driver').with_ensure('absent')
end
end
end
@ -152,7 +152,5 @@ describe 'neutron::agents::ml2::linuxbridge' do
{ :linuxbridge_server_package => 'openstack-neutron-linuxbridge',
:linuxbridge_agent_service => 'neutron-linuxbridge-agent' }
end
it_configures 'neutron plugin linuxbridge agent with ml2 plugin'
end
end

View File

@ -0,0 +1,44 @@
$LOAD_PATH.push(
File.join(
File.dirname(__FILE__),
'..',
'..',
'..',
'fixtures',
'modules',
'inifile',
'lib')
)
require 'spec_helper'
provider_class = Puppet::Type.type(:neutron_agent_linuxbridge).provider(:ini_setting)
describe provider_class do
it 'should default to the default setting when no other one is specified' do
resource = Puppet::Type::Neutron_agent_linuxbridge.new(
{
:name => 'DEFAULT/foo',
:value => 'bar'
}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('DEFAULT')
expect(provider.setting).to eq('foo')
expect(provider.file_path).to eq('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini')
end
it 'should allow setting to be set explicitly' do
resource = Puppet::Type::Neutron_agent_linuxbridge.new(
{
:name => 'dude/foo',
:value => 'bar'
}
)
provider = provider_class.new(resource)
expect(provider.section).to eq('dude')
expect(provider.setting).to eq('foo')
expect(provider.file_path).to eq('/etc/neutron/plugins/linuxbridge/linuxbridge_conf.ini')
end
end