Merge "Install and configure OVSDPDK"
This commit is contained in:
commit
b3a60ac924
|
@ -0,0 +1,51 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -z "${IF_OVS_TYPE}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ovs_vsctl() {
|
||||
ovs-vsctl --timeout=5 "$@"
|
||||
}
|
||||
|
||||
if (ovs_vsctl --version) > /dev/null 2>&1; then :; else
|
||||
exit 0
|
||||
fi
|
||||
|
||||
SERVICE_UNIT=/usr/lib/systemd/system/openvswitch-nonetwork.service
|
||||
if [ -f $SERVICE_UNIT ] && [ -x /usr/bin/systemctl ]; then
|
||||
if ! systemctl --quiet is-active openvswitch-nonetwork.service; then
|
||||
systemctl start openvswitch-nonetwork.service
|
||||
fi
|
||||
else
|
||||
if service openvswitch-switch status > /dev/null 2>&1; then
|
||||
service openvswitch-switch start
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${MODE}" = "start" ]; then
|
||||
eval OVS_EXTRA=\"${IF_OVS_EXTRA}\"
|
||||
|
||||
case "${IF_OVS_TYPE}" in
|
||||
DPDKOVSPort)
|
||||
ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
|
||||
"${IF_DPDK_PORT}" ${IF_OVS_OPTIONS} \
|
||||
-- set Interface "${IF_DPDK_PORT}" type=dpdk \
|
||||
${OVS_EXTRA+-- $OVS_EXTRA}
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
elif [ "${MODE}" = "stop" ]; then
|
||||
case "${IF_OVS_TYPE}" in
|
||||
DPDKOVSPort)
|
||||
ovs_vsctl -- --if-exists del-port "${IF_OVS_BRIDGE}" "${IF_DPDK_PORT}"
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -0,0 +1 @@
|
|||
NR_2M_PAGES=0
|
|
@ -0,0 +1,29 @@
|
|||
require 'puppetx/l23_network_scheme'
|
||||
|
||||
Puppet::Parser::Functions::newfunction(:get_dpdk_interfaces, :type => :rvalue, :doc => <<-EOS
|
||||
This function gets list of interfaces and port transformations and
|
||||
returns bus_info addresses and intended drivers for dpdk transformations.
|
||||
ex: get_dpdk_interfaces() => [["0000:01:00.0", "igb_uio"]]
|
||||
EOS
|
||||
) do |args|
|
||||
dpdk_interfaces = {}
|
||||
|
||||
cfg = L23network::Scheme.get_config(lookupvar('l3_fqdn_hostname'))
|
||||
return [] unless cfg
|
||||
|
||||
interfaces = cfg[:interfaces]
|
||||
cfg[:transformations].each do |transform|
|
||||
next unless transform[:name] ||\
|
||||
transform[:provider].to_s.upcase == "DPDKOVS" ||\
|
||||
transform[:action] == "add-port"
|
||||
|
||||
if_name = transform[:name].to_sym
|
||||
bus_info = interfaces[if_name][:vendor_specific][:bus_info] if interfaces.has_key?(if_name)
|
||||
dpdk_driver = transform[:vendor_specific][:dpdk_driver] if transform[:vendor_specific]
|
||||
dpdk_interfaces[bus_info] = dpdk_driver if bus_info and dpdk_driver
|
||||
end
|
||||
|
||||
dpdk_interfaces.sort
|
||||
end
|
||||
|
||||
# vim: set ts=2 sw=2 et :
|
|
@ -51,8 +51,6 @@ Puppet::Type.type(:l23_stored_config).provide(:dpdkovs_ubuntu, :parent => Puppet
|
|||
header << self.puppet_header
|
||||
header << "allow-#{bridge} #{provider.name}"
|
||||
header << "iface #{provider.name} inet #{provider.method}"
|
||||
header << "pre-up ovs-vsctl --may-exist add-port ${IF_OVS_BRIDGE} ${IF_DPDK_PORT} -- ${IF_OVS_EXTRA}"
|
||||
header << "ovs_extra set Interface #{dpdk_port} type=dpdk"
|
||||
return header, props
|
||||
end
|
||||
|
||||
|
|
|
@ -23,8 +23,11 @@ Puppet::Type.type(:l2_bridge).provide(:ovs, :parent => Puppet::Provider::Ovs_bas
|
|||
debug("CREATE resource: #{@resource}")
|
||||
@old_property_hash = {}
|
||||
@property_flush = {}.merge! @resource
|
||||
#
|
||||
vsctl('add-br', @resource[:bridge])
|
||||
vendor_specific = @resource[:vendor_specific] || {}
|
||||
datapath_type = vendor_specific["datapath_type"]
|
||||
cmd = ['add-br', @resource[:bridge]]
|
||||
cmd += ['--', 'set', 'Bridge', @resource[:bridge], "datapath_type=#{datapath_type}"] if datapath_type
|
||||
vsctl(cmd)
|
||||
self.class.interface_up(@resource[:bridge])
|
||||
notice("bridge '#{@resource[:bridge]}' created.")
|
||||
end
|
||||
|
@ -52,10 +55,6 @@ Puppet::Type.type(:l2_bridge).provide(:ovs, :parent => Puppet::Provider::Ovs_bas
|
|||
end
|
||||
end
|
||||
end
|
||||
vs = (@property_flush[:vendor_specific] || {})
|
||||
if vs.has_key? "datapath_type"
|
||||
vsctl('set', 'Bridge', @resource[:bridge], "datapath_type=#{vs["datapath_type"]}")
|
||||
end
|
||||
#
|
||||
@property_hash = resource.to_hash
|
||||
end
|
||||
|
@ -85,9 +84,7 @@ Puppet::Type.type(:l2_bridge).provide(:ovs, :parent => Puppet::Provider::Ovs_bas
|
|||
end
|
||||
def vendor_specific=(val)
|
||||
old = @property_hash[:vendor_specific] || {}
|
||||
# we're prefetching properties as hashes w/ keys as symbols, and set props as hashes w/ keys as strings
|
||||
# so here is normalization
|
||||
@property_flush[:vendor_specific] = Hash[val.map{|(k,v)| [k,v] if old[k.to_sym] != v }]
|
||||
@property_flush[:vendor_specific] = val.reject{|(k,v)| old[k.to_sym] == v }
|
||||
end
|
||||
|
||||
def stp
|
||||
|
|
|
@ -41,6 +41,7 @@ Puppet::Type.type(:l2_port).provide(:dpdkovs, :parent => Puppet::Provider::Ovs_b
|
|||
end
|
||||
|
||||
def destroy
|
||||
debug("DESTROY resource: #{@resource}")
|
||||
vsctl("del-port", @resource[:bridge], @resource[:vendor_specific]['dpdk_port'])
|
||||
end
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ Puppet::Type.type(:l2_port).provide(:ovs, :parent => Puppet::Provider::Ovs_base)
|
|||
end
|
||||
|
||||
def destroy
|
||||
debug("DESTROY resource: #{@resource}")
|
||||
vsctl("del-port", @resource[:bridge], @resource[:interface])
|
||||
end
|
||||
|
||||
|
|
|
@ -47,8 +47,10 @@ class l23network (
|
|||
$ensure_package = 'present',
|
||||
$use_lnx = true,
|
||||
$use_ovs = false,
|
||||
$use_dpdk = false,
|
||||
$install_ovs = $use_ovs,
|
||||
$install_brtool = $use_lnx,
|
||||
$install_dpdk = $use_dpdk,
|
||||
$modprobe_bridge = $use_lnx,
|
||||
$install_bondtool = $use_lnx,
|
||||
$modprobe_bonding = $use_lnx,
|
||||
|
@ -61,6 +63,7 @@ class l23network (
|
|||
$ovs_common_package_name = undef,
|
||||
$disable_hotplug = true,
|
||||
$network_manager = false,
|
||||
$dpdk_options = {},
|
||||
){
|
||||
|
||||
include ::stdlib
|
||||
|
@ -70,8 +73,10 @@ class l23network (
|
|||
ensure_package => $ensure_package,
|
||||
use_ovs => $use_ovs,
|
||||
use_lnx => $use_lnx,
|
||||
use_dpdk => $use_dpdk,
|
||||
install_ovs => $install_ovs,
|
||||
install_brtool => $install_brtool,
|
||||
install_dpdk => $install_dpdk,
|
||||
modprobe_bridge => $modprobe_bridge,
|
||||
install_bondtool => $install_bondtool,
|
||||
modprobe_bonding => $modprobe_bonding,
|
||||
|
@ -82,6 +87,7 @@ class l23network (
|
|||
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,
|
||||
dpdk_options => $dpdk_options,
|
||||
}
|
||||
|
||||
if $::l23network::params::interfaces_file {
|
||||
|
|
|
@ -25,8 +25,10 @@ class l23network::l2 (
|
|||
$ensure_package = 'present',
|
||||
$use_lnx = true,
|
||||
$use_ovs = false,
|
||||
$use_dpdk = false,
|
||||
$install_ovs = $use_ovs,
|
||||
$install_brtool = $use_lnx,
|
||||
$install_dpdk = $use_dpdk,
|
||||
$modprobe_bridge = $use_lnx,
|
||||
$install_bondtool = $use_lnx,
|
||||
$modprobe_bonding = $use_lnx,
|
||||
|
@ -37,6 +39,7 @@ class l23network::l2 (
|
|||
$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,
|
||||
$dpdk_options = {},
|
||||
){
|
||||
|
||||
include ::stdlib
|
||||
|
@ -63,6 +66,16 @@ class l23network::l2 (
|
|||
Package<| title=='openvswitch-datapath' |> -> Package<| title=='openvswitch-common' |>
|
||||
}
|
||||
|
||||
class { '::l23network::l2::dpdk':
|
||||
use_dpdk => $use_dpdk,
|
||||
install_dpdk => $install_dpdk,
|
||||
ovs_core_mask => $dpdk_options['ovs_core_mask'],
|
||||
ovs_pmd_core_mask => $dpdk_options['ovs_pmd_core_mask'],
|
||||
ovs_socket_mem => $dpdk_options['ovs_socket_mem'],
|
||||
install_ovs => $install_ovs,
|
||||
ensure_package => $ensure_package,
|
||||
} -> Anchor['l23network::l2::init']
|
||||
|
||||
service {'openvswitch-service':
|
||||
ensure => 'running',
|
||||
name => $::l23network::params::ovs_service_name,
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
# == Class: l23network::l2::dpdk
|
||||
#
|
||||
# Module for configuring DPDK-enabled OVS and interfaces.
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*use_dpdk*]
|
||||
# Initialize DPDK or not
|
||||
# Defaults to false
|
||||
# [*install_dpdk*]
|
||||
# Install DPDK packages or not
|
||||
# Defaults to $use_dpdk
|
||||
# [*ovs_core_mask*]
|
||||
# (optional) OpenVSwitch cpu core mask in hexa format
|
||||
# Defaults to 0x1
|
||||
# [*ovs_pmd_core_mask*]
|
||||
# (optional) OpenVSwitch core mask in hexa format for PMD threads
|
||||
# Defaults to undef
|
||||
# [*ovs_socket_mem*]
|
||||
# (optional) List of amounts of memory to allocate per NUMA node
|
||||
# Defaults to '128'
|
||||
# [*ovs_memory_channels*]
|
||||
# (optional) Number of memory channels in CPU
|
||||
# Defaults to '2'
|
||||
#
|
||||
class l23network::l2::dpdk (
|
||||
$use_dpdk = false,
|
||||
$install_dpdk = $use_dpdk,
|
||||
$ovs_core_mask = $::l23network::params::ovs_core_mask,
|
||||
$ovs_pmd_core_mask = undef,
|
||||
$ovs_socket_mem = $::l23network::params::ovs_socket_mem,
|
||||
$ovs_memory_channels = $::l23network::params::ovs_memory_channels,
|
||||
$ovs_dpdk_package_name = $::l23network::params::ovs_dpdk_package_name,
|
||||
$ovs_dpdk_dkms_package_name = $::l23network::params::ovs_dpdk_dkms_package_name,
|
||||
$dpdk_dir = $::l23network::params::dpdk_dir,
|
||||
$dpdk_conf_file = $::l23network::params::dpdk_conf_file,
|
||||
$dpdk_interfaces_file = $::l23network::params::dpdk_interfaces_file,
|
||||
$ovs_socket_dir_group = $::l23network::params::ovs_socket_dir_group,
|
||||
$ovs_socket_dir = $::l23network::params::ovs_socket_dir,
|
||||
$ovs_default_file = $::l23network::params::ovs_default_file,
|
||||
$install_ovs = true,
|
||||
$ensure_package = 'present',
|
||||
){
|
||||
include ::stdlib
|
||||
include ::l23network::params
|
||||
|
||||
if $use_dpdk {
|
||||
|
||||
# Configure DPDK interfaces
|
||||
if $dpdk_dir and $dpdk_conf_file and $dpdk_interfaces_file {
|
||||
$dpdk_interfaces = get_dpdk_interfaces()
|
||||
|
||||
file {$dpdk_dir:
|
||||
ensure => directory,
|
||||
} ->
|
||||
file {$dpdk_conf_file:
|
||||
ensure => present,
|
||||
source => 'puppet:///modules/l23network/dpdk.conf',
|
||||
} ->
|
||||
file {$dpdk_interfaces_file:
|
||||
ensure => present,
|
||||
content => template('l23network/dpdk_interfaces.erb'),
|
||||
}
|
||||
File[$dpdk_interfaces_file] ~> Service['dpdk']
|
||||
File[$dpdk_interfaces_file] ~> Service['openvswitch-service']
|
||||
|
||||
if $ovs_default_file {
|
||||
File[$dpdk_interfaces_file] -> File[$ovs_default_file]
|
||||
}
|
||||
} else {
|
||||
warning('DPDK was not configured')
|
||||
}
|
||||
|
||||
# Install DPDK modules
|
||||
if $install_dpdk and $ovs_dpdk_dkms_package_name {
|
||||
package {'dpdk-dkms':
|
||||
ensure => $ensure_package,
|
||||
name => $ovs_dpdk_dkms_package_name,
|
||||
}
|
||||
Package['dpdk-dkms'] -> Service['dpdk']
|
||||
} else {
|
||||
warning('DPDK kernel module was not installed')
|
||||
}
|
||||
|
||||
# Bind DPDK (it's safe to start it)
|
||||
service {'dpdk':
|
||||
ensure => 'running',
|
||||
name => 'dpdk',
|
||||
enable => true,
|
||||
hasstatus => true,
|
||||
} -> Anchor['l23network::l2::dpdk']
|
||||
|
||||
# Configure OpenVSwitch to use DPDK
|
||||
if $ovs_default_file {
|
||||
file {$ovs_default_file:
|
||||
ensure => present,
|
||||
content => template('l23network/openvswitch_default_Debian.erb'),
|
||||
} ~> Service['openvswitch-service']
|
||||
}
|
||||
|
||||
# Install DPDK-enabled OpenVSwitch
|
||||
if $install_dpdk and $install_ovs and $ovs_dpdk_package_name {
|
||||
package {'openvswitch-dpdk':
|
||||
ensure => $ensure_package,
|
||||
name => $ovs_dpdk_package_name,
|
||||
} ~> Service['openvswitch-service']
|
||||
|
||||
if $ovs_default_file {
|
||||
Package['openvswitch-dpdk'] -> File[$ovs_default_file]
|
||||
}
|
||||
} else {
|
||||
warning('OpenVSwitch DPDK was not installed')
|
||||
}
|
||||
|
||||
# Configure OVS DPDK PMD in runtime (it's safe to re-set it)
|
||||
if $ovs_pmd_core_mask {
|
||||
$ovs_pmd_core_mask_cmd = "ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=${$ovs_pmd_core_mask}"
|
||||
} else {
|
||||
$ovs_pmd_core_mask_cmd = 'ovs-vsctl remove Open_vSwitch . other_config pmd-cpu-mask'
|
||||
}
|
||||
exec { 'ovs_pmd_core_mask':
|
||||
command => $ovs_pmd_core_mask_cmd,
|
||||
path => '/bin:/usr/bin:/usr/local/bin',
|
||||
require => Service['openvswitch-service'],
|
||||
} -> Anchor['l23network::l2::dpdk']
|
||||
|
||||
# Install ifupdown scripts
|
||||
if $::l23_os =~ /(?i)ubuntu/ {
|
||||
file {'/etc/network/if-pre-up.d/ovsdpdk':
|
||||
ensure => present,
|
||||
owner => 'root',
|
||||
mode => '0755',
|
||||
source => 'puppet:///modules/l23network/debian_ovsdpdk',
|
||||
} ->
|
||||
file {'/etc/network/if-post-down.d/ovsdpdk':
|
||||
ensure => present,
|
||||
owner => 'root',
|
||||
mode => '0755',
|
||||
source => 'puppet:///modules/l23network/debian_ovsdpdk',
|
||||
} -> Anchor['l23network::l2::dpdk']
|
||||
}
|
||||
|
||||
anchor { 'l23network::l2::dpdk': }
|
||||
}
|
||||
}
|
|
@ -5,47 +5,81 @@ class l23network::params {
|
|||
|
||||
case $::l23_os {
|
||||
/(?i)ubuntu/: {
|
||||
$interfaces_dir = '/etc/network/interfaces.d'
|
||||
$interfaces_file = '/etc/network/interfaces'
|
||||
$ovs_service_name = 'openvswitch-switch'
|
||||
$ovs_status_cmd = '/etc/init.d/openvswitch-switch status'
|
||||
$lnx_vlan_tools = 'vlan'
|
||||
$lnx_bond_tools = 'ifenslave'
|
||||
$lnx_ethernet_tools = 'ethtool'
|
||||
$lnx_bridge_tools = 'bridge-utils'
|
||||
$ovs_datapath_package_name = 'openvswitch-datapath-dkms'
|
||||
$ovs_common_package_name = 'openvswitch-switch'
|
||||
$ovs_kern_module_name = 'openvswitch'
|
||||
$network_manager_name = 'network-manager'
|
||||
$extra_tools = 'iputils-arping'
|
||||
$interfaces_dir = '/etc/network/interfaces.d'
|
||||
$interfaces_file = '/etc/network/interfaces'
|
||||
$ovs_service_name = 'openvswitch-switch'
|
||||
$ovs_status_cmd = '/etc/init.d/openvswitch-switch status'
|
||||
$ovs_default_file = '/etc/default/openvswitch-switch'
|
||||
$lnx_vlan_tools = 'vlan'
|
||||
$lnx_bond_tools = 'ifenslave'
|
||||
$lnx_ethernet_tools = 'ethtool'
|
||||
$lnx_bridge_tools = 'bridge-utils'
|
||||
$ovs_datapath_package_name = 'openvswitch-datapath-dkms'
|
||||
$ovs_common_package_name = 'openvswitch-switch'
|
||||
$ovs_dpdk_package_name = 'openvswitch-switch-dpdk'
|
||||
$ovs_dpdk_dkms_package_name = 'dpdk-dkms'
|
||||
$dpdk_dir = '/etc/dpdk'
|
||||
$dpdk_conf_file = '/etc/dpdk/dpdk.conf'
|
||||
$dpdk_interfaces_file = '/etc/dpdk/interfaces'
|
||||
$ovs_socket_dir_group = 'libvirt-qemu'
|
||||
$ovs_socket_dir = '/var/run/openvswitch'
|
||||
$ovs_kern_module_name = 'openvswitch'
|
||||
$network_manager_name = 'network-manager'
|
||||
$extra_tools = 'iputils-arping'
|
||||
$ovs_core_mask = 0x1
|
||||
$ovs_socket_mem = 256
|
||||
$ovs_memory_channels = 2
|
||||
}
|
||||
/(?i)redhat|centos/: {
|
||||
$interfaces_dir = '/etc/sysconfig/network-scripts'
|
||||
$interfaces_file = undef
|
||||
$ovs_service_name = 'openvswitch'
|
||||
$ovs_status_cmd = '/etc/init.d/openvswitch status'
|
||||
$lnx_vlan_tools = undef
|
||||
$lnx_bond_tools = undef
|
||||
$lnx_ethernet_tools = 'ethtool'
|
||||
$lnx_bridge_tools = 'bridge-utils'
|
||||
$ovs_datapath_package_name = 'kmod-openvswitch'
|
||||
$ovs_common_package_name = 'openvswitch'
|
||||
$ovs_kern_module_name = 'openvswitch'
|
||||
$network_manager_name = 'NetworkManager'
|
||||
$extra_tools = 'iputils'
|
||||
$interfaces_dir = '/etc/sysconfig/network-scripts'
|
||||
$interfaces_file = undef
|
||||
$ovs_service_name = 'openvswitch'
|
||||
$ovs_status_cmd = '/etc/init.d/openvswitch status'
|
||||
$ovs_default_file = undef
|
||||
$lnx_vlan_tools = undef
|
||||
$lnx_bond_tools = undef
|
||||
$lnx_ethernet_tools = 'ethtool'
|
||||
$lnx_bridge_tools = 'bridge-utils'
|
||||
$ovs_dpdk_package_name = undef
|
||||
$ovs_dpdk_dkms_package_name = undef
|
||||
$dpdk_dir = undef
|
||||
$dpdk_conf_file = undef
|
||||
$dpdk_interfaces_file = undef
|
||||
$ovs_socket_dir_group = undef
|
||||
$ovs_socket_dir = undef
|
||||
$ovs_datapath_package_name = 'kmod-openvswitch'
|
||||
$ovs_common_package_name = 'openvswitch'
|
||||
$ovs_kern_module_name = 'openvswitch'
|
||||
$network_manager_name = 'NetworkManager'
|
||||
$extra_tools = 'iputils'
|
||||
$ovs_core_mask = 0x1
|
||||
$ovs_socket_mem = 256
|
||||
$ovs_memory_channels = 2
|
||||
|
||||
}
|
||||
/(?i)darwin/: {
|
||||
$interfaces_dir = '/tmp/1'
|
||||
$interfaces_file = undef
|
||||
$ovs_service_name = undef
|
||||
$lnx_vlan_tools = undef
|
||||
$lnx_bond_tools = undef
|
||||
$lnx_ethernet_tools = undef
|
||||
$lnx_bridge_tools = undef
|
||||
$ovs_datapath_package_name = undef
|
||||
$ovs_common_package_name = undef
|
||||
$ovs_kern_module_name = undef
|
||||
$network_manager_name = undef
|
||||
$interfaces_dir = '/tmp/1'
|
||||
$interfaces_file = undef
|
||||
$ovs_service_name = undef
|
||||
$ovs_default_file = undef
|
||||
$lnx_vlan_tools = undef
|
||||
$lnx_bond_tools = undef
|
||||
$lnx_ethernet_tools = undef
|
||||
$lnx_bridge_tools = undef
|
||||
$ovs_dpdk_package_name = undef
|
||||
$ovs_dpdk_dkms_package_name = undef
|
||||
$dpdk_dir = undef
|
||||
$dpdk_conf_file = undef
|
||||
$dpdk_interfaces_file = undef
|
||||
$ovs_socket_dir_group = undef
|
||||
$ovs_socket_dir = undef
|
||||
$ovs_datapath_package_name = undef
|
||||
$ovs_common_package_name = undef
|
||||
$ovs_kern_module_name = undef
|
||||
$network_manager_name = undef
|
||||
$ovs_core_mask = undef
|
||||
$ovs_socket_mem = undef
|
||||
$ovs_memory_channels = undef
|
||||
}
|
||||
default: {
|
||||
fail("Unsupported OS: ${l23_os}/${::operatingsystem}")
|
||||
|
|
|
@ -30,8 +30,12 @@ describe 'l23network::l2' do
|
|||
|
||||
it { should_not contain_package('openvswitch-common').with_name('openvswitch') }
|
||||
|
||||
it { should_not contain_package('openvswitch-dpdk') }
|
||||
|
||||
it { should_not contain_service('openvswitch-service') }
|
||||
|
||||
it { should_not contain_service('dpdk') }
|
||||
|
||||
it { should_not contain_k_mod('openvswitch').with_ensure('present') }
|
||||
|
||||
it { should contain_k_mod('bonding') }
|
||||
|
@ -173,8 +177,12 @@ describe 'l23network::l2' do
|
|||
|
||||
it { should_not contain_package('openvswitch-common') }
|
||||
|
||||
it { should_not contain_package('openvswitch-dpdk').with_name('openvswitch-switch-dpdk') }
|
||||
|
||||
it { should_not contain_service('openvswitch-service') }
|
||||
|
||||
it { should_not contain_service('dpdk') }
|
||||
|
||||
it { should_not contain_k_mod('openvswitch').with_ensure('present') }
|
||||
|
||||
it { should contain_k_mod('bonding') }
|
||||
|
@ -224,6 +232,7 @@ describe 'l23network::l2' do
|
|||
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') }
|
||||
|
@ -255,6 +264,43 @@ describe 'l23network::l2' do
|
|||
|
||||
end
|
||||
|
||||
context 'use_ovs, use_dpdk with default parameters' do
|
||||
|
||||
let :params do
|
||||
{ :ensure_package => 'present',
|
||||
:use_lnx => true,
|
||||
:use_ovs => true,
|
||||
:use_dpdk => 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_package('dpdk-dkms').with_name('dpdk-dkms') }
|
||||
it { should contain_package('dpdk-dkms').that_comes_before('Service[dpdk]') }
|
||||
|
||||
it { should contain_file('/etc/dpdk/interfaces').that_comes_before('File[/etc/default/openvswitch-switch]') }
|
||||
it { should contain_file('/etc/dpdk/interfaces').that_notifies('Service[dpdk]') }
|
||||
it { should contain_file('/etc/dpdk/interfaces').that_notifies('Service[openvswitch-service]') }
|
||||
|
||||
it { should contain_package('openvswitch-dpdk').with_name('openvswitch-switch-dpdk') }
|
||||
it { should contain_package('openvswitch-dpdk').that_notifies('Service[openvswitch-service]') }
|
||||
it { should contain_package('openvswitch-dpdk').that_comes_before('File[/etc/default/openvswitch-switch]') }
|
||||
|
||||
it { should contain_file('/etc/default/openvswitch-switch').that_notifies('Service[openvswitch-service]') }
|
||||
|
||||
it { should contain_service('openvswitch-service') }
|
||||
|
||||
it { should contain_k_mod('openvswitch').with_ensure('present') }
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
allow-br-prv enp1s0f0
|
||||
iface enp1s0f0 inet manual
|
||||
pre-up ovs-vsctl --may-exist add-port "${IF_OVS_BRIDGE}" "${IF_DPDK_PORT}" -- ${IF_OVS_EXTRA}
|
||||
ovs_extra set Interface dpdk0 type=dpdk
|
||||
ovs_type DPDKOVSPort
|
||||
dpdk_port dpdk0
|
||||
ovs_bridge br-prv
|
|
@ -0,0 +1,62 @@
|
|||
require 'spec_helper'
|
||||
require 'yaml'
|
||||
require 'puppetx/l23_hash_tools'
|
||||
|
||||
describe Puppet::Parser::Functions.function(:get_dpdk_interfaces) do
|
||||
let(:network_scheme) do
|
||||
<<eof
|
||||
---
|
||||
version: 1.1
|
||||
provider: lnx
|
||||
interfaces:
|
||||
enp2s0f0:
|
||||
vendor_specific:
|
||||
driver: tg3
|
||||
bus_info: "0000:02:00.0"
|
||||
enp1s0f1:
|
||||
vendor_specific:
|
||||
driver: ixgbe
|
||||
bus_info: "0000:01:00.1"
|
||||
enp1s0f0:
|
||||
vendor_specific:
|
||||
driver: ixgbe
|
||||
bus_info: "0000:01:00.0"
|
||||
eno1:
|
||||
vendor_specific:
|
||||
driver: tg3
|
||||
bus_info: "0000:02:00.1"
|
||||
transformations:
|
||||
- bridge: br-prv
|
||||
name: enp1s0f0
|
||||
action: add-port
|
||||
provider: dpdkovs
|
||||
vendor_specific:
|
||||
dpdk_driver: igb_uio
|
||||
eof
|
||||
end
|
||||
|
||||
let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
|
||||
|
||||
subject do
|
||||
function_name = Puppet::Parser::Functions.function(:get_dpdk_interfaces)
|
||||
scope.method(function_name)
|
||||
end
|
||||
|
||||
context "get_dpdk_interfaces() usage" do
|
||||
before(:each) do
|
||||
scope.stubs(:lookupvar).with('l3_fqdn_hostname').returns('node1.tld')
|
||||
L23network::Scheme.set_config(
|
||||
scope.lookupvar('l3_fqdn_hostname'),
|
||||
L23network.sanitize_keys_in_hash(YAML.load(network_scheme))
|
||||
)
|
||||
end
|
||||
|
||||
it 'should exist' do
|
||||
subject == Puppet::Parser::Functions.function(:get_transformation_property)
|
||||
end
|
||||
|
||||
it 'should return dpdk driver list' do
|
||||
should run.with_params().and_return([["0000:01:00.0", "igb_uio"]])
|
||||
end
|
||||
end
|
||||
end
|
|
@ -80,8 +80,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
|
|||
it { expect(cfg_file).to match(/ovs_type\s+DPDKOVSPort/) }
|
||||
it { expect(cfg_file).to match(/ovs_bridge\s+br-prv/) }
|
||||
it { expect(cfg_file).to match(/dpdk_port\s+dpdk0/) }
|
||||
it { expect(cfg_file).to match(/ovs_extra\s+set\s+Interface\s+dpdk0\s+type=dpdk/) }
|
||||
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(7) }
|
||||
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(5) }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ describe Puppet::Type.type(:l2_patch).provider(:ovs) do
|
|||
puppet_debug_override()
|
||||
provider_br1.class.stubs(:iproute)
|
||||
provider_br2.class.stubs(:iproute)
|
||||
provider_br1.class.stubs(:vsctl).with('add-br', 'br1').returns(true)
|
||||
provider_br2.class.stubs(:vsctl).with('add-br', 'br2').returns(true)
|
||||
provider_br1.class.stubs(:vsctl).with(['add-br', 'br1']).returns(true)
|
||||
provider_br2.class.stubs(:vsctl).with(['add-br', 'br2']).returns(true)
|
||||
provider_patch.class.stubs(:vsctl).with([
|
||||
'--may-exist', 'add-port', 'br1', 'p_39a440c1-0', '--', 'set', 'Interface', 'p_39a440c1-0', 'type=patch', 'option:peer=p_39a440c1-1'
|
||||
]).returns(true)
|
||||
|
@ -80,7 +80,7 @@ describe Puppet::Type.type(:l2_patch).provider(:ovs) do
|
|||
Puppet::Util::Log.newdestination(:console)
|
||||
end
|
||||
provider_br1.class.stubs(:iproute)
|
||||
provider_br1.class.stubs(:vsctl).with('add-br', 'br1').returns(true)
|
||||
provider_br1.class.stubs(:vsctl).with(['add-br', 'br1']).returns(true)
|
||||
provider_br2.class.stubs(:iproute).with().returns(true)
|
||||
provider_br2.class.stubs(:iproute).with('link', 'set', 'up', 'dev', 'br2').returns(true)
|
||||
provider_br2.stubs(:brctl).with(['addbr', 'br2']).returns(true)
|
||||
|
|
|
@ -40,9 +40,8 @@ describe Puppet::Type.type(:l2_port).provider(:dpdkovs) do
|
|||
describe "ovs port" do
|
||||
before(:each) do
|
||||
puppet_debug_override()
|
||||
provider_br1.class.stubs(:vsctl).with('add-br', 'br1').returns(true)
|
||||
provider_br1.class.stubs(:vsctl).with(['add-br', 'br1', '--', 'set', 'Bridge', 'br1', 'datapath_type=netdev']).returns(true)
|
||||
provider_br1.class.stubs(:vsctl).with('set', 'Bridge', 'br1', 'stp_enable=false').returns(true)
|
||||
provider_br1.class.stubs(:vsctl).with('set', 'Bridge', 'br1', 'datapath_type=netdev').returns(true)
|
||||
provider_br1.class.stubs(:interface_up).with('br1').returns(true)
|
||||
end
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ describe Puppet::Type.type(:l2_port).provider(:ovs) do
|
|||
|
||||
before(:each) do
|
||||
puppet_debug_override()
|
||||
provider_br1.class.stubs(:vsctl).with('add-br', 'br1').returns(true)
|
||||
provider_br1.class.stubs(:vsctl).with(['add-br', 'br1']).returns(true)
|
||||
provider_br1.class.stubs(:interface_up).with('br1').returns(true)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<%- @dpdk_interfaces.each do |bus_info, driver| -%>
|
||||
pci <%= bus_info %> <%= driver %>
|
||||
<%- end -%>
|
|
@ -0,0 +1,13 @@
|
|||
/etc/init.d/dpdk start
|
||||
|
||||
export DPDK_OPTS="--dpdk <% if @ovs_socket_dir %>-vhost_sock_dir <%= @ovs_socket_dir %> <% end %>-c <%= @ovs_core_mask %> -n <%= @ovs_memory_channels %> --socket-mem <%= @ovs_socket_mem %>"
|
||||
|
||||
<% if @ovs_socket_dir -%>
|
||||
# LP 1546565
|
||||
umask 0002
|
||||
mkdir -p "<%= @ovs_socket_dir %>"
|
||||
<% if @ovs_socket_dir_group -%>
|
||||
chgrp "<%= @ovs_socket_dir_group %>" "<%= @ovs_socket_dir %>" || true
|
||||
<% end -%>
|
||||
chmod g+s "<%= @ovs_socket_dir %>"
|
||||
<% end -%>
|
|
@ -1,11 +1,14 @@
|
|||
notice('MODULAR: netconfig.pp')
|
||||
|
||||
$network_scheme = hiera_hash('network_scheme', {})
|
||||
prepare_network_config($network_scheme)
|
||||
|
||||
if ( $::l23_os =~ /(?i:centos6)/ and $::kernelmajversion == '3.10' ) {
|
||||
$ovs_datapath_package_name = 'kmod-openvswitch-lt'
|
||||
}
|
||||
|
||||
$dpdk_options = hiera_hash('dpdk', {})
|
||||
|
||||
class { 'l23network' :
|
||||
use_ovs => hiera('use_ovs', false),
|
||||
use_ovs_dkms_datapath_module => $::l23_os ? {
|
||||
|
@ -13,8 +16,9 @@ class { 'l23network' :
|
|||
default => true
|
||||
},
|
||||
ovs_datapath_package_name => $ovs_datapath_package_name,
|
||||
use_dpdk => pick($dpdk_options['enabled'], false),
|
||||
dpdk_options => $dpdk_options,
|
||||
}
|
||||
prepare_network_config($network_scheme)
|
||||
$sdn = generate_network_config()
|
||||
notify {'SDN': message => $sdn }
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ describe manifest do
|
|||
default_gateway = Noop.hiera 'default_gateway'
|
||||
set_xps = Noop.hiera 'set_xps', true
|
||||
set_rps = Noop.hiera 'set_rps', true
|
||||
dpdk_config = Noop.hiera_hash 'dpdk', {}
|
||||
enable_dpdk = dpdk_config.fetch 'enabled', false
|
||||
|
||||
it { should contain_class('l23network').with('use_ovs' => use_neutron) }
|
||||
it { should contain_sysctl__value('net.ipv4.conf.all.arp_accept').with('value' => '1') }
|
||||
|
@ -45,6 +47,15 @@ describe manifest do
|
|||
'exclude' => '/sys/class/net/lo/*',
|
||||
)}
|
||||
end
|
||||
if enable_dpdk
|
||||
it 'should set dpdk-specific options for OVS' do
|
||||
should contain_class('l23network::l2::dpdk').with('use_dpdk' => true)
|
||||
end
|
||||
else
|
||||
it 'should skip dpdk-specific options for OVS' do
|
||||
should contain_class('l23network::l2::dpdk').with('use_dpdk' => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test_ubuntu_and_centos manifest
|
||||
|
|
Loading…
Reference in New Issue