From 8b8ed37b543c7fe1f3d1508751052b9e0c7d27e1 Mon Sep 17 00:00:00 2001 From: Babu Shanmugam Date: Mon, 11 Jul 2016 09:47:20 +0000 Subject: [PATCH] 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 --- .../neutron_plugin_ovn/ini_setting.rb | 10 -- lib/puppet/type/neutron_plugin_ovn.rb | 35 ----- manifests/config.pp | 1 - manifests/deps.pp | 1 - manifests/params.pp | 2 - manifests/plugins/ml2/ovn.pp | 86 +++++++++++++ manifests/plugins/ovn.pp | 60 ++------- .../ovn_ml2_upgrade-9bc64f0da70ca670.yaml | 10 ++ spec/acceptance/neutron_config_spec.rb | 22 ---- spec/classes/neutron_config_spec.rb | 7 - spec/classes/neutron_plugins_ml2_ovn_spec.rb | 83 ++++++++++++ spec/classes/neutron_plugins_ovn_spec.rb | 121 ------------------ 12 files changed, 189 insertions(+), 249 deletions(-) delete mode 100644 lib/puppet/provider/neutron_plugin_ovn/ini_setting.rb delete mode 100644 lib/puppet/type/neutron_plugin_ovn.rb create mode 100644 manifests/plugins/ml2/ovn.pp create mode 100644 releasenotes/notes/ovn_ml2_upgrade-9bc64f0da70ca670.yaml create mode 100644 spec/classes/neutron_plugins_ml2_ovn_spec.rb delete mode 100644 spec/classes/neutron_plugins_ovn_spec.rb diff --git a/lib/puppet/provider/neutron_plugin_ovn/ini_setting.rb b/lib/puppet/provider/neutron_plugin_ovn/ini_setting.rb deleted file mode 100644 index 6978cff15..000000000 --- a/lib/puppet/provider/neutron_plugin_ovn/ini_setting.rb +++ /dev/null @@ -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 diff --git a/lib/puppet/type/neutron_plugin_ovn.rb b/lib/puppet/type/neutron_plugin_ovn.rb deleted file mode 100644 index bf39b6bf0..000000000 --- a/lib/puppet/type/neutron_plugin_ovn.rb +++ /dev/null @@ -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('') - end - - autorequire(:package) do - 'neutron-plugin-ovn' - end - -end diff --git a/manifests/config.pp b/manifests/config.pp index a18525a38..fdb5e6411 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -137,7 +137,6 @@ class neutron::config ( create_resources('neutron_plugin_midonet', $plugin_midonet_config) create_resources('neutron_plugin_plumgrid', $plugin_plumgrid_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_ml2', $plugin_ml2_config) } diff --git a/manifests/deps.pp b/manifests/deps.pp index 0367fdba9..94b6f78df 100644 --- a/manifests/deps.pp +++ b/manifests/deps.pp @@ -56,7 +56,6 @@ class neutron::deps { 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_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_sriov<||> ~> Anchor['neutron::config::end'] Anchor['neutron::config::begin'] -> Neutron_plumlib_plumgrid<||> ~> Anchor['neutron::config::end'] diff --git a/manifests/params.pp b/manifests/params.pp index e2b473b60..fb2c46522 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -43,7 +43,6 @@ class neutron::params { $midonet_config_file = '/etc/neutron/plugins/midonet/midonet.ini' $ovn_plugin_package = 'python-networking-ovn' - $ovn_config_file = '/etc/neutron/plugins/networking-ovn/networking-ovn.ini' $plumgrid_plugin_package = 'networking-plumgrid' $plumgrid_pythonlib_package = 'plumgrid-pythonlib' @@ -131,7 +130,6 @@ class neutron::params { $midonet_config_file = '/etc/neutron/plugins/midonet/midonet.ini' $ovn_plugin_package = 'python-networking-ovn' - $ovn_config_file = '/etc/neutron/plugins/networking-ovn/networking-ovn.ini' $plumgrid_plugin_package = 'networking-plumgrid' $plumgrid_pythonlib_package = 'plumgrid-pythonlib' diff --git a/manifests/plugins/ml2/ovn.pp b/manifests/plugins/ml2/ovn.pp new file mode 100644 index 000000000..3e79297b6 --- /dev/null +++ b/manifests/plugins/ml2/ovn.pp @@ -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; + } +} diff --git a/manifests/plugins/ovn.pp b/manifests/plugins/ovn.pp index feff6fcb0..0c7247fe0 100644 --- a/manifests/plugins/ovn.pp +++ b/manifests/plugins/ovn.pp @@ -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 # # === Parameters @@ -40,57 +43,14 @@ class neutron::plugins::ovn( $vif_type = $::os_service_default, ) { - include ::neutron::deps - include ::neutron::params + warning('neutron::plugins::ovn is deprecated in favor of neutron::plugins::ml2::ovn') - if ! is_service_default($ovn_l3_mode) { - validate_bool($ovn_l3_mode) + class { '::neutron::plugins::ml2::ovn': + 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; - } } diff --git a/releasenotes/notes/ovn_ml2_upgrade-9bc64f0da70ca670.yaml b/releasenotes/notes/ovn_ml2_upgrade-9bc64f0da70ca670.yaml new file mode 100644 index 000000000..7dcb9990d --- /dev/null +++ b/releasenotes/notes/ovn_ml2_upgrade-9bc64f0da70ca670.yaml @@ -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 diff --git a/spec/acceptance/neutron_config_spec.rb b/spec/acceptance/neutron_config_spec.rb index 4c3e64f02..9db30a7ce 100644 --- a/spec/acceptance/neutron_config_spec.rb +++ b/spec/acceptance/neutron_config_spec.rb @@ -26,7 +26,6 @@ describe 'basic neutron_config resource' do File <||> -> Neutron_vpnaas_agent_config <||> File <||> -> Neutron_plugin_midonet <||> File <||> -> Neutron_plugin_opencontrail <||> - File <||> -> Neutron_plugin_ovn <||> File <||> -> Neutron_agent_linuxbridge <||> File <||> -> Neutron_agent_ovs <||> File <||> -> Neutron_plugin_plumgrid <||> @@ -42,7 +41,6 @@ describe 'basic neutron_config resource' do '/etc/neutron/plugins/nicira', '/etc/neutron/plugins/midonet', '/etc/neutron/plugins/opencontrail', - '/etc/neutron/plugins/networking-ovn', '/etc/neutron/plugins/plumgrid'] $neutron_files = [ '/etc/neutron/api-paste.ini', @@ -63,7 +61,6 @@ describe 'basic neutron_config resource' do '/etc/neutron/vpn_agent.ini', '/etc/neutron/plugins/midonet/midonet.ini', '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini', - '/etc/neutron/plugins/networking-ovn/networking-ovn.ini', '/etc/neutron/plugins/plumgrid/plumgrid.ini', '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini', '/etc/neutron/plugins/ml2/sriov_agent.ini'] @@ -400,24 +397,6 @@ describe 'basic neutron_config resource' do ensure_absent_val => 'toto', } - neutron_plugin_ovn { 'DEFAULT/thisshouldexist' : - value => 'foo', - } - - neutron_plugin_ovn { 'DEFAULT/thisshouldnotexist' : - value => '', - } - - neutron_plugin_ovn { 'DEFAULT/thisshouldexist2' : - value => '', - ensure_absent_val => 'toto', - } - - neutron_plugin_ovn { 'DEFAULT/thisshouldnotexist2' : - value => 'toto', - ensure_absent_val => 'toto', - } - neutron_agent_linuxbridge { 'DEFAULT/thisshouldexist' : value => 'foo', } @@ -551,7 +530,6 @@ describe 'basic neutron_config resource' do '/etc/neutron/vpn_agent.ini', '/etc/neutron/plugins/midonet/midonet.ini', '/etc/neutron/plugins/opencontrail/ContrailPlugin.ini', - '/etc/neutron/plugins/networking-ovn/networking-ovn.ini', '/etc/neutron/plugins/plumgrid/plumgrid.ini', '/etc/neutron/plugins/ml2/ml2_conf_sriov.ini', '/etc/neutron/plugins/ml2/sriov_agent.ini'] diff --git a/spec/classes/neutron_config_spec.rb b/spec/classes/neutron_config_spec.rb index b979fb764..9dc8e7fe3 100644 --- a/spec/classes/neutron_config_spec.rb +++ b/spec/classes/neutron_config_spec.rb @@ -85,7 +85,6 @@ describe 'neutron::config' do :plugin_midonet_config => config_hash, :plugin_plumgrid_config => config_hash, :plugin_opencontrail_config => config_hash, - :plugin_ovn_config => config_hash, :plugin_nuage_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') 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 is_expected.to contain_neutron_plugin_nuage('DEFAULT/foo').with_value('fooValue') is_expected.to contain_neutron_plugin_nuage('DEFAULT/bar').with_value('barValue') diff --git a/spec/classes/neutron_plugins_ml2_ovn_spec.rb b/spec/classes/neutron_plugins_ml2_ovn_spec.rb new file mode 100644 index 000000000..68364cffa --- /dev/null +++ b/spec/classes/neutron_plugins_ml2_ovn_spec.rb @@ -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('') + 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 diff --git a/spec/classes/neutron_plugins_ovn_spec.rb b/spec/classes/neutron_plugins_ovn_spec.rb deleted file mode 100644 index 122243ea9..000000000 --- a/spec/classes/neutron_plugins_ovn_spec.rb +++ /dev/null @@ -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('') - 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