more accurate checking for bonding provider
Change-Id: I7386f74790e15a9bf99018db6d263b37f67b2ee1 Closes-bug: #1318996
This commit is contained in:
parent
89ccab7ee7
commit
9cc882f48b
@ -203,11 +203,28 @@ Puppet::Parser::Functions::newfunction(:generate_network_config, :type => :rvalu
|
||||
ifconfig_order.insert(-1, t[:name].to_sym())
|
||||
end
|
||||
elsif action == :bond
|
||||
t[:provider] = 'ovs' if ! t[:provider] # default provider for Bond
|
||||
if ! t[:interfaces].is_a? Array
|
||||
raise(Puppet::ParseError, "generate_network_config(): 'add-bond' resource should has non-empty 'interfaces' list.")
|
||||
end
|
||||
if ! t[:properties].is_a? Hash
|
||||
raise(Puppet::ParseError, "generate_network_config(): 'add-bond' resource should has non-empty 'properties' field.")
|
||||
if t[:provider] == 'lnx'
|
||||
if ! t[:properties].is_a? Hash
|
||||
raise(Puppet::ParseError, "generate_network_config(): 'add-bond' resource should has 'properties' hash for '#{t[:provider]}' provider.")
|
||||
else
|
||||
if t[:properties].size < 1
|
||||
raise(Puppet::ParseError, "generate_network_config(): 'add-bond' resource should has non-empty 'properties' hash for '#{t[:provider]}' provider.")
|
||||
end
|
||||
end
|
||||
elsif t[:provider] == 'ovs'
|
||||
if ! t[:properties].is_a? Array
|
||||
raise(Puppet::ParseError, "generate_network_config(): 'add-bond' resource should has 'properties' array for '#{t[:provider]}' provider.")
|
||||
else
|
||||
if t[:properties].size < 1
|
||||
raise(Puppet::ParseError, "generate_network_config(): 'add-bond' resource should has non-empty 'properties' array for '#{t[:provider]}' provider.")
|
||||
end
|
||||
end
|
||||
else
|
||||
raise(Puppet::ParseError, "generate_network_config(): 'add-bond' resource has wrong provider '#{t[:provider]}'.")
|
||||
end
|
||||
if t[:provider] == 'lnx'
|
||||
if ! ifconfig_order.index(t[:name].to_sym())
|
||||
|
@ -0,0 +1,9 @@
|
||||
class l23network::examples::adv_net_config__bond_ovs (
|
||||
$fuel_settings,
|
||||
) {
|
||||
class {'l23network': use_ovs=>true}
|
||||
|
||||
prepare_network_config($fuel_settings['network_scheme'])
|
||||
$sdn = generate_network_config()
|
||||
}
|
||||
###
|
@ -101,6 +101,26 @@ describe 'l23network::examples::adv_net_config__bond_lnx', :type => :class do
|
||||
end
|
||||
end
|
||||
|
||||
it 'ALL: Should contains l23network::l2::bridge resource' do
|
||||
rv = contain_l23network__l2__bridge("br-#{c_bondname}")
|
||||
should rv.with(
|
||||
'ensure' => 'present'
|
||||
)
|
||||
end
|
||||
|
||||
it 'ALL: Should contains l23network::l2::port resource' do
|
||||
rv = contain_l23network__l2__port("#{c_bondname}")
|
||||
should rv.with(
|
||||
'bridge' => "br-#{c_bondname}",
|
||||
'ensure' => 'present'
|
||||
)
|
||||
end
|
||||
|
||||
it 'ALL: Should contains relationship beetwen l23network::l2::bridge and l23network::l2::port' do
|
||||
bridge = contain_l23network__l2__bridge("br-#{c_bondname}")
|
||||
should bridge.that_comes_before("L23network::L2::Port[#{c_bondname}]")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Centos, static
|
||||
|
@ -0,0 +1,117 @@
|
||||
require 'rspec-puppet'
|
||||
require 'spec_helper'
|
||||
require 'puppetlabs_spec_helper/puppetlabs_spec/puppet_internals'
|
||||
require 'yaml'
|
||||
|
||||
#fuel_settings = YAML::load(<<-EOM)
|
||||
c_bondname = 'bond0'
|
||||
c_interfaces = ['eth1','eth2']
|
||||
c_lacp_rate = 2
|
||||
c_miimon = 150
|
||||
fuel_settings = YAML::load(<<-EOM)
|
||||
network_scheme:
|
||||
version: '1.0'
|
||||
provider: ovs
|
||||
interfaces:
|
||||
eth2:
|
||||
L2:
|
||||
vlan_splinters: 'off'
|
||||
eth1:
|
||||
L2:
|
||||
vlan_splinters: 'off'
|
||||
eth5:
|
||||
fake:
|
||||
interface: eth5
|
||||
transformations:
|
||||
- action: add-br
|
||||
name: br-#{c_bondname}
|
||||
- action: add-bond
|
||||
bridge: br-#{c_bondname}
|
||||
name: #{c_bondname}
|
||||
interfaces:
|
||||
- eth1
|
||||
- eth2
|
||||
properties:
|
||||
- bond_mode=active-backup
|
||||
endpoints:
|
||||
eth5:
|
||||
IP: none
|
||||
EOM
|
||||
|
||||
# Ubintu
|
||||
describe 'l23network::examples::adv_net_config__bond_ovs', :type => :class do
|
||||
let(:module_path) { '../' }
|
||||
#let(:title) { 'bond0' }
|
||||
let(:params) { {
|
||||
:fuel_settings => fuel_settings
|
||||
} }
|
||||
let(:facts) { {
|
||||
:l3_fqdn_hostname => 'qweqweqwe',
|
||||
:osfamily => 'Debian',
|
||||
:operatingsystem => 'Ubuntu',
|
||||
:kernel => 'Linux'
|
||||
} }
|
||||
let(:interface_file_start) { '/etc/network/interfaces.d/ifcfg-' }
|
||||
|
||||
it "UBUNTU: Should contains interface_file" do
|
||||
should contain_file('/etc/network/interfaces').with_content(/\*/)
|
||||
end
|
||||
|
||||
it 'UBUNTU: Should contains interface files for bond-slave interfaces' do
|
||||
c_interfaces.each do |iface|
|
||||
rv = contain_file("#{interface_file_start}#{iface}")
|
||||
should rv.with_content(/auto\s+#{iface}/)
|
||||
should rv.with_content(/iface\s+#{iface}/)
|
||||
should rv.with_content(/up\s+ip\s+l\s+set\s+#{iface}\s+up/)
|
||||
should rv.with_content(/down\s+ip\s+l\s+set\s+#{iface}\s+down/)
|
||||
end
|
||||
end
|
||||
|
||||
it 'ALL: Should contains l23network::l2::bridge resource' do
|
||||
rv = contain_l23network__l2__bridge("br-#{c_bondname}")
|
||||
should rv.with(
|
||||
'ensure' => 'present'
|
||||
)
|
||||
end
|
||||
|
||||
it 'ALL: Should contains l23network::l2::bond resource' do
|
||||
rv = contain_l23network__l2__bond("#{c_bondname}")
|
||||
should rv.with(
|
||||
'bridge' => "br-#{c_bondname}",
|
||||
'interfaces' => c_interfaces,
|
||||
'ensure' => 'present'
|
||||
)
|
||||
end
|
||||
|
||||
it 'ALL: Should contains relationship beetwen l23network::l2::bridge and l23network::l2::bond' do
|
||||
bridge = contain_l23network__l2__bridge("br-#{c_bondname}")
|
||||
should bridge.that_comes_before("L23network::L2::Bond[#{c_bondname}]")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# Centos
|
||||
describe 'l23network::examples::adv_net_config__bond_ovs', :type => :class do
|
||||
let(:module_path) { '../' }
|
||||
#let(:title) { 'bond0' }
|
||||
let(:params) { {
|
||||
:fuel_settings => fuel_settings
|
||||
} }
|
||||
let(:facts) { {
|
||||
:l3_fqdn_hostname => 'qweqweqwe',
|
||||
:osfamily => 'RedHat',
|
||||
:operatingsystem => 'Centos',
|
||||
:kernel => 'Linux'
|
||||
} }
|
||||
let(:interface_file_start) { '/etc/sysconfig/network-scripts/ifcfg-' }
|
||||
|
||||
it 'CENTOS: Should contains interface files for bond-slave interfaces' do
|
||||
c_interfaces.each do |iface|
|
||||
rv = contain_file("#{interface_file_start}#{iface}")
|
||||
should rv.with_content(/DEVICE=#{iface}/)
|
||||
should rv.with_content(/BOOTPROTO=none/)
|
||||
should rv.with_content(/ONBOOT=yes/)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user