Puppet4 support: l23network modules

Related-Bug: 1586480

Change-Id: I03ed1dd15f248a27682fa6605116d4c01a268b50
This commit is contained in:
Dmitry Ilyin 2016-08-17 15:59:47 -05:00
parent 3abe37493d
commit 2a7697303b
15 changed files with 63 additions and 38 deletions

View File

@ -14,6 +14,7 @@ pkg
rdoc
spec/reports
spec/fixtures/modules
spec/fixtures/manifests
test/tmp
test/version_tmp
tmp

View File

@ -3,7 +3,7 @@ require 'yaml'
require 'forwardable'
require 'puppet/parser'
require 'puppet/parser/templatewrapper'
require 'puppet/resource/type_collection_helper'
require 'puppet/resource/type_collection'
require 'puppet/util/methodhelper'
require_relative '../../../puppetx/l23_utils'
require_relative '../../../puppetx/l23_network_scheme'

View File

@ -131,7 +131,14 @@ define l23network::l2::port (
# Merge offloading data with rings rx/tx
if is_hash($::netrings) {
$netrings_maximums = dig($::netrings, [$port_name, 'maximums'])
$port_netrings = $::netrings[$port_name]
if is_hash($port_netrings) and $port_netrings['maximums'] {
$netrings_maximums = $port_netrings['maximums']
} else {
$netrings_maximums = undef
}
if $netrings_maximums {
$ethtool_opts = deep_merge({ 'rings' => $netrings_maximums }, $ethtool)
} else {

View File

@ -23,7 +23,7 @@ network_scheme:
mtu: 9000
vendor_specific:
disable_offloading: true
emdpoints: {}
endpoints: {}
roles: {}
eof
end
@ -134,7 +134,7 @@ network_scheme:
vendor_specific:
disable_offloading: true
provider: ovs
emdpoints: {}
endpoints: {}
roles: {}
eof
end

View File

@ -2,6 +2,10 @@ require 'spec_helper'
describe 'l23network', :type => :class do
let(:pre_condition) do
class_pre_condition
end
context 'default init of l23network module(Ubuntu)' do
let(:facts) { {
:osfamily => 'Debian',

View File

@ -21,9 +21,9 @@ describe 'l23network::l3::ifconfig', :type => :define do
:ipaddr => 'dhcp'
} }
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
let(:rings) do
{

View File

@ -21,9 +21,9 @@ describe 'l23network::l3::ifconfig', :type => :define do
:ipaddr => 'none'
} }
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
let(:rings) do
{

View File

@ -9,9 +9,10 @@ describe 'l23network::l2::bond', :type => :define do
:l23_os => 'ubuntu',
:l3_fqdn_hostname => 'stupid_hostname',
} }
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
before(:each) do
puppet_debug_override()

View File

@ -9,9 +9,10 @@ describe 'l23network::l2::bridge', :type => :define do
:l23_os => 'ubuntu',
:l3_fqdn_hostname => 'stupid_hostname',
} }
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
before(:each) do
puppet_debug_override()

View File

@ -26,10 +26,9 @@ describe 'l23network::l2::patch', :type => :define do
get_provider_for.stubs(:call).with('L2_bridge', 'br2').returns('lnx')
end
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
context 'Just a patch between two bridges' do
let(:params) do
@ -186,10 +185,9 @@ describe 'l23network::l2::patch', :type => :define do
get_provider_for.stubs(:call).with('L2_bridge', 'br2').returns('ovs')
}
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
context 'Just a ovs2ovs patch between two bridges' do
let(:params) do

View File

@ -9,10 +9,10 @@ describe 'l23network::l2::port', :type => :define do
:l23_os => 'ubuntu',
:l3_fqdn_hostname => 'stupid_hostname',
} }
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
context 'Infiniband parent' do
let(:params) do

View File

@ -9,10 +9,10 @@ describe 'l23network::l2::port', :type => :define do
:l23_os => 'ubuntu',
:l3_fqdn_hostname => 'stupid_hostname',
} }
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
context 'Port without anythyng' do
let(:params) do

View File

@ -9,10 +9,10 @@ describe 'l23network::l2::port', :type => :define do
:l23_os => 'ubuntu',
:l3_fqdn_hostname => 'stupid_hostname',
} }
let(:pre_condition) { [
"class {'l23network': }"
] }
let(:pre_condition) do
definition_pre_condition
end
context 'Create SRIOV port' do
let(:params) do

View File

@ -1,5 +0,0 @@
#include ::l23network::params
# this is a workaround for run spec tests not only on Linux platform
Package <||> { provider => 'apt' }
###

View File

@ -27,3 +27,21 @@ def puppet_debug_override
Puppet::Util::Log.newdestination(:console)
end
end
def definition_pre_condition
<<-eof
class {'l23network': }
Package <||> {
provider => 'apt',
}
eof
end
def class_pre_condition
<<-eof
Package <||> {
provider => 'apt',
}
eof
end