Bond improvements

* Set correct default bond properties:
  - ad_select is only used for 802.3ad bond mode
  - Implement bond property *use_carrier*
  - updelay and downdelay values are connected with miimon value
* Fix idempotency for resource l2_bond:
  - Skip undef, absent and '' for bond_properties in type
  - Add to prefetching such bond_properties as ad_select, updelay and downdelay
    for lnx provider.

Change-Id: If66f312a7cfeb10c5e3a94ff90635d2671790286
Closes-bug: #1536246
This commit is contained in:
Stanislav Makar 2016-01-19 17:45:12 +00:00
parent 701629f046
commit fdfed817dd
16 changed files with 246 additions and 135 deletions

View File

@ -21,6 +21,7 @@ Puppet::Type.type(:l23_stored_config).provide(:ovs_ubuntu, :parent => Puppet::Pr
:bond_slaves => 'ovs_bonds',
:bond_mode => 'ovs_options',
:bond_miimon => 'ovs_options',
:bond_use_carrier => 'ovs_options',
:bond_lacp_rate => 'ovs_options',
:bond_lacp => 'ovs_options',
:bond_xmit_hash_policy => '', # unused
@ -59,6 +60,10 @@ Puppet::Type.type(:l23_stored_config).provide(:ovs_ubuntu, :parent => Puppet::Pr
:field => 'other_config:bond-miimon-interval',
:store_to => 'ovs_options'
},
:bond_use_carrier => {
:field => 'other_config:bond-detect-mode',
:store_to => 'ovs_options'
},
}
end
def oneline_properties
@ -154,6 +159,12 @@ Puppet::Type.type(:l23_stored_config).provide(:ovs_ubuntu, :parent => Puppet::Pr
rv << "ovs_extra -- set Port #{provider.name} tag=#{provider.vlan_id}"
end
def self.unmangle__bond_use_carrier(provider, data)
values = [ 'miimon', 'carrier' ]
rv = values[data.to_i] if data.to_i <= values.size
rv ||= nil
end
def self.mangle__jacks(data)
[data.join()]
end

View File

@ -40,6 +40,7 @@ class Puppet::Provider::L23_stored_config_centos < Puppet::Provider::L23_stored_
:slave => 'SLAVE',
:bond_mode => 'mode',
:bond_miimon => 'miimon',
:bond_use_carrier => 'use_carrier',
:bonding_opts => 'BONDING_OPTS',
:bond_lacp_rate => 'lacp_rate',
:bond_ad_select => 'ad_select',
@ -316,11 +317,11 @@ class Puppet::Provider::L23_stored_config_centos < Puppet::Provider::L23_stored_
# Do extra actions if ovs2lnx patch cord
props = self.format_patch_bridges(props) if ( props[:if_type].to_s == 'vport' and props[:bridge].size > 1 )
props = self.format_bond_opts(props) if props.has_key?(:bond_mode)
debug("format_file('#{filename}')::properties: #{props.inspect}")
pairs = self.unmangle_properties(provider, props)
pairs = self.format_bond_opts(pairs) if pairs.has_key?('mode') or pairs.has_key?('bond_mode')
pairs['DEVICETYPE'] = 'ovs' if pairs['TYPE'].to_s =~ /OVS/
if pairs['ROUTES']
@ -387,12 +388,12 @@ class Puppet::Provider::L23_stored_config_centos < Puppet::Provider::L23_stored_
bond_options = []
bond_properties = property_mappings.select { |k, v| k.to_s =~ %r{bond_.*} and !([:bond_master].include?(k)) }
bond_properties.each do |param, transform |
if props.has_key?(param)
bond_options << "#{transform}=#{props[param]}"
props.delete(param)
if props.has_key?(transform)
bond_options << "#{transform}=#{props[transform]}"
props.delete(transform)
end
end
props[:bonding_opts] = "\"#{bond_options.join(' ')}\""
props['BONDING_OPTS'] = "\"#{bond_options.join(' ')}\""
props
end

View File

@ -5,19 +5,20 @@ class Puppet::Provider::L23_stored_config_ovs_centos < Puppet::Provider::L23_sto
def self.property_mappings
rv = super
rv.merge!({
:devicetype => 'DEVICETYPE',
:vlan_id => 'OVS_OPTIONS',
:jacks => 'OVS_PATCH_PEER',
:bridge => 'OVS_BRIDGE',
:lnx_bridge => 'BRIDGE',
:bond_slaves => 'BOND_IFACES',
:bonding_opts => 'OVS_OPTIONS',
:bond_mode => 'bond_mode',
:bond_miimon => 'other_config:bond-miimon-interval',
:bond_lacp => 'lacp',
:bond_lacp_rate => 'other_config:lacp-time',
:bond_updelay => 'bond_updelay',
:bond_downdelay => 'bond_downdelay',
:devicetype => 'DEVICETYPE',
:vlan_id => 'OVS_OPTIONS',
:jacks => 'OVS_PATCH_PEER',
:bridge => 'OVS_BRIDGE',
:lnx_bridge => 'BRIDGE',
:bond_slaves => 'BOND_IFACES',
:bond_mode => 'bond_mode',
:bond_use_carrier => 'other_config:bond-detect-mode',
:bond_miimon => 'other_config:bond-miimon-interval',
:bond_lacp => 'lacp',
:bond_lacp_rate => 'other_config:lacp-time',
:bond_updelay => 'bond_updelay',
:bond_downdelay => 'bond_downdelay',
:bonding_opts => 'OVS_OPTIONS',
})
#delete non-OVS params
[:bond_ad_select, :bond_xmit_hash_policy, :bond_master].each { |p| rv.delete(p) }
@ -93,12 +94,12 @@ class Puppet::Provider::L23_stored_config_ovs_centos < Puppet::Provider::L23_sto
bond_options = []
bond_properties = property_mappings.select { |k, v| k.to_s =~ %r{bond_.*} and !([:bond_slaves].include?(k)) }
bond_properties.each do |param, transform |
if props.has_key?(param)
bond_options << "#{transform}=#{props[param]}"
props.delete(param)
if props.has_key?(transform)
bond_options << "#{transform}=#{props[transform]}"
props.delete(transform)
end
end
props[:bonding_opts] = "\"#{bond_options.join(' ')}\""
props['OVS_OPTIONS'] = "\"#{bond_options.join(' ')}\""
props
end
@ -177,6 +178,18 @@ class Puppet::Provider::L23_stored_config_ovs_centos < Puppet::Provider::L23_sto
val
end
def self.unmangle__bond_use_carrier(provider, data)
values = [ 'miimon', 'carrier' ]
rv = values[data.to_i] if data.to_i <= values.size
rv ||= nil
end
def self.mangle__bond_use_carrier(data)
values = [ 'miimon', 'carrier' ]
rv = values.index(data) if data
rv ||= nil
end
end
# vim: set ts=2 sw=2 et :

View File

@ -42,6 +42,7 @@ class Puppet::Provider::L23_stored_config_ubuntu < Puppet::Provider::L23_stored_
:bond_slaves => 'bond-slaves',
:bond_mode => 'bond-mode',
:bond_miimon => 'bond-miimon',
:bond_use_carrier => 'bond-use-carrier',
:bond_lacp => '', # unused for lnx
:bond_lacp_rate => 'bond-lacp-rate',
:bond_updelay => 'bond-updelay',

View File

@ -507,6 +507,8 @@ class Puppet::Provider::L2_base < Puppet::Provider::InterfaceToolset
:bond_properties => {
:mode => mode,
:miimon => File.open("/sys/class/net/#{bond_name}/bonding/miimon").read.chomp,
:updelay => File.open("/sys/class/net/#{bond_name}/bonding/updelay").read.chomp,
:downdelay => File.open("/sys/class/net/#{bond_name}/bonding/downdelay").read.chomp,
}
}
if ['802.3ad', 'balance-xor', 'balance-tlb', 'balance-alb'].include? mode
@ -515,7 +517,9 @@ class Puppet::Provider::L2_base < Puppet::Provider::InterfaceToolset
end
if mode=='802.3ad'
lacp_rate = File.open("/sys/class/net/#{bond_name}/bonding/lacp_rate").read.split(/\s+/)[0]
ad_select = File.open("/sys/class/net/#{bond_name}/bonding/ad_select").read.split(/\s+/)[0],
bond[bond_name][:bond_properties][:lacp_rate] = lacp_rate
bond[bond_name][:bond_properties][:ad_select] = ad_select
end
bond[bond_name][:onboot] = !self.get_iface_state(bond_name).nil?
end

View File

@ -66,7 +66,6 @@ Puppet::Type.type(:l2_bond).provide(:lnx, :parent => Puppet::Provider::Lnx_base)
if ! @property_flush.empty?
debug("FLUSH properties: #{@property_flush}")
bond_prop_dir = "/sys/class/net/#{@resource[:bond]}"
#
# FLUSH changed properties
if @property_flush.has_key? :slaves
runtime_slave_ports = self.class.get_sys_class("/sys/class/net/#{@resource[:bond]}/bonding/slaves", true)
@ -96,10 +95,16 @@ Puppet::Type.type(:l2_bond).provide(:lnx, :parent => Puppet::Provider::Lnx_base)
end
end
if @property_flush.has_key? :bond_properties
bond_properties_to_change = @property_flush[:bond_properties]
if @old_property_hash[:bond_properties] and !@old_property_hash[:bond_properties].empty?
bond_properties_to_change = @property_flush[:bond_properties].to_a - @old_property_hash[:bond_properties].to_a
bond_properties_to_change = Hash[*bond_properties_to_change.flatten]
end
debug("Bond properties which are going to be changed #{bond_properties_to_change}")
# change bond_properties
bond_is_up = !self.class.get_iface_state(@resource[:bond]).nil?
# Reassemble bond if we change bond mode
need_reassembling = true if self.class.get_sys_class("#{bond_prop_dir}/bonding/#{'mode'}") != @property_flush[:bond_properties][:mode]
need_reassembling = true if bond_properties_to_change[:mode] and self.class.get_sys_class("#{bond_prop_dir}/bonding/#{'mode'}") != bond_properties_to_change[:mode]
if need_reassembling
self.class.interface_down(@resource[:bond])
bond_is_up = false
@ -117,9 +122,9 @@ Puppet::Type.type(:l2_bond).provide(:lnx, :parent => Puppet::Provider::Lnx_base)
debug("Set primary bond properties [#{primary_bond_properties.join(',')}] for bond '#{@resource[:bond]}'")
primary_bond_properties.each do |ppp|
pprop = ppp.to_s
if @property_flush[:bond_properties].has_key?(ppp)
if bond_properties_to_change.has_key?(ppp)
curr_pprop = self.class.get_sys_class("#{bond_prop_dir}/bonding/#{pprop}")
should_pprop = @property_flush[:bond_properties][ppp].to_s
should_pprop = bond_properties_to_change[ppp].to_s
if ['', 'nil', 'undef'].include? should_pprop
debug("Skip undefined property '#{pprop}'='#{should_pprop}' for bond '#{@resource[:bond]}'")
elsif curr_pprop != should_pprop
@ -136,7 +141,7 @@ Puppet::Type.type(:l2_bond).provide(:lnx, :parent => Puppet::Provider::Lnx_base)
end
end
# setup another bond_properties
non_primary_bond_properties = @property_flush[:bond_properties].reject{|k,v| primary_bond_properties.include? k}
non_primary_bond_properties = bond_properties_to_change.reject{|k,v| primary_bond_properties.include? k}
debug("Set non-primary bond properties [#{non_primary_bond_properties.keys.join(',')}] for bond '#{@resource[:bond]}'")
non_primary_bond_properties.each do |prop, val|
if ['', 'nil', 'undef'].include? val.to_s

View File

@ -248,6 +248,7 @@ Puppet::Type.newtype(:l23_stored_config) do
newproperty(:bond_mode)
newproperty(:bond_miimon)
newproperty(:bond_use_carrier)
newproperty(:bond_lacp)
newproperty(:bond_lacp_rate)
newproperty(:bond_xmit_hash_policy)

View File

@ -131,7 +131,7 @@ Puppet::Type.newtype(:l2_bond) do
# provider-specific hash, validating only by type.
validate do |val|
if ! val.is_a? Hash
fail("Interface_properties should be a hash!")
fail("bond_properties should be a hash!")
end
end
@ -139,8 +139,8 @@ Puppet::Type.newtype(:l2_bond) do
# it's a workaround, because puppet double some values inside his internal logic
val.keys.each do |k|
if k.is_a? String
if ! val.has_key? k.to_sym
val[k.to_sym] = val[k]
unless val.has_key? k.to_sym
val[k.to_sym] = val[k] unless [:undef, :absent, ''].include?(val[k])
end
val.delete(k)
end

View File

@ -22,14 +22,16 @@
# lacp - ovs provider only
# lacp_rate
# ad_select - lnx provider only
# use_carrier - for lnx provider - as is, for ovs - bond-detect-mode: 1 - carrier, 0 - miimon
# updelay
# downdelay
#
# [*interface_properties*]
# Configuration options for included interfaces (mtu, ethtool, etc...)
#
# [*provider*]
# This manifest supports lnx or ovs providers.
#
# [*interface_properties*]
# Configuration options for included interfaces (mtu, ethtool, etc...)
#
define l23network::l2::bond (
@ -88,8 +90,8 @@ define l23network::l2::bond (
/ovs/: {
# default values by design http://openvswitch.org/support/dist-docs/ovs-vswitchd.conf.db.5.txt
$default_bond_properties = {
'mode' => 'active-backup',
'lacp' => 'off',
'mode' => 'active-backup',
'lacp' => 'off',
'lacp_rate' => 'slow',
}
@ -105,19 +107,18 @@ define l23network::l2::bond (
}
$calculated_bond_properties = {
mode => pick($bond_properties[mode], $default_bond_properties[mode]),
lacp => $lacp,
mode => pick($bond_properties[mode], $default_bond_properties[mode]),
lacp => $lacp,
lacp_rate => $lacp_rate,
}
}
default: {
# default values by design https://www.kernel.org/doc/Documentation/networking/bonding.txt
$default_bond_properties = {
'mode' => 'balance-rr',
'lacp_rate' => 'slow',
'mode' => 'balance-rr',
'lacp_rate' => 'slow',
'xmit_hash_policy' => 'layer2',
'ad_select' => 'bandwidth',
'ad_select' => 'bandwidth',
}
# calculate mode
@ -143,28 +144,29 @@ define l23network::l2::bond (
} else {
$lacp_rate = pick($bond_properties[lacp_rate], $default_bond_properties[lacp_rate])
}
}
# calculate ad_select
if is_integer($bond_properties[ad_select]) {
$ad_select = $ad_select_states[$bond_properties[ad_select]]
} else {
$ad_select = pick($bond_properties[ad_select], $default_bond_properties[ad_select])
# calculate ad_select
if is_integer($bond_properties[ad_select]) {
$ad_select = $ad_select_states[$bond_properties[ad_select]]
} else {
$ad_select = pick($bond_properties[ad_select], $default_bond_properties[ad_select])
}
}
$calculated_bond_properties = {
mode => $bond_mode,
mode => $bond_mode,
xmit_hash_policy => $xmit_hash_policy,
lacp_rate => $lacp_rate,
ad_select => $ad_select,
lacp_rate => $lacp_rate,
ad_select => $ad_select,
}
}
}
$real_bond_properties = merge($calculated_bond_properties, { miimon => pick($bond_properties[miimon], 100 ),
updelay => pick($bond_properties[updelay], 200 ),
downdelay => pick($bond_properties[downdelay], 200 )})
$miimon = pick($bond_properties[miimon], 100 )
$real_bond_properties = merge($calculated_bond_properties, { miimon => $miimon,
use_carrier => pick($bond_properties[use_carrier], 1),
updelay => pick($bond_properties[updelay], 2*$miimon),
downdelay => pick($bond_properties[downdelay], 2*$miimon), })
if $interfaces {
validate_array($interfaces)
@ -231,6 +233,7 @@ define l23network::l2::bond (
bond_master => undef,
bond_slaves => $interfaces,
bond_miimon => $real_bond_properties[miimon],
bond_use_carrier => $real_bond_properties[use_carrier],
bond_lacp => $real_bond_properties[lacp],
bond_lacp_rate => $real_bond_properties[lacp_rate],
bond_xmit_hash_policy => $real_bond_properties[xmit_hash_policy],

View File

@ -43,6 +43,17 @@ describe 'l23network::l2::bond', :type => :define do
})
end
it do
should contain_l2_bond('bond0').with({
'slaves' => ['eth3', 'eth4'],
'bond_properties' => {:mode=>"balance-rr",
:miimon=>"100",
:use_carrier=>"1",
:updelay=>"200",
:downdelay=>"200"},
})
end
['eth3', 'eth4'].each do |slave|
it do
should contain_l23_stored_config(slave).with({
@ -92,6 +103,19 @@ describe 'l23network::l2::bond', :type => :define do
})
end
it do
should contain_l2_bond('ovs-bond0').with({
'slaves' => ['eth31', 'eth41'],
'bridge' => 'br-ovs-bond0',
'bond_properties' => {:mode=>"active-backup",
:miimon=>"100",
:use_carrier=>"1",
:lacp=>"off",
:updelay=>"200",
:downdelay=>"200"},
})
end
['eth31', 'eth41'].each do |slave|
it do
should contain_l23_stored_config(slave).with({
@ -136,6 +160,19 @@ describe 'l23network::l2::bond', :type => :define do
})
end
it do
should contain_l2_bond('bond0').with({
'slaves' => ['eth3.101', 'eth4.102'],
'bond_properties' => {:mode=>'balance-rr',
:miimon=>'100',
:use_carrier=>'1',
:updelay=>'200',
:downdelay=>'200'},
})
end
['eth3.101', 'eth4.102'].each do |slave|
it do
should contain_l23_stored_config(slave).with({
@ -183,10 +220,22 @@ describe 'l23network::l2::bond', :type => :define do
'mtu' => 9000,
'bond_updelay' => '111',
'bond_downdelay' => '222',
'bond_ad_select' => 'count',
'bond_ad_select' => nil,
})
end
it do
should contain_l2_bond('bond0').with({
'slaves' => ['eth3', 'eth4'],
'bond_properties' => {:mode=>'balance-rr',
:miimon=>'100',
:use_carrier=>'1',
:updelay=>'111',
:downdelay=>'222'},
})
end
it do
should contain_l2_bond('bond0').with({
'mtu' => 9000,
@ -234,16 +283,20 @@ describe 'l23network::l2::bond', :type => :define do
'bond_xmit_hash_policy' => 'layer2',
})
end
# it do
# should contain_l2_bond('bond0').with_ensure('present')
# should contain_l2_bond('bond0').with_bond_properties({
# :mode => '802.3ad',
# :lacp_rate => 'slow',
# :miimon => '100',
# :xmit_hash_policy => 'layer2'
# })
# end
it do
should contain_l2_bond('bond0').with({
'slaves' => ['eth3', 'eth4'],
'bond_properties' => {:mode=>'802.3ad',
:xmit_hash_policy=>'layer2',
:lacp_rate=>'slow',
:ad_select=>'bandwidth',
:miimon=>'100',
:use_carrier=>'1',
:updelay=>'200',
:downdelay=>'200'},
})
end
# we shouldn't test bond slaves here, because it equalent to previous tests
end
@ -275,6 +328,18 @@ describe 'l23network::l2::bond', :type => :define do
should contain_l23_stored_config('bond0').without_bond_lacp_rate()
should contain_l23_stored_config('bond0').without_bond_xmit_hash_policy()
end
it do
should contain_l2_bond('bond0').with({
'slaves' => ['eth3', 'eth4'],
'bond_properties' => {:mode=>'active-backup',
:miimon=>'100',
:use_carrier=>'1',
:updelay=>'200',
:downdelay=>'200'},
})
end
end
context 'Create a lnx-bond with mode = balance-tlb, lacp_rate = fast xmit_hash_policy = layer2+3' do
@ -386,8 +451,8 @@ describe 'l23network::l2::bond', :type => :define do
'bond_lacp' => 'active',
'bond_lacp_rate' => 'fast',
'bond_miimon' => '300',
'bond_updelay' => '200',
'bond_downdelay' => '200',
'bond_updelay' => '600',
'bond_downdelay' => '600',
})
should contain_l23_stored_config('bond-ovs').without_bond_xmit_hash_policy()
end
@ -398,9 +463,10 @@ describe 'l23network::l2::bond', :type => :define do
:mode => 'balance-tcp',
:lacp => 'active',
:lacp_rate => 'fast',
:use_carrier => '1',
:miimon => '300',
:updelay =>"200",
:downdelay =>"200",
:updelay => '600',
:downdelay => '600',
},
})
end

View File

@ -10,4 +10,4 @@ ONBOOT=yes
MTU=9000
TYPE=Bond
BRIDGE=lnx-br0
BONDING_OPTS="mode=balance-tcp miimon=60 lacp_rate=fast ad_select=2 updelay=123 downdelay=155"
BONDING_OPTS="mode=balance-tcp miimon=60 use_carrier=0 lacp_rate=fast ad_select=2 updelay=123 downdelay=155"

View File

@ -10,6 +10,6 @@ ONBOOT=yes
MTU=9000
TYPE=OVSBond
OVS_BRIDGE=br0
OVS_OPTIONS="bond_mode=balance-tcp other_config:bond-miimon-interval=50 lacp=active other_config:lacp-time=fast bond_updelay=111 bond_downdelay=222"
OVS_OPTIONS="bond_mode=balance-tcp other_config:bond-miimon-interval=50 other_config:bond-detect-mode=miimon lacp=active other_config:lacp-time=fast bond_updelay=111 bond_downdelay=222"
DEVICETYPE=ovs
BOND_IFACES="eth2 eth3"

View File

@ -14,22 +14,23 @@ describe Puppet::Type.type(:l23_stored_config).provider(:lnx_centos7) do
let(:input_data) do
{
:lnx_bond1 => {
:name => 'lnx-bond1',
:ensure => 'present',
:if_type => 'bond',
:bridge => 'lnx-br0',
:mtu => '9000',
:onboot => true,
:method => 'manual',
:bond_mode => 'balance-tcp',
:bond_slaves => ['eth2', 'eth3'],
:bond_miimon => '60',
:bond_lacp_rate => 'fast',
:bond_lacp => 'active',
:bond_updelay => '123',
:bond_downdelay => '155',
:bond_ad_select => '2', # unused for OVS
:provider => "lnx_centos7",
:name => 'lnx-bond1',
:ensure => 'present',
:if_type => 'bond',
:bridge => 'lnx-br0',
:mtu => '9000',
:onboot => true,
:method => 'manual',
:bond_mode => 'balance-tcp',
:bond_slaves => ['eth2', 'eth3'],
:bond_miimon => '60',
:bond_use_carrier => '0',
:bond_lacp_rate => 'fast',
:bond_lacp => 'active',
:bond_updelay => '123',
:bond_downdelay => '155',
:bond_ad_select => '2', # unused for OVS
:provider => "lnx_centos7",
},
}
end
@ -86,7 +87,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:lnx_centos7) do
it { expect(cfg_file).to match(%r{TYPE=Bond}) }
it { expect(cfg_file).to match(%r{BRIDGE=lnx-br0}) }
it { expect(cfg_file).to match(%r{MTU=9000}) }
it { expect(cfg_file).to match(%r{BONDING_OPTS="mode=balance-tcp miimon=60 lacp_rate=fast ad_select=2 updelay=123 downdelay=155"}) }
it { expect(cfg_file).to match(%r{BONDING_OPTS="mode=balance-tcp miimon=60 use_carrier=0 lacp_rate=fast ad_select=2 updelay=123 downdelay=155"}) }
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(7) } # no more lines in the interface file
end
@ -99,6 +100,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:lnx_centos7) do
it { expect(res[:if_type].to_s).to eq 'bond' }
it { expect(res[:bond_mode]).to eq 'balance-tcp' }
it { expect(res[:bond_miimon]).to eq '60' }
it { expect(res[:bond_use_carrier]).to eq '0' }
it { expect(res[:bond_lacp_rate]).to eq 'fast' }
it { expect(res[:bond_lacp]).not_to eq 'active' }
it { expect(res[:bond_updelay]).to eq '123' }

View File

@ -6,22 +6,22 @@ describe Puppet::Type.type(:l23_stored_config).provider(:lnx_ubuntu) do
let(:input_data) do
{
:bond0 => {
:name => 'bond0',
:ensure => 'present',
:if_type => 'bond',
:mtu => '9000',
:onboot => true,
:method => 'manual',
:bond_mode => '802.3ad',
:name => 'bond0',
:ensure => 'present',
:if_type => 'bond',
:mtu => '9000',
:onboot => true,
:method => 'manual',
:bond_mode => '802.3ad',
:bond_xmit_hash_policy => 'encap3+4',
:bond_slaves => ['eth2', 'eth3'],
:bond_miimon => '50',
:bond_lacp_rate => 'fast',
:bond_lacp => 'passive', # used only for OVS bonds. Should do nothing for lnx.
:bond_updelay => '111',
:bond_downdelay => '222',
:bond_ad_select => '2',
:provider => "lnx_ubuntu",
:bond_slaves => ['eth2', 'eth3'],
:bond_miimon => '50',
:bond_lacp_rate => 'fast',
:bond_lacp => 'passive', # used only for OVS bonds. Should do nothing for lnx.
:bond_updelay => '111',
:bond_downdelay => '222',
:bond_ad_select => '2',
:provider => "lnx_ubuntu",
},
}
end

View File

@ -14,22 +14,23 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_centos7) do
let(:input_data) do
{
:ovs_bondlacp1 => {
:name => 'ovs-bondlacp1',
:ensure => 'present',
:if_type => 'bond',
:bridge => 'br0',
:mtu => '9000',
:onboot => true,
:method => 'manual',
:bond_mode => 'balance-tcp',
:bond_slaves => ['eth2', 'eth3'],
:bond_miimon => '50',
:bond_lacp_rate => 'fast',
:bond_lacp => 'active',
:bond_updelay => '111',
:bond_downdelay => '222',
:bond_ad_select => '2', # unused for OVS
:provider => "ovs_centos7",
:name => 'ovs-bondlacp1',
:ensure => 'present',
:if_type => 'bond',
:bridge => 'br0',
:mtu => '9000',
:onboot => true,
:method => 'manual',
:bond_mode => 'balance-tcp',
:bond_slaves => ['eth2', 'eth3'],
:bond_miimon => '50',
:bond_use_carrier => '0',
:bond_lacp_rate => 'fast',
:bond_lacp => 'active',
:bond_updelay => '111',
:bond_downdelay => '222',
:bond_ad_select => '2', # unused for OVS
:provider => "ovs_centos7",
},
}
end
@ -87,7 +88,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_centos7) do
it { expect(cfg_file).to match(%r{OVS_BRIDGE=br0}) }
it { expect(cfg_file).to match(%r{MTU=9000}) }
it { expect(cfg_file).to match(%r{OVS_OPTIONS="bond_mode=balance-tcp other_config:bond-miimon-interval=50 \
other_config:lacp-time=fast bond_updelay=111 bond_downdelay=222 lacp=active"}) }
other_config:bond-detect-mode=miimon other_config:lacp-time=fast bond_updelay=111 bond_downdelay=222 lacp=active"}) }
it { expect(cfg_file).to match(%r{BOND_IFACES="eth2 eth3"}) }
it { expect(cfg_file).to match(%r{DEVICETYPE=ovs}) }
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(9) } # no more lines in the interface file
@ -101,6 +102,7 @@ other_config:lacp-time=fast bond_updelay=111 bond_downdelay=222 lacp=active"}) }
it { expect(res[:if_type].to_s).to eq 'bond' }
it { expect(res[:bond_mode]).to eq 'balance-tcp' }
it { expect(res[:bond_miimon]).to eq '50' }
it { expect(res[:bond_use_carrier].to_s).to eq '0' }
it { expect(res[:bond_lacp_rate]).to eq 'fast' }
it { expect(res[:bond_lacp]).to eq 'active' }
it { expect(res[:bond_updelay]).to eq '111' }

View File

@ -6,22 +6,23 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_ubuntu) do
let(:input_data) do
{
:bond_lacp => {
:name => 'bond_lacp',
:ensure => 'present',
:if_type => 'bond',
:bridge => 'br0',
:mtu => '9000',
:onboot => true,
:method => 'manual',
:bond_mode => 'balance-tcp',
:bond_slaves => ['eth2', 'eth3'],
:bond_miimon => '50',
:bond_lacp_rate => 'fast',
:bond_lacp => 'active',
:bond_updelay => '111',
:bond_downdelay => '222',
:bond_ad_select => '2', # unused for OVS
:provider => "ovs_ubuntu",
:name => 'bond_lacp',
:ensure => 'present',
:if_type => 'bond',
:bridge => 'br0',
:mtu => '9000',
:onboot => true,
:method => 'manual',
:bond_mode => 'balance-tcp',
:bond_slaves => ['eth2', 'eth3'],
:bond_miimon => '50',
:bond_use_carrier => '0',
:bond_lacp_rate => 'fast',
:bond_lacp => 'active',
:bond_updelay => '111',
:bond_downdelay => '222',
:bond_ad_select => '2', # unused for OVS
:provider => "ovs_ubuntu",
},
}
end
@ -87,6 +88,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:ovs_ubuntu) do
it { expect(cfg_file).to match(/ovs_type\s+OVSBond/) }
it { expect(cfg_file).to match(/ovs_bridge\s+br0/) }
it { expect(cfg_file).to match(/ovs_options.+bond_mode=balance-tcp/) }
it { expect(cfg_file).to match(/ovs_options.+other_config:bond-detect-mode=miimon/) }
it { expect(cfg_file).to match(/ovs_options.+other_config:lacp-time=fast/) }
it { expect(cfg_file).to match(/ovs_options.+other_config:bond-miimon-interval=50/) }
it { expect(cfg_file).to match(/ovs_options.+bond_updelay=111/) }