Changing ovn plugin to ml2 mechanism driver

openstack/networking-ovn is no more a core plugin. A resent revamping
made it to a ml2 mechanism driver. This patch addresses this change.

Fixes-bug: #1600790
Change-Id: Ie8f8653ed6eefd7e278862de1293e2a2fc206c66
This commit is contained in:
Babu Shanmugam 2016-07-11 09:47:20 +00:00
parent d591774c54
commit 8b8ed37b54
12 changed files with 189 additions and 249 deletions

View File

@ -1,10 +0,0 @@
Puppet::Type.type(:neutron_plugin_ovn).provide(
:ini_setting,
:parent => Puppet::Type.type(:openstack_config).provider(:ini_setting)
) do
def file_path
'/etc/neutron/plugins/networking-ovn/networking-ovn.ini'
end
end

View File

@ -1,35 +0,0 @@
Puppet::Type.newtype(:neutron_plugin_ovn) do
ensurable
newparam(:name, :namevar => true) do
desc 'Section/setting name to manage from networking-ovn.ini'
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
newparam(:secret, :boolean => true) do
desc 'Whether to hide the value from Puppet logs. Defaults to `false`.'
newvalues(:true, :false)
defaultto false
end
newparam(:ensure_absent_val) do
desc 'A value that is specified as the value property will behave as if ensure => absent was specified'
defaultto('<SERVICE DEFAULT>')
end
autorequire(:package) do
'neutron-plugin-ovn'
end
end

View File

@ -137,7 +137,6 @@ class neutron::config (
create_resources('neutron_plugin_midonet', $plugin_midonet_config) create_resources('neutron_plugin_midonet', $plugin_midonet_config)
create_resources('neutron_plugin_plumgrid', $plugin_plumgrid_config) create_resources('neutron_plugin_plumgrid', $plugin_plumgrid_config)
create_resources('neutron_plugin_opencontrail', $plugin_opencontrail_config) create_resources('neutron_plugin_opencontrail', $plugin_opencontrail_config)
create_resources('neutron_plugin_ovn', $plugin_ovn_config)
create_resources('neutron_plugin_nuage', $plugin_nuage_config) create_resources('neutron_plugin_nuage', $plugin_nuage_config)
create_resources('neutron_plugin_ml2', $plugin_ml2_config) create_resources('neutron_plugin_ml2', $plugin_ml2_config)
} }

View File

@ -56,7 +56,6 @@ class neutron::deps {
Anchor['neutron::config::begin'] -> Neutron_plugin_nuage<||> ~> Anchor['neutron::config::end'] Anchor['neutron::config::begin'] -> Neutron_plugin_nuage<||> ~> Anchor['neutron::config::end']
Anchor['neutron::config::begin'] -> Neutron_plugin_nvp<||> ~> Anchor['neutron::config::end'] Anchor['neutron::config::begin'] -> Neutron_plugin_nvp<||> ~> Anchor['neutron::config::end']
Anchor['neutron::config::begin'] -> Neutron_plugin_opencontrail<||> ~> Anchor['neutron::config::end'] Anchor['neutron::config::begin'] -> Neutron_plugin_opencontrail<||> ~> Anchor['neutron::config::end']
Anchor['neutron::config::begin'] -> Neutron_plugin_ovn<||> ~> Anchor['neutron::config::end']
Anchor['neutron::config::begin'] -> Neutron_plugin_plumgrid<||> ~> Anchor['neutron::config::end'] Anchor['neutron::config::begin'] -> Neutron_plugin_plumgrid<||> ~> Anchor['neutron::config::end']
Anchor['neutron::config::begin'] -> Neutron_plugin_sriov<||> ~> Anchor['neutron::config::end'] Anchor['neutron::config::begin'] -> Neutron_plugin_sriov<||> ~> Anchor['neutron::config::end']
Anchor['neutron::config::begin'] -> Neutron_plumlib_plumgrid<||> ~> Anchor['neutron::config::end'] Anchor['neutron::config::begin'] -> Neutron_plumlib_plumgrid<||> ~> Anchor['neutron::config::end']

View File

@ -43,7 +43,6 @@ class neutron::params {
$midonet_config_file = '/etc/neutron/plugins/midonet/midonet.ini' $midonet_config_file = '/etc/neutron/plugins/midonet/midonet.ini'
$ovn_plugin_package = 'python-networking-ovn' $ovn_plugin_package = 'python-networking-ovn'
$ovn_config_file = '/etc/neutron/plugins/networking-ovn/networking-ovn.ini'
$plumgrid_plugin_package = 'networking-plumgrid' $plumgrid_plugin_package = 'networking-plumgrid'
$plumgrid_pythonlib_package = 'plumgrid-pythonlib' $plumgrid_pythonlib_package = 'plumgrid-pythonlib'
@ -131,7 +130,6 @@ class neutron::params {
$midonet_config_file = '/etc/neutron/plugins/midonet/midonet.ini' $midonet_config_file = '/etc/neutron/plugins/midonet/midonet.ini'
$ovn_plugin_package = 'python-networking-ovn' $ovn_plugin_package = 'python-networking-ovn'
$ovn_config_file = '/etc/neutron/plugins/networking-ovn/networking-ovn.ini'
$plumgrid_plugin_package = 'networking-plumgrid' $plumgrid_plugin_package = 'networking-plumgrid'
$plumgrid_pythonlib_package = 'plumgrid-pythonlib' $plumgrid_pythonlib_package = 'plumgrid-pythonlib'

View File

@ -0,0 +1,86 @@
# This class installs and configures the OVN Neutron plugin
#
# === Parameters
#
# [*ovn_nb_connection*]
# (optional) The connection string for the OVN_Northbound OVSDB.
# Defaults to 'tcp:127.0.0.1:6641'
#
# [*ovn_sb_connection*]
# (optional) The connection string for the OVN_Southbound OVSDB
# Defaults to 'tcp:127.0.0.1:6642'
#
# [*package_ensure*]
# (optional) The intended state of the python-networking-odl
# package, i.e. any of the possible values of the 'ensure'
# property for a package resource type.
# Defaults to 'present'
#
# [*ovsdb_connection_timeout*]
# (optional) Timeout in seconds for the OVSDB connection transaction
# Defaults to $::os_service_default
#
# [*neutron_sync_mode*]
# (optional) The synchronization mode of OVN with Neutron DB.
# Valid values are - ['log', 'off', 'repair']
# off - synchronization is off
# log - during neutron-server startup check to see if OVN is in sync with
# the Neutron database. Log warnings for any inconsistencies found so
# that an admin can investigate.
# repair - during neutron-server startup, automatically create resources
# found in Neutron but not in OVN. Also remove resources from OVN
# that are no longer in Neutron.
# Defaults to $::os_service_default
#
# [*ovn_l3_mode*]
# (optional) Whether to use OVN native L3 support. Do not change the
# value for existing deployments that contain routers.
# Type: boolean
# Defaults to $::os_service_default
#
# [*vif_type*]
# (optional) Type of VIF to be used for ports.
# Valid values are ['ovs', 'vhostuser']
# Defaults to $::os_service_default
class neutron::plugins::ml2::ovn(
$ovn_nb_connection = $::os_service_default,
$ovn_sb_connection = $::os_service_default,
$package_ensure = 'present',
$ovsdb_connection_timeout = $::os_service_default,
$neutron_sync_mode = $::os_service_default,
$ovn_l3_mode = $::os_service_default,
$vif_type = $::os_service_default,
) {
include ::neutron::deps
require ::neutron::plugins::ml2
if ! is_service_default($ovn_l3_mode) {
validate_bool($ovn_l3_mode)
}
if ! ( $vif_type in ['ovs', 'vhostuser', $::os_service_default] ) {
fail( 'Invalid value for vif_type parameter' )
}
if ! ( $neutron_sync_mode in ['off', 'log', 'repair', $::os_service_default] ) {
fail( 'Invalid value for neutron_sync_mode parameter' )
}
ensure_resource('package', $::neutron::params::ovn_plugin_package,
{
ensure => $package_ensure,
tag => 'openstack',
}
)
neutron_plugin_ml2 {
'ml2_ovn/ovn_nb_connection' : value => $ovn_nb_connection;
'ml2_ovn/ovn_sb_connection' : value => $ovn_sb_connection;
'ml2_ovn/ovsdb_connection_timeout' : value => $ovsdb_connection_timeout;
'ml2_ovn/neutron_sync_mode' : value => $neutron_sync_mode;
'ml2_ovn/ovn_l3_mode' : value => $ovn_l3_mode;
'ml2_ovn/vif_type' : value => $vif_type;
}
}

View File

@ -1,3 +1,6 @@
# == DEPRECATED
# This class has been deprecated in favor of neutron::plugins::ml2::ovn
#
# This class installs and configures the OVN Neutron plugin # This class installs and configures the OVN Neutron plugin
# #
# === Parameters # === Parameters
@ -40,57 +43,14 @@ class neutron::plugins::ovn(
$vif_type = $::os_service_default, $vif_type = $::os_service_default,
) { ) {
include ::neutron::deps warning('neutron::plugins::ovn is deprecated in favor of neutron::plugins::ml2::ovn')
include ::neutron::params
if ! is_service_default($ovn_l3_mode) { class { '::neutron::plugins::ml2::ovn':
validate_bool($ovn_l3_mode) ovn_nb_connection => $ovsdb_connection,
ovsdb_connection_timeout => $ovsdb_connection_timeout,
neutron_sync_mode => $neutron_sync_mode,
ovn_l3_mode => $ovn_l3_mode,
vif_type => $vif_type
} }
if ! ( $vif_type in ['ovs', 'vhostuser', $::os_service_default] ) {
fail( 'Invalid value for vif_type parameter' )
}
if ! ( $neutron_sync_mode in ['off', 'log', 'repair', $::os_service_default] ) {
fail( 'Invalid value for neutron_sync_mode parameter' )
}
package {'neutron-plugin-ovn':
ensure => present,
name => $::neutron::params::ovn_plugin_package,
tag => ['neutron-package', 'openstack'],
}
ensure_resource('file', '/etc/neutron/plugins/networking-ovn', {
ensure => directory,
owner => 'root',
group => 'neutron',
mode => '0640'}
)
if $::osfamily == 'Debian' {
file_line { '/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG':
path => '/etc/default/neutron-server',
match => '^NEUTRON_PLUGIN_CONFIG=(.*)$',
line => "NEUTRON_PLUGIN_CONFIG=${::neutron::params::ovn_config_file}",
tag => 'neutron-file-line',
}
}
if $::osfamily == 'Redhat' {
file { '/etc/neutron/plugin.ini':
ensure => link,
target => $::neutron::params::ovn_config_file,
require => Package[$::neutron::params::ovn_plugin_package],
tag => 'neutron-config-file',
}
}
neutron_plugin_ovn {
'ovn/ovsdb_connection': value => $ovsdb_connection;
'ovn/ovsdb_connection_timeout': value => $ovsdb_connection_timeout;
'ovn/neutron_sync_mode': value => $neutron_sync_mode;
'ovn/ovn_l3_mode': value => $ovn_l3_mode;
'ovn/vif_type': value => $vif_type;
}
} }

View File

@ -0,0 +1,10 @@
---
upgrade:
- Previously OVN plugin for Neutron used to be a core plugin. With
the recent changes in networking-ovn project, OVN is plugged in to
neutron as an ml2 mechanism driver.
deprecations:
- neutron::plugins::ovn is deprecated as it was managing OVN as a
core-plugin. This is deprecated in favor of its ml2 equivalent
neutron::plugins::ml2::ovn

View File

@ -26,7 +26,6 @@ describe 'basic neutron_config resource' do
File <||> -> Neutron_vpnaas_agent_config <||> File <||> -> Neutron_vpnaas_agent_config <||>
File <||> -> Neutron_plugin_midonet <||> File <||> -> Neutron_plugin_midonet <||>
File <||> -> Neutron_plugin_opencontrail <||> File <||> -> Neutron_plugin_opencontrail <||>
File <||> -> Neutron_plugin_ovn <||>
File <||> -> Neutron_agent_linuxbridge <||> File <||> -> Neutron_agent_linuxbridge <||>
File <||> -> Neutron_agent_ovs <||> File <||> -> Neutron_agent_ovs <||>
File <||> -> Neutron_plugin_plumgrid <||> File <||> -> Neutron_plugin_plumgrid <||>
@ -42,7 +41,6 @@ describe 'basic neutron_config resource' do
'/etc/neutron/plugins/nicira', '/etc/neutron/plugins/nicira',
'/etc/neutron/plugins/midonet', '/etc/neutron/plugins/midonet',
'/etc/neutron/plugins/opencontrail', '/etc/neutron/plugins/opencontrail',
'/etc/neutron/plugins/networking-ovn',
'/etc/neutron/plugins/plumgrid'] '/etc/neutron/plugins/plumgrid']
$neutron_files = [ '/etc/neutron/api-paste.ini', $neutron_files = [ '/etc/neutron/api-paste.ini',
@ -63,7 +61,6 @@ describe 'basic neutron_config resource' do
'/etc/neutron/vpn_agent.ini', '/etc/neutron/vpn_agent.ini',
'/etc/neutron/plugins/midonet/midonet.ini', '/etc/neutron/plugins/midonet/midonet.ini',
'/etc/neutron/plugins/opencontrail/ContrailPlugin.ini', '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini',
'/etc/neutron/plugins/networking-ovn/networking-ovn.ini',
'/etc/neutron/plugins/plumgrid/plumgrid.ini', '/etc/neutron/plugins/plumgrid/plumgrid.ini',
'/etc/neutron/plugins/ml2/ml2_conf_sriov.ini', '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini',
'/etc/neutron/plugins/ml2/sriov_agent.ini'] '/etc/neutron/plugins/ml2/sriov_agent.ini']
@ -400,24 +397,6 @@ describe 'basic neutron_config resource' do
ensure_absent_val => 'toto', ensure_absent_val => 'toto',
} }
neutron_plugin_ovn { 'DEFAULT/thisshouldexist' :
value => 'foo',
}
neutron_plugin_ovn { 'DEFAULT/thisshouldnotexist' :
value => '<SERVICE DEFAULT>',
}
neutron_plugin_ovn { 'DEFAULT/thisshouldexist2' :
value => '<SERVICE DEFAULT>',
ensure_absent_val => 'toto',
}
neutron_plugin_ovn { 'DEFAULT/thisshouldnotexist2' :
value => 'toto',
ensure_absent_val => 'toto',
}
neutron_agent_linuxbridge { 'DEFAULT/thisshouldexist' : neutron_agent_linuxbridge { 'DEFAULT/thisshouldexist' :
value => 'foo', value => 'foo',
} }
@ -551,7 +530,6 @@ describe 'basic neutron_config resource' do
'/etc/neutron/vpn_agent.ini', '/etc/neutron/vpn_agent.ini',
'/etc/neutron/plugins/midonet/midonet.ini', '/etc/neutron/plugins/midonet/midonet.ini',
'/etc/neutron/plugins/opencontrail/ContrailPlugin.ini', '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini',
'/etc/neutron/plugins/networking-ovn/networking-ovn.ini',
'/etc/neutron/plugins/plumgrid/plumgrid.ini', '/etc/neutron/plugins/plumgrid/plumgrid.ini',
'/etc/neutron/plugins/ml2/ml2_conf_sriov.ini', '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini',
'/etc/neutron/plugins/ml2/sriov_agent.ini'] '/etc/neutron/plugins/ml2/sriov_agent.ini']

View File

@ -85,7 +85,6 @@ describe 'neutron::config' do
:plugin_midonet_config => config_hash, :plugin_midonet_config => config_hash,
:plugin_plumgrid_config => config_hash, :plugin_plumgrid_config => config_hash,
:plugin_opencontrail_config => config_hash, :plugin_opencontrail_config => config_hash,
:plugin_ovn_config => config_hash,
:plugin_nuage_config => config_hash, :plugin_nuage_config => config_hash,
:plugin_ml2_config => config_hash :plugin_ml2_config => config_hash
} }
@ -133,12 +132,6 @@ describe 'neutron::config' do
is_expected.to contain_neutron_plugin_opencontrail('DEFAULT/baz').with_ensure('absent') is_expected.to contain_neutron_plugin_opencontrail('DEFAULT/baz').with_ensure('absent')
end end
it 'configures arbitrary neutron_plugin_ovn configurations' do
is_expected.to contain_neutron_plugin_ovn('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_neutron_plugin_ovn('DEFAULT/bar').with_value('barValue')
is_expected.to contain_neutron_plugin_ovn('DEFAULT/baz').with_ensure('absent')
end
it 'configures arbitrary neutron_plugin_nuage configurations' do it 'configures arbitrary neutron_plugin_nuage configurations' do
is_expected.to contain_neutron_plugin_nuage('DEFAULT/foo').with_value('fooValue') is_expected.to contain_neutron_plugin_nuage('DEFAULT/foo').with_value('fooValue')
is_expected.to contain_neutron_plugin_nuage('DEFAULT/bar').with_value('barValue') is_expected.to contain_neutron_plugin_nuage('DEFAULT/bar').with_value('barValue')

View File

@ -0,0 +1,83 @@
require 'spec_helper'
describe 'neutron::plugins::ml2::ovn' do
let :pre_condition do
"class { 'neutron::server': auth_password => 'password' }
class { 'neutron': rabbit_password => 'passw0rd' }"
end
let :default_params do
{
:ovn_nb_connection => 'tcp:127.0.0.1:6641',
:ovn_sb_connection => 'tcp:127.0.0.1:6642',
:ovsdb_connection_timeout => '60',
:neutron_sync_mode => 'log',
:ovn_l3_mode => true,
:vif_type => 'ovs',
}
end
let :test_facts do
{ :operatingsystem => 'default',
:operatingsystemrelease => 'default'
}
end
shared_examples_for 'neutron ovn plugin' do
let :params do
{}
end
before do
params.merge!(default_params)
end
it 'should perform default configuration of' do
is_expected.to contain_neutron_plugin_ml2('ml2_ovn/ovn_nb_connection').with_value(params[:ovn_nb_connection])
is_expected.to contain_neutron_plugin_ml2('ml2_ovn/ovn_sb_connection').with_value(params[:ovn_sb_connection])
is_expected.to contain_neutron_plugin_ml2('ml2_ovn/ovsdb_connection_timeout').with_value(params[:ovsdb_connection_timeout])
is_expected.to contain_neutron_plugin_ml2('ml2_ovn/neutron_sync_mode').with_value(params[:neutron_sync_mode])
is_expected.to contain_neutron_plugin_ml2('ml2_ovn/ovn_l3_mode').with_value(params[:ovn_l3_mode])
is_expected.to contain_neutron_plugin_ml2('ml2_ovn/vif_type').with_value(params[:vif_type])
end
end
shared_examples_for 'Validating parameters' do
let :params do
{}
end
before :each do
params.clear
params.merge!(default_params)
end
it 'should fail with invalid neutron_sync_mode' do
params[:neutron_sync_mode] = 'invalid'
is_expected.to raise_error(Puppet::Error, /Invalid value for neutron_sync_mode parameter/)
end
it 'should fail with invalid vif_type' do
params[:vif_type] = 'invalid'
is_expected.to raise_error(Puppet::Error, /Invalid value for vif_type parameter/)
params.delete(:vif_type)
is_expected.to contain_neutron_plugin_ml2('ml2_ovn/vif_type').with_value('<SERVICE DEFAULT>')
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts({:processorcount => 8}))
end
it_configures 'neutron ovn plugin'
it_configures 'Validating parameters'
end
end
end

View File

@ -1,121 +0,0 @@
require 'spec_helper'
describe 'neutron::plugins::ovn' do
let :pre_condition do
"class { 'neutron::server': auth_password => 'password' }
class { 'neutron': rabbit_password => 'passw0rd' }"
end
let :default_params do
{
:ovsdb_connection => 'tcp:127.0.0.1:6641',
:ovsdb_connection_timeout => '60',
:neutron_sync_mode => 'log',
:ovn_l3_mode => true,
:vif_type => 'ovs',
}
end
let :test_facts do
{ :operatingsystem => 'default',
:operatingsystemrelease => 'default'
}
end
shared_examples_for 'neutron ovn plugin' do
let :params do
{}
end
before do
params.merge!(default_params)
end
it 'should perform default configuration of' do
is_expected.to contain_neutron_plugin_ovn('ovn/ovsdb_connection').with_value(params[:ovsdb_connection])
is_expected.to contain_neutron_plugin_ovn('ovn/ovsdb_connection_timeout').with_value(params[:ovsdb_connection_timeout])
is_expected.to contain_neutron_plugin_ovn('ovn/neutron_sync_mode').with_value(params[:neutron_sync_mode])
is_expected.to contain_neutron_plugin_ovn('ovn/ovn_l3_mode').with_value(params[:ovn_l3_mode])
is_expected.to contain_neutron_plugin_ovn('ovn/vif_type').with_value(params[:vif_type])
end
end
shared_examples_for 'Validating parameters' do
let :params do
{}
end
before :each do
params.clear
params.merge!(default_params)
end
it 'should fail with undefined ovsdb_connection' do
params.delete(:ovsdb_connection)
is_expected.to raise_error(Puppet::Error)
end
it 'should fail with invalid neutron_sync_mode' do
params[:neutron_sync_mode] = 'invalid'
is_expected.to raise_error(Puppet::Error, /Invalid value for neutron_sync_mode parameter/)
end
it 'should fail with invalid vif_type' do
params[:vif_type] = 'invalid'
is_expected.to raise_error(Puppet::Error, /Invalid value for vif_type parameter/)
params.delete(:vif_type)
is_expected.to contain_neutron_plugin_ovn('ovn/vif_type').with_value('<SERVICE DEFAULT>')
end
end
shared_examples_for 'debian specific' do
let :params do
default_params
end
it 'configures /etc/default/neutron-server' do
is_expected.to contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').with(
:path => '/etc/default/neutron-server',
:match => '^NEUTRON_PLUGIN_CONFIG=(.*)$',
:line => 'NEUTRON_PLUGIN_CONFIG=/etc/neutron/plugins/networking-ovn/networking-ovn.ini',
:tag => 'neutron-file-line')
is_expected.to contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').that_requires('Anchor[neutron::config::begin]')
is_expected.to contain_file_line('/etc/default/neutron-server:NEUTRON_PLUGIN_CONFIG').that_notifies('Anchor[neutron::config::end]')
end
end
shared_examples_for 'redhat specific' do
let :params do
default_params
end
it 'should create plugin symbolic link' do
is_expected.to contain_file('/etc/neutron/plugin.ini').with(
:ensure => 'link',
:target => '/etc/neutron/plugins/networking-ovn/networking-ovn.ini',
:require => 'Package[python-networking-ovn]')
end
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge(OSDefaults.get_facts({:processorcount => 8}))
end
case facts[:osfamily]
when 'Debian'
it_configures 'debian specific'
when 'RedHat'
it_configures 'redhat specific'
end
it_configures 'neutron ovn plugin'
it_configures 'Validating parameters'
end
end
end