From 171e18ef3225e8af5781ff455fd0e5d622d05e40 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mathieu=20Gagne=CC=81?= <mgagne@iweb.com>
Date: Wed, 9 Jul 2014 20:44:07 -0400
Subject: [PATCH] Configure OVS mechanism agent configs in its config file
Configurations for the OVS agent should go in its config file:
/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini
but as packaging is broken and different in Ubuntu and Redhat
we have to use new neutron_agent_ovs provider to configure
ovs agent correctly.
Therefore, we should not remove the agent config file and
replace it with a symlink to plugin.ini or ml2_conf.ini.
Those config files are meant to be used by the core plugin itself
in neutron-server, not the agents themselves.
- Remove symlink creation from ovs_neutron_plugin.ini to plugin.ini
- Use neutron_agent_ovs to configure OVS mechanism agent configs
Change-Id: I53d9b923784587e8a2a934f004a3b054c716daaa
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
Conflicts:
neutron/manifests/agents/ml2/ovs.pp
---
.../provider/neutron_agent_ovs/ini_setting.rb | 26 ++++++++++
neutron/lib/puppet/type/neutron_agent_ovs.rb | 18 +++++++
neutron/manifests/agents/ml2/ovs.pp | 43 ++++++----------
.../spec/classes/neutron_agents_ml2_ovs_spec.rb | 59 ++++++++++------------
4 files changed, 87 insertions(+), 59 deletions(-)
create mode 100644 neutron/lib/puppet/provider/neutron_agent_ovs/ini_setting.rb
create mode 100644 neutron/lib/puppet/type/neutron_agent_ovs.rb
diff --git a/neutron/lib/puppet/provider/neutron_agent_ovs/ini_setting.rb b/neutron/lib/puppet/provider/neutron_agent_ovs/ini_setting.rb
new file mode 100644
index 0000000..47ae0d6
--- /dev/null
+++ b/neutron/lib/puppet/provider/neutron_agent_ovs/ini_setting.rb
@@ -0,0 +1,26 @@
+Puppet::Type.type(:neutron_agent_ovs).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
+ if Facter['osfamily'].value == 'Debian'
+ '/etc/neutron/plugins/ml2/ml2_conf.ini'
+ else
+ '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini'
+ end
+ end
+
+end
diff --git a/neutron/lib/puppet/type/neutron_agent_ovs.rb b/neutron/lib/puppet/type/neutron_agent_ovs.rb
new file mode 100644
index 0000000..a2c74f1
--- /dev/null
+++ b/neutron/lib/puppet/type/neutron_agent_ovs.rb
@@ -0,0 +1,18 @@
+Puppet::Type.newtype(:neutron_agent_ovs) do
+
+ ensurable
+
+ newparam(:name, :namevar => true) do
+ desc 'Section/setting name to manage from ovs 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
diff --git a/neutron/manifests/agents/ml2/ovs.pp b/neutron/manifests/agents/ml2/ovs.pp
index 4dae4f6..a2fb198 100644
--- a/neutron/manifests/agents/ml2/ovs.pp
+++ b/neutron/manifests/agents/ml2/ovs.pp
@@ -117,7 +117,8 @@ class neutron::agents::ml2::ovs (
fail('L2 population must be enabled when DVR is enabled')
}
- Neutron_plugin_ml2<||> ~> Service['neutron-ovs-agent-service']
+ Package['neutron-ovs-agent'] -> Neutron_agent_ovs<||>
+ Neutron_agent_ovs<||> ~> Service['neutron-ovs-agent-service']
if ($bridge_mappings != []) {
# bridge_mappings are used to describe external networks that are
@@ -135,7 +136,7 @@ class neutron::agents::ml2::ovs (
# Set config for bridges that we're going to create
# The OVS neutron plugin will talk in terms of the networks in the bridge_mappings
$br_map_str = join($bridge_mappings, ',')
- neutron_plugin_ml2 {
+ neutron_agent_ovs {
'ovs/bridge_mappings': value => $br_map_str;
}
neutron::plugins::ovs::bridge{ $bridge_mappings:
@@ -146,7 +147,7 @@ class neutron::agents::ml2::ovs (
}
}
- neutron_plugin_ml2 {
+ neutron_agent_ovs {
'agent/polling_interval': value => $polling_interval;
'agent/l2_population': value => $l2_population;
'agent/arp_responder': value => $arp_responder;
@@ -154,12 +155,10 @@ class neutron::agents::ml2::ovs (
'ovs/integration_bridge': value => $integration_bridge;
}
- if ($firewall_driver) {
- neutron_plugin_ml2 { 'securitygroup/firewall_driver':
- value => $firewall_driver
- }
+ if $firewall_driver {
+ neutron_agent_ovs { 'securitygroup/firewall_driver': value => $firewall_driver }
} else {
- neutron_plugin_ml2 { 'securitygroup/firewall_driver': ensure => absent }
+ neutron_agent_ovs { 'securitygroup/firewall_driver': ensure => absent }
}
vs_bridge { $integration_bridge:
@@ -172,25 +171,25 @@ class neutron::agents::ml2::ovs (
ensure => present,
before => Service['neutron-ovs-agent-service'],
}
- neutron_plugin_ml2 {
+ neutron_agent_ovs {
'ovs/enable_tunneling': value => true;
'ovs/tunnel_bridge': value => $tunnel_bridge;
'ovs/local_ip': value => $local_ip;
}
if size($tunnel_types) > 0 {
- neutron_plugin_ml2 {
+ neutron_agent_ovs {
'agent/tunnel_types': value => join($tunnel_types, ',');
}
}
if 'vxlan' in $tunnel_types {
validate_vxlan_udp_port($vxlan_udp_port)
- neutron_plugin_ml2 {
+ neutron_agent_ovs {
'agent/vxlan_udp_port': value => $vxlan_udp_port;
}
}
} else {
- neutron_plugin_ml2 {
+ neutron_agent_ovs {
'ovs/enable_tunneling': value => false;
'ovs/tunnel_bridge': ensure => absent;
'ovs/local_ip': ensure => absent;
@@ -199,7 +198,6 @@ class neutron::agents::ml2::ovs (
if $::neutron::params::ovs_agent_package {
- Package['neutron-ovs-agent'] -> Neutron_plugin_ml2<||>
package { 'neutron-ovs-agent':
ensure => $package_ensure,
name => $::neutron::params::ovs_agent_package,
@@ -208,21 +206,11 @@ class neutron::agents::ml2::ovs (
# Some platforms (RedHat) do not provide a separate
# neutron plugin ovs agent package. The configuration file for
# the ovs agent is provided by the neutron ovs plugin package.
- Package['neutron-ovs-agent'] -> Neutron_plugin_ml2<||>
- Package['neutron-ovs-agent'] -> Service['ovs-cleanup-service']
-
if ! defined(Package['neutron-ovs-agent']) {
package { 'neutron-ovs-agent':
- ensure => $package_ensure,
- name => $::neutron::params::ovs_server_package,
- } ->
- # https://bugzilla.redhat.com/show_bug.cgi?id=1087647
- # Causes init script for agent to load the old ovs file
- # instead of the ml2 config file.
- file { '/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini':
- ensure => link,
- target => '/etc/neutron/plugins/ml2/ml2_conf.ini'
- } ~> Service<| title == 'neutron-ovs-agent-service' |>
+ ensure => $package_ensure,
+ name => $::neutron::params::ovs_server_package,
+ }
}
}
@@ -240,7 +228,8 @@ class neutron::agents::ml2::ovs (
}
if $::neutron::params::ovs_cleanup_service {
- service {'ovs-cleanup-service':
+ Package['neutron-ovs-agent'] -> Service['ovs-cleanup-service']
+ service { 'ovs-cleanup-service':
ensure => $service_ensure,
name => $::neutron::params::ovs_cleanup_service,
enable => $enabled,
diff --git a/neutron/spec/classes/neutron_agents_ml2_ovs_spec.rb b/neutron/spec/classes/neutron_agents_ml2_ovs_spec.rb
index 45aec8e..b7a1204 100644
--- a/neutron/spec/classes/neutron_agents_ml2_ovs_spec.rb
+++ b/neutron/spec/classes/neutron_agents_ml2_ovs_spec.rb
@@ -34,15 +34,15 @@ describe 'neutron::agents::ml2::ovs' do
it { should contain_class('neutron::params') }
it 'configures ovs_neutron_plugin.ini' do
- should contain_neutron_plugin_ml2('agent/polling_interval').with_value(p[:polling_interval])
- should contain_neutron_plugin_ml2('agent/l2_population').with_value(p[:l2_population])
- should contain_neutron_plugin_ml2('agent/arp_responder').with_value(p[:arp_responder])
- should contain_neutron_plugin_ml2('ovs/integration_bridge').with_value(p[:integration_bridge])
- should contain_neutron_plugin_ml2('securitygroup/firewall_driver').\
+ should contain_neutron_agent_ovs('agent/polling_interval').with_value(p[:polling_interval])
+ should contain_neutron_agent_ovs('agent/l2_population').with_value(p[:l2_population])
+ should contain_neutron_agent_ovs('agent/arp_responder').with_value(p[:arp_responder])
+ should contain_neutron_agent_ovs('ovs/integration_bridge').with_value(p[:integration_bridge])
+ should contain_neutron_agent_ovs('securitygroup/firewall_driver').\
with_value(p[:firewall_driver])
- should contain_neutron_plugin_ml2('ovs/enable_tunneling').with_value(false)
- should contain_neutron_plugin_ml2('ovs/tunnel_bridge').with_ensure('absent')
- should contain_neutron_plugin_ml2('ovs/local_ip').with_ensure('absent')
+ should contain_neutron_agent_ovs('ovs/enable_tunneling').with_value(false)
+ should contain_neutron_agent_ovs('ovs/tunnel_bridge').with_ensure('absent')
+ should contain_neutron_agent_ovs('ovs/local_ip').with_ensure('absent')
end
it 'configures vs_bridge' do
@@ -59,18 +59,20 @@ describe 'neutron::agents::ml2::ovs' do
:name => platform_params[:ovs_agent_package],
:ensure => p[:package_ensure]
)
- should contain_package('neutron-ovs-agent').with_before(/Neutron_plugin_ml2\[.+\]/)
+ should contain_package('neutron-ovs-agent').with_before(/Neutron_agent_ovs\[.+\]/)
else
end
end
- it 'configures neutron ovs agent service' do
- should contain_service('neutron-ovs-agent-service').with(
- :name => platform_params[:ovs_agent_service],
- :enable => true,
- :ensure => 'running',
- :require => 'Class[Neutron]'
- )
+ it 'configures neutron ovs cleanup service (if any)' do
+ if platform_params.has_key?(:ovs_cleanup_service)
+ should contain_service('ovs-cleanup-service').with(
+ :name => platform_params[:ovs_cleanup_service],
+ :enable => true,
+ :ensure => 'running'
+ )
+ should contain_package('neutron-ovs-agent').with_before(/Service\[ovs-cleanup-service\]/)
+ end
end
context 'when supplying a firewall driver' do
@@ -78,7 +80,7 @@ describe 'neutron::agents::ml2::ovs' do
params.merge!(:firewall_driver => false)
end
it 'should configure firewall driver' do
- should contain_neutron_plugin_ml2('securitygroup/firewall_driver').with_ensure('absent')
+ should contain_neutron_agent_ovs('securitygroup/firewall_driver').with_ensure('absent')
end
end
@@ -87,7 +89,7 @@ describe 'neutron::agents::ml2::ovs' do
params.merge!(:arp_responder => true)
end
it 'should enable ARP responder' do
- should contain_neutron_plugin_ml2('agent/arp_responder').with_value(true)
+ should contain_neutron_agent_ovs('agent/arp_responder').with_value(true)
end
end
@@ -97,7 +99,7 @@ describe 'neutron::agents::ml2::ovs' do
:l2_population => true )
end
it 'should enable DVR' do
- should contain_neutron_plugin_ml2('agent/enable_distributed_routing').with_value(true)
+ should contain_neutron_agent_ovs('agent/enable_distributed_routing').with_value(true)
end
end
@@ -107,7 +109,7 @@ describe 'neutron::agents::ml2::ovs' do
end
it 'configures bridge mappings' do
- should contain_neutron_plugin_ml2('ovs/bridge_mappings')
+ should contain_neutron_agent_ovs('ovs/bridge_mappings')
end
it 'should configure bridge mappings' do
@@ -139,9 +141,9 @@ describe 'neutron::agents::ml2::ovs' do
params.merge!(:enable_tunneling => true, :local_ip => '127.0.0.1' )
end
it 'should configure ovs for tunneling' do
- should contain_neutron_plugin_ml2('ovs/enable_tunneling').with_value(true)
- should contain_neutron_plugin_ml2('ovs/tunnel_bridge').with_value(default_params[:tunnel_bridge])
- should contain_neutron_plugin_ml2('ovs/local_ip').with_value('127.0.0.1')
+ should contain_neutron_agent_ovs('ovs/enable_tunneling').with_value(true)
+ should contain_neutron_agent_ovs('ovs/tunnel_bridge').with_value(default_params[:tunnel_bridge])
+ should contain_neutron_agent_ovs('ovs/local_ip').with_value('127.0.0.1')
should contain_vs_bridge(default_params[:tunnel_bridge]).with(
:ensure => 'present',
:before => 'Service[neutron-ovs-agent-service]'
@@ -158,8 +160,8 @@ describe 'neutron::agents::ml2::ovs' do
end
it 'should perform vxlan network configuration' do
- should contain_neutron_plugin_ml2('agent/tunnel_types').with_value(params[:tunnel_types])
- should contain_neutron_plugin_ml2('agent/vxlan_udp_port').with_value(params[:vxlan_udp_port])
+ should contain_neutron_agent_ovs('agent/tunnel_types').with_value(params[:tunnel_types])
+ should contain_neutron_agent_ovs('agent/vxlan_udp_port').with_value(params[:vxlan_udp_port])
end
end
@@ -210,12 +212,5 @@ describe 'neutron::agents::ml2::ovs' do
)
should contain_package('neutron-ovs-agent').with_before(/Service\[ovs-cleanup-service\]/)
end
-
- it 'links from ovs config to plugin config' do
- should contain_file('/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini').with(
- :ensure => 'link',
- :target => '/etc/neutron/plugins/ml2/ml2_conf.ini'
- )
- end
end
end