Use kernel build-in openVswitch module for CentOS7/RHEL7

* Move hardcoded CentOS6 ovs_datapath_package_name from l23network::params.pp
to top netconfig.pp manifest.
* Add the possibility to use DKMS datapath openVswitch or kernel build-in module
for l23network.

Change-Id: I7b006a9dc3b3ec5b22dd41cc15b57d5730e4810c
Closes-bug: #1508515
This commit is contained in:
Stanislav Makar 2015-10-22 11:13:08 +00:00
parent 7759a70efe
commit ce64b166b5
7 changed files with 297 additions and 52 deletions

View File

@ -29,16 +29,17 @@ Include L23network module and initialize it. It is recommended to do it on the e
Initialization class 'l23network' has following incoming parameters and its default values:
class { 'l23network':
use_ovs => false,
use_lnx => true,
install_ovs => $use_ovs,
install_brtool => $use_lnx,
install_ethtool => $use_lnx,
install_bondtool => $use_lnx,
install_vlantool => $use_lnx,
ovs_modname => undef,
ovs_datapath_package_name => undef,
ovs_common_package_name => undef,
use_ovs => false,
use_lnx => true,
install_ovs => $use_ovs,
install_brtool => $use_lnx,
install_ethtool => $use_lnx,
install_bondtool => $use_lnx,
install_vlantool => $use_lnx,
ovs_module_name => undef,
use_ovs_dkms_datapath_module => undef,
ovs_datapath_package_name => undef,
ovs_common_package_name => undef,
}
For highly customized configurations you can redefine each of ones. For example, if you plan to use open vSwitch you should enable it:

View File

@ -9,40 +9,54 @@
# (optional) The state of used packages
# Defaults to 'present'
#
# [*use_ovs_dkms_datapath_module*]
# (optional) The usage of DKMS datapath openVswitch or kernel build-in module
# Defaults to true
#
# [*ovs_module_name*]
# (optional) The custom datapath openVswitch module name
# Defaults to undef, the value from params.pp is used
#
# [*ovs_datapath_package_name*]
# (optional) The custom name of datapath openVswitch package
# Defaults to undef, the value from params.pp is used
#
# [*disable_hotplug*]
# (optional) Enables to disable hotplug system temporarily during network configuration
# Defaults to true
#
class l23network (
$ensure_package = 'present',
$use_lnx = true,
$use_ovs = false,
$install_ovs = $use_ovs,
$install_brtool = $use_lnx,
$install_ethtool = $use_lnx,
$install_bondtool = $use_lnx,
$install_vlantool = $use_lnx,
$ovs_modname = undef,
$ovs_datapath_package_name = undef,
$ovs_common_package_name = undef,
$disable_hotplug = true,
$ensure_package = 'present',
$use_lnx = true,
$use_ovs = false,
$install_ovs = $use_ovs,
$install_brtool = $use_lnx,
$install_ethtool = $use_lnx,
$install_bondtool = $use_lnx,
$install_vlantool = $use_lnx,
$ovs_module_name = undef,
$use_ovs_dkms_datapath_module = true,
$ovs_datapath_package_name = undef,
$ovs_common_package_name = undef,
$disable_hotplug = true,
){
include stdlib
include ::l23network::params
class { 'l23network::l2':
ensure_package => $ensure_package,
use_ovs => $use_ovs,
use_lnx => $use_lnx,
install_ovs => $install_ovs,
install_brtool => $install_brtool,
install_ethtool => $install_ethtool,
install_bondtool => $install_bondtool,
install_vlantool => $install_vlantool,
ovs_modname => $ovs_modname,
ovs_datapath_package_name => $ovs_datapath_package_name,
ovs_common_package_name => $ovs_common_package_name,
ensure_package => $ensure_package,
use_ovs => $use_ovs,
use_lnx => $use_lnx,
install_ovs => $install_ovs,
install_brtool => $install_brtool,
install_ethtool => $install_ethtool,
install_bondtool => $install_bondtool,
install_vlantool => $install_vlantool,
ovs_module_name => $ovs_module_name,
use_ovs_dkms_datapath_module => $use_ovs_dkms_datapath_module,
ovs_datapath_package_name => $ovs_datapath_package_name,
ovs_common_package_name => $ovs_common_package_name,
}
if $::l23network::params::interfaces_file {

View File

@ -10,17 +10,18 @@
# Defaults to 'present'
#
class l23network::l2 (
$ensure_package = 'present',
$use_lnx = true,
$use_ovs = false,
$install_ovs = $use_ovs,
$install_brtool = $use_lnx,
$install_ethtool = $use_lnx,
$install_bondtool = $use_lnx,
$install_vlantool = $use_lnx,
$ovs_modname = $::l23network::params::ovs_kern_module_name,
$ovs_datapath_package_name = $::l23network::params::ovs_datapath_package_name,
$ovs_common_package_name = $::l23network::params::ovs_common_package_name,
$ensure_package = 'present',
$use_lnx = true,
$use_ovs = false,
$install_ovs = $use_ovs,
$install_brtool = $use_lnx,
$install_ethtool = $use_lnx,
$install_bondtool = $use_lnx,
$install_vlantool = $use_lnx,
$ovs_module_name = $::l23network::params::ovs_kern_module_name,
$use_ovs_dkms_datapath_module = true,
$ovs_datapath_package_name = $::l23network::params::ovs_datapath_package_name,
$ovs_common_package_name = $::l23network::params::ovs_common_package_name,
){
include stdlib
include ::l23network::params
@ -28,7 +29,7 @@ class l23network::l2 (
if $use_ovs {
$ovs_mod_ensure = present
if $install_ovs {
if $ovs_datapath_package_name {
if $use_ovs_dkms_datapath_module {
package { 'openvswitch-datapath':
name => $ovs_datapath_package_name,
ensure => $ensure_package,
@ -58,7 +59,7 @@ class l23network::l2 (
$ovs_mod_ensure = absent
}
@k_mod{$ovs_modname:
@k_mod{$ovs_module_name :
ensure => $ovs_mod_ensure
}

View File

@ -27,10 +27,7 @@ class l23network::params {
$lnx_bond_tools = undef
$lnx_ethernet_tools = 'ethtool'
$lnx_bridge_tools = 'bridge-utils'
$ovs_datapath_package_name = $::kernelmajversion ? {
'3.10' => 'kmod-openvswitch-lt',
default => 'kmod-openvswitch',
}
$ovs_datapath_package_name = 'kmod-openvswitch'
$ovs_common_package_name = 'openvswitch'
$ovs_kern_module_name = 'openvswitch'
$extra_tools = 'iputils'

View File

@ -0,0 +1,223 @@
require 'spec_helper'
describe 'l23network::l2' do
context 'CentOS 7' do
let (:facts) do
{ :l23_os => 'centos7',
:l3_fqdn_hostname => 'my_name',
}
end
let :pre_condition do
'K_mod <| |>'
end
puppet_debug_override
context 'with a default params' do
let :params do
{ }
end
it { should compile.with_all_deps }
it { should_not contain_package('openvswitch-datapath') }
it { should_not contain_package('openvswitch-common').with_name('openvswitch') }
it { should_not contain_service('openvswitch-service') }
it { should_not contain_k_mod('openvswitch').with_ensure('present') }
it { should contain_k_mod('bonding') }
it { should contain_k_mod('8021q') }
it { should contain_k_mod('bridge') }
end
context 'use_ovs with default parameters' do
let :params do
{ :ensure_package => 'present',
:use_lnx => true,
:use_ovs => true,
}
end
it { should compile.with_all_deps }
it { should contain_package('openvswitch-datapath').with_name('kmod-openvswitch') }
it { should contain_package('openvswitch-datapath').that_comes_before('Service[openvswitch-service]') }
it { should contain_package('openvswitch-common').with_name('openvswitch') }
it { should contain_package('openvswitch-common').that_notifies('Service[openvswitch-service]') }
it { should contain_service('openvswitch-service') }
it { should contain_k_mod('openvswitch').with_ensure('present') }
end
context 'use_ovs and custom ovs_datapath_package_name and custom ovs_module_name and ovs_common_package_name' do
let :params do
{ :ensure_package => 'present',
:use_lnx => true,
:use_ovs => true,
:ovs_module_name => 'custom_ovs_module_name',
:ovs_datapath_package_name => 'custom_ovs_datapath_package_name',
:ovs_common_package_name => 'test_ovs_common_package_name',
}
end
it { should compile.with_all_deps }
it { should contain_package('openvswitch-datapath').with_name('custom_ovs_datapath_package_name') }
it { should contain_package('openvswitch-datapath').that_comes_before('Service[openvswitch-service]') }
it { should contain_package('openvswitch-common').with_name('test_ovs_common_package_name') }
it { should contain_package('openvswitch-common').that_notifies('Service[openvswitch-service]') }
it { should contain_service('openvswitch-service') }
it { should contain_k_mod('custom_ovs_module_name').with_ensure('present') }
end
context 'use_ovs with disabled dkms ovs module' do
let :params do
{ :ensure_package => 'present',
:use_lnx => true,
:use_ovs => true,
:use_ovs_dkms_datapath_module => false,
}
end
it { should compile.with_all_deps }
it { should_not contain_package('openvswitch-datapath').with_name('kmod-openvswitch') }
it { should contain_package('openvswitch-common').with_name('openvswitch') }
it { should contain_package('openvswitch-common').that_notifies('Service[openvswitch-service]') }
it { should contain_service('openvswitch-service') }
it { should contain_k_mod('openvswitch').with_ensure('present') }
end
end
context 'Ubuntu' do
let (:facts) do
{ :l23_os => 'ubuntu',
:l3_fqdn_hostname => 'my_name',
}
end
let :pre_condition do
'K_mod <| |>'
end
puppet_debug_override
context 'with a default params' do
let :params do
{ }
end
it { should compile.with_all_deps }
it { should_not contain_package('openvswitch-datapath') }
it { should_not contain_package('openvswitch-common') }
it { should_not contain_service('openvswitch-service') }
it { should_not contain_k_mod('openvswitch').with_ensure('present') }
it { should contain_k_mod('bonding') }
it { should contain_k_mod('8021q') }
it { should contain_k_mod('bridge') }
end
context 'use_ovs with default parameters' do
let :params do
{ :ensure_package => 'present',
:use_lnx => true,
:use_ovs => true,
}
end
it { should compile.with_all_deps }
it { should contain_package('openvswitch-datapath').with_name('openvswitch-datapath-dkms') }
it { should contain_package('openvswitch-datapath').that_comes_before('Service[openvswitch-service]') }
it { should contain_package('openvswitch-common').with_name('openvswitch-switch') }
it { should contain_package('openvswitch-common').that_notifies('Service[openvswitch-service]') }
it { should contain_service('openvswitch-service') }
it { should contain_k_mod('openvswitch').with_ensure('present') }
end
context 'use_ovs and custom ovs_datapath_package_name and custom ovs_module_name and ovs_common_package_name' do
let :params do
{ :ensure_package => 'present',
:use_lnx => true,
:use_ovs => true,
:ovs_module_name => 'custom_ovs_module_name',
:ovs_datapath_package_name => 'custom_ovs_datapath_package_name',
:ovs_common_package_name => 'test_ovs_common_package_name',
}
end
it { should compile.with_all_deps }
it { should contain_package('openvswitch-datapath').with_name('custom_ovs_datapath_package_name') }
it { should contain_package('openvswitch-datapath').that_comes_before('Service[openvswitch-service]') }
it { should contain_package('openvswitch-common').with_name('test_ovs_common_package_name') }
it { should contain_package('openvswitch-common').that_notifies('Service[openvswitch-service]') }
it { should contain_service('openvswitch-service') }
it { should contain_k_mod('custom_ovs_module_name').with_ensure('present') }
end
context 'use_ovs with disabled dkms ovs module' do
let :params do
{ :ensure_package => 'present',
:use_lnx => true,
:use_ovs => true,
:use_ovs_dkms_datapath_module => false,
}
end
it { should compile.with_all_deps }
it { should_not contain_package('openvswitch-datapath').with_name('openvswitch-datapath-dkms') }
it { should contain_package('openvswitch-common').with_name('openvswitch-switch') }
it { should contain_package('openvswitch-common').that_notifies('Service[openvswitch-service]') }
it { should contain_service('openvswitch-service') }
it { should contain_k_mod('openvswitch').with_ensure('present') }
end
end
end

View File

@ -1 +1 @@
include ::l23network::params

View File

@ -2,8 +2,17 @@ notice('MODULAR: netconfig.pp')
$network_scheme = hiera('network_scheme')
if ( $::l23_os =~ /(?i:centos6)/ and $::kernelmajversion == '3.10' ) {
$ovs_datapath_package_name = 'kmod-openvswitch-lt'
}
class { 'l23network' :
use_ovs => hiera('use_neutron', false)
use_ovs => hiera('use_neutron', false),
use_ovs_dkms_datapath_module => $::l23_os ? {
/(?i:redhat7|centos7)/ => false,
default => true
},
ovs_datapath_package_name => $ovs_datapath_package_name,
}
prepare_network_config($network_scheme)
$sdn = generate_network_config()