OVS DPDK package support with basic options
Puppet changes requierd for supporting OVS DPDK packages. Basic DPDK_OPTIONS parameters are added (more to come). Implements: blueprint tripleo-ovs-dpdk Change-Id: I853517247f2892ad27cff179961d1498456d1cb5
This commit is contained in:
parent
a4b436b1aa
commit
f1c5e34409
67
manifests/dpdk.pp
Normal file
67
manifests/dpdk.pp
Normal file
@ -0,0 +1,67 @@
|
||||
#
|
||||
# Configure OVS to use DPDK
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*package_ensure*]
|
||||
# (Optional) State of the openvswitch package
|
||||
# Defaults to 'present'.
|
||||
#
|
||||
# [*core_list*]
|
||||
# (required) The list of cores to be used by the DPDK Poll Mode Driver
|
||||
# The core_list is a string with format as <c1>[-c2][,c3[-c4],...] where c1, c2, etc are core indexes between 0 and 128
|
||||
# For example, to configure 3 cores the value should be "0-2"
|
||||
#
|
||||
# [*memory_channels*]
|
||||
# (required) The number of memory channels to use as an integer
|
||||
#
|
||||
# [*socket_mem*]
|
||||
# (Optional) Set the memory to be allocated on each socket
|
||||
# The socket_mem is a string with comma separated memory list in MB in the order of socket numbers.
|
||||
# For example, to allocate memory of 1GB for socket 1 and no allocation for socket 0, the value should be "0,1024"
|
||||
# Defaults to undef.
|
||||
#
|
||||
class vswitch::dpdk (
|
||||
$core_list,
|
||||
$memory_channels,
|
||||
$package_ensure = 'present',
|
||||
$socket_mem = undef,
|
||||
) {
|
||||
|
||||
include ::vswitch::params
|
||||
|
||||
package { $::vswitch::params::ovs_dpdk_package_name:
|
||||
ensure => $package_ensure,
|
||||
before => Service['openvswitch'],
|
||||
tag => 'openvswitch',
|
||||
}
|
||||
|
||||
# Set DPDK_OPTIONS to openvswitch
|
||||
if $socket_mem {
|
||||
$socket_string = "--socket-mem ${socket_mem}"
|
||||
}
|
||||
|
||||
$options = "DPDK_OPTIONS = \"-l ${core_list} -n ${memory_channels} ${socket_string}\""
|
||||
|
||||
case $::osfamily {
|
||||
'Redhat': {
|
||||
file_line { '/etc/sysconfig/openvswitch':
|
||||
path => '/etc/sysconfig/openvswitch',
|
||||
match => '^DPDK_OPTIONS.*',
|
||||
line => $options,
|
||||
require => Package[$::vswitch::params::ovs_dpdk_package_name],
|
||||
before => Service['openvswitch']
|
||||
}
|
||||
|
||||
service { 'openvswitch':
|
||||
ensure => true,
|
||||
enable => true,
|
||||
name => $::vswitch::params::ovs_service_name,
|
||||
}
|
||||
}
|
||||
default: {
|
||||
fail( "${::osfamily} not yet supported for dpdk installation by puppet-vswitch")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -128,6 +128,7 @@ class vswitch::ovs(
|
||||
package { $::vswitch::params::ovs_package_name:
|
||||
ensure => $package_ensure,
|
||||
before => Service['openvswitch'],
|
||||
tag => 'openvswitch',
|
||||
}
|
||||
|
||||
Service['openvswitch'] -> Vs_port<||>
|
||||
|
@ -2,15 +2,24 @@
|
||||
#
|
||||
class vswitch::params {
|
||||
include ::openstacklib::defaults
|
||||
|
||||
if versioncmp($::puppetversion, '4.0.0') < 0 and versioncmp($::puppetversion, '3.6.1') >= 0 {
|
||||
Package<| tag == 'openvswitch' |> {
|
||||
allow_virtual => true,
|
||||
}
|
||||
}
|
||||
|
||||
case $::osfamily {
|
||||
'Redhat': {
|
||||
$ovs_package_name = 'openvswitch'
|
||||
$ovs_dpdk_package_name = 'openvswitch-dpdk'
|
||||
$ovs_dkms_package_name = undef
|
||||
$ovs_service_name = 'openvswitch'
|
||||
$provider = 'ovs_redhat'
|
||||
}
|
||||
'Debian': {
|
||||
$ovs_package_name = 'openvswitch-switch'
|
||||
$ovs_dpdk_package_name = 'openvswitch-switch-dpdk'
|
||||
$ovs_dkms_package_name = 'openvswitch-datapath-dkms'
|
||||
$ovs_service_name = 'openvswitch-switch'
|
||||
$provider = 'ovs'
|
||||
|
107
spec/classes/vswitch_dpdk_spec.rb
Normal file
107
spec/classes/vswitch_dpdk_spec.rb
Normal file
@ -0,0 +1,107 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'vswitch::dpdk' do
|
||||
|
||||
let :default_params do {
|
||||
:package_ensure => 'present',
|
||||
:core_list => '1,2',
|
||||
:memory_channels => '2'
|
||||
}
|
||||
end
|
||||
|
||||
let :socket_mem_params do {
|
||||
:package_ensure => 'present',
|
||||
:core_list => '1,2',
|
||||
:memory_channels => '2',
|
||||
:socket_mem => '1024'
|
||||
}
|
||||
end
|
||||
|
||||
let :redhat_platform_params do {
|
||||
:ovs_dpdk_package_name => 'openvswitch-dpdk',
|
||||
:ovs_service_name => 'openvswitch',
|
||||
:provider => 'ovs_redhat',
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples_for 'vswitch dpdk' do
|
||||
|
||||
it 'contains params' do
|
||||
is_expected.to contain_class('vswitch::params')
|
||||
end
|
||||
|
||||
it 'configures service' do
|
||||
is_expected.to contain_service('openvswitch').with(
|
||||
:ensure => true,
|
||||
:enable => true,
|
||||
:name => platform_params[:ovs_service_name],
|
||||
:hasstatus => platform_params[:service_hasstatus],
|
||||
:status => platform_params[:service_status],
|
||||
)
|
||||
end
|
||||
|
||||
it 'install package' do
|
||||
is_expected.to contain_package(platform_params[:ovs_dpdk_package_name]).with(
|
||||
:name => platform_params[:ovs_dpdk_package_name],
|
||||
:ensure => params[:package_ensure],
|
||||
:before => 'Service[openvswitch]',
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
shared_examples_for 'vswitch dpdk mandatory params' do
|
||||
it 'configures dpdk options for ovs' do
|
||||
is_expected.to contain_file_line('/etc/sysconfig/openvswitch').with(
|
||||
:path => '/etc/sysconfig/openvswitch',
|
||||
:match => '^DPDK_OPTIONS.*',
|
||||
:line => 'DPDK_OPTIONS = "-l 1,2 -n 2 "',
|
||||
:before => 'Service[openvswitch]',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for 'vswitch dpdk socket_mem param' do
|
||||
it 'configures dpdk options for ovs' do
|
||||
is_expected.to contain_file_line('/etc/sysconfig/openvswitch').with(
|
||||
:path => '/etc/sysconfig/openvswitch',
|
||||
:match => '^DPDK_OPTIONS.*',
|
||||
:line => 'DPDK_OPTIONS = "-l 1,2 -n 2 --socket-mem 1024"',
|
||||
:before => 'Service[openvswitch]',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'on redhat with only mandatory parameters' do
|
||||
let :params do default_params end
|
||||
|
||||
let :facts do
|
||||
OSDefaults.get_facts({
|
||||
:osfamily => 'Redhat',
|
||||
:ovs_version => '1.4.2',
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do redhat_platform_params end
|
||||
|
||||
it_configures 'vswitch dpdk'
|
||||
it_configures 'vswitch dpdk mandatory params'
|
||||
end
|
||||
|
||||
context 'on redhat with additonal parameters' do
|
||||
let :params do socket_mem_params end
|
||||
|
||||
let :facts do
|
||||
OSDefaults.get_facts({
|
||||
:osfamily => 'Redhat',
|
||||
:ovs_version => '1.4.2',
|
||||
})
|
||||
end
|
||||
|
||||
let :platform_params do redhat_platform_params end
|
||||
|
||||
it_configures 'vswitch dpdk'
|
||||
it_configures 'vswitch dpdk socket_mem param'
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user