Add support for OVN plugin
Added a puppet class to install the plugin package and configure the OVN plugin Closes-bug: #1566280 Change-Id: I9d33721ef80938b955b18c6e97e10000b144ce2f
This commit is contained in:
parent
1941fd80fc
commit
1fb8dd50e9
10
lib/puppet/provider/neutron_plugin_ovn/ini_setting.rb
Normal file
10
lib/puppet/provider/neutron_plugin_ovn/ini_setting.rb
Normal file
@ -0,0 +1,10 @@
|
||||
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
|
35
lib/puppet/type/neutron_plugin_ovn.rb
Normal file
35
lib/puppet/type/neutron_plugin_ovn.rb
Normal file
@ -0,0 +1,35 @@
|
||||
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
|
@ -66,6 +66,9 @@
|
||||
# [*plugin_opencontrail_config*]
|
||||
# (optional) Manage configuration of plugins/opencontrail/ContrailPlugin.ini
|
||||
#
|
||||
# [*plugin_ovn_config*]
|
||||
# (optional) Manage configuration of plugins/networking-ovn/networking-ovn.ini
|
||||
#
|
||||
# [*plugin_nuage_config*]
|
||||
# (optional) Manage configuration of plugins/nuage/plugin.ini
|
||||
#
|
||||
@ -94,6 +97,7 @@ class neutron::config (
|
||||
$plugin_midonet_config = {},
|
||||
$plugin_plumgrid_config = {},
|
||||
$plugin_opencontrail_config = {},
|
||||
$plugin_ovn_config = {},
|
||||
$plugin_nuage_config = {},
|
||||
$plugin_ml2_config = {},
|
||||
) {
|
||||
@ -113,6 +117,7 @@ class neutron::config (
|
||||
validate_hash($plugin_midonet_config)
|
||||
validate_hash($plugin_plumgrid_config)
|
||||
validate_hash($plugin_opencontrail_config)
|
||||
validate_hash($plugin_ovn_config)
|
||||
validate_hash($plugin_nuage_config)
|
||||
validate_hash($plugin_ml2_config)
|
||||
|
||||
@ -130,6 +135,7 @@ 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)
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ class neutron::params {
|
||||
$midonet_server_package = 'python-neutron-plugin-midonet'
|
||||
$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'
|
||||
$plumgrid_config_file = '/etc/neutron/plugins/plumgrid/plumgrid.ini'
|
||||
@ -127,6 +130,9 @@ class neutron::params {
|
||||
$midonet_server_package = 'python-neutron-plugin-midonet'
|
||||
$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'
|
||||
$plumgrid_config_file = '/etc/neutron/plugins/plumgrid/plumgrid.ini'
|
||||
|
105
manifests/plugins/ovn.pp
Normal file
105
manifests/plugins/ovn.pp
Normal file
@ -0,0 +1,105 @@
|
||||
# This class installs and configures the OVN Neutron plugin
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*ovsdb_connection*]
|
||||
# (required) The connection string for the native OVSDB backend.
|
||||
#
|
||||
# [*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::ovn(
|
||||
$ovsdb_connection,
|
||||
$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::params
|
||||
|
||||
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' )
|
||||
}
|
||||
|
||||
package {'neutron-plugin-ovn':
|
||||
ensure => present,
|
||||
name => $::neutron::params::ovn_plugin_package,
|
||||
tag => 'openstack'
|
||||
}
|
||||
|
||||
Neutron_plugin_ovn<||> ~> Service['neutron-server']
|
||||
|
||||
ensure_resource('file', '/etc/neutron/plugins/networking-ovn', {
|
||||
ensure => directory,
|
||||
owner => 'root',
|
||||
group => 'neutron',
|
||||
mode => '0640'}
|
||||
)
|
||||
|
||||
# Ensure the neutron package is installed before config is set
|
||||
# under both RHEL and Ubuntu
|
||||
if $::neutron::params::server_package {
|
||||
Package['neutron-server'] -> Neutron_plugin_ovn<||>
|
||||
} else {
|
||||
Package['neutron'] -> Neutron_plugin_ovn<||>
|
||||
}
|
||||
|
||||
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}",
|
||||
require => [ Package['neutron-server'], Package['neutron-plugin-ovn'] ],
|
||||
notify => Service['neutron-server'],
|
||||
}
|
||||
}
|
||||
|
||||
if $::osfamily == 'Redhat' {
|
||||
file { '/etc/neutron/plugin.ini':
|
||||
ensure => link,
|
||||
target => $::neutron::params::ovn_config_file,
|
||||
require => Package[$::neutron::params::ovn_plugin_package],
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
3
releasenotes/notes/ovn_support-c404cdc8f8624632.yaml
Normal file
3
releasenotes/notes/ovn_support-c404cdc8f8624632.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
---
|
||||
features:
|
||||
- Add support for OVN driver.
|
@ -26,6 +26,7 @@ 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 <||>
|
||||
@ -41,6 +42,7 @@ 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',
|
||||
@ -61,6 +63,7 @@ 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']
|
||||
@ -397,6 +400,24 @@ describe 'basic neutron_config resource' do
|
||||
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' :
|
||||
value => 'foo',
|
||||
}
|
||||
@ -552,6 +573,7 @@ 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',
|
||||
|
120
spec/classes/neutron_plugins_ovn_spec.rb
Normal file
120
spec/classes/neutron_plugins_ovn_spec.rb
Normal file
@ -0,0 +1,120 @@
|
||||
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',
|
||||
:require => ['Package[neutron-server]', 'Package[neutron-plugin-ovn]'],
|
||||
:notify => 'Service[neutron-server]')
|
||||
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
|
Loading…
Reference in New Issue
Block a user