diff --git a/deployment/puppet/l23network/lib/puppet/parser/functions/generate_network_config.rb b/deployment/puppet/l23network/lib/puppet/parser/functions/generate_network_config.rb index 55224b9264..1b0d234467 100644 --- a/deployment/puppet/l23network/lib/puppet/parser/functions/generate_network_config.rb +++ b/deployment/puppet/l23network/lib/puppet/parser/functions/generate_network_config.rb @@ -419,7 +419,9 @@ Puppet::Parser::Functions::newfunction(:generate_network_config, :type => :rvalu end if !trans[:provider] - if action == :port && trans[:bridge] + if action == :port && trans[:bridge] && ((trans[:vlan_dev] && trans[:vlan_id]) or trans[:name]=~/\.\d+/) + trans[:provider] = default_provider + elsif action == :port && trans[:bridge] provider = L23network.get_property_for_transformation('PROVIDER', trans[:bridge], lookupvar('l3_fqdn_hostname')) trans[:provider] = provider || default_provider else diff --git a/deployment/puppet/l23network/spec/classes/l2_lnx_subinterfaces_into_ovs_bridge__spec.rb b/deployment/puppet/l23network/spec/classes/l2_lnx_subinterfaces_into_ovs_bridge__spec.rb new file mode 100644 index 0000000000..cfbccf56d3 --- /dev/null +++ b/deployment/puppet/l23network/spec/classes/l2_lnx_subinterfaces_into_ovs_bridge__spec.rb @@ -0,0 +1,173 @@ +require 'spec_helper' + +describe 'l23network::examples::run_network_scheme', :type => :class do + context 'network scheme with OVS bridge and native lnx subinterface with ethN.XXX naming into it' do + let(:title) { 'test network scheme' } + let(:facts) { + { + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :kernel => 'Linux', + :l23_os => 'ubuntu', + :l3_fqdn_hostname => 'stupid_hostname', + } + } + + let(:params) {{ + :settings_yaml => ''' + network_scheme: + version: 1.1 + provider: lnx + interfaces: + eth1: {} + transformations: + - action: add-br + name: xxx + provider: ovs + - action: add-port + name: eth1.101 + bridge: xxx + ''' + }} + + before(:each) do + puppet_debug_override() + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_l23network__l2__port('eth1.101') } + it { is_expected.to contain_l23network__l2__port('eth1.101').with({ + 'provider' => 'lnx', + })} + end +end + +describe 'l23network::examples::run_network_scheme', :type => :class do + context 'network scheme with OVS bridge and native lnx subinterface with vlanXXX naming into it' do + let(:title) { 'test network scheme' } + let(:facts) { + { + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :kernel => 'Linux', + :l23_os => 'ubuntu', + :l3_fqdn_hostname => 'stupid_hostname', + } + } + + let(:params) {{ + :settings_yaml => ''' + network_scheme: + version: 1.1 + provider: lnx + interfaces: + eth1: {} + transformations: + - action: add-br + name: xxx + provider: ovs + - action: add-port + name: vlan101 + vlan_dev: eth1 + vlan_id: 101 + bridge: xxx + ''' + }} + + before(:each) do + puppet_debug_override() + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_l23network__l2__port('vlan101') } + it { is_expected.to contain_l23network__l2__port('vlan101').with({ + 'provider' => 'lnx', + })} + end +end + +describe 'l23network::examples::run_network_scheme', :type => :class do + context 'network scheme with OVS bridge and native lnx interface into it' do + let(:title) { 'test network scheme' } + let(:facts) { + { + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :kernel => 'Linux', + :l23_os => 'ubuntu', + :l3_fqdn_hostname => 'stupid_hostname', + } + } + + let(:params) {{ + :settings_yaml => ''' + network_scheme: + version: 1.1 + provider: lnx + interfaces: + eth1: {} + transformations: + - action: add-br + name: xxx + provider: ovs + - action: add-port + name: eth1 + bridge: xxx + ''' + }} + + before(:each) do + puppet_debug_override() + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_l23network__l2__port('eth1') } + it { is_expected.to contain_l23network__l2__port('eth1').with({ + 'provider' => 'ovs', + })} + end +end + +describe 'l23network::examples::run_network_scheme', :type => :class do + context 'network scheme with OVS bridge and ovs fake interface into it' do + let(:title) { 'test network scheme' } + let(:facts) { + { + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :kernel => 'Linux', + :l23_os => 'ubuntu', + :l3_fqdn_hostname => 'stupid_hostname', + } + } + + let(:params) {{ + :settings_yaml => ''' + network_scheme: + version: 1.1 + provider: lnx + interfaces: + eth1: {} + transformations: + - action: add-br + name: xxx + provider: ovs + - action: add-port + name: yyy + bridge: xxx + ''' + }} + + before(:each) do + puppet_debug_override() + end + + it { is_expected.to compile.with_all_deps } + it { is_expected.to contain_l23network__l2__port('yyy') } + it { is_expected.to contain_l23network__l2__port('yyy').with({ + 'provider' => 'ovs', + })} + end +end + +### diff --git a/files/fuel-ha-utils/ocf/ns_IPaddr2 b/files/fuel-ha-utils/ocf/ns_IPaddr2 index d1ce510dc0..ad9bbcc10f 100755 --- a/files/fuel-ha-utils/ocf/ns_IPaddr2 +++ b/files/fuel-ha-utils/ocf/ns_IPaddr2 @@ -475,6 +475,19 @@ ip_stop() { return $rc } +check_patchcord_exists_in_bridge() { + local br="$1" + local veth="$2" + if [[ -d /sys/class/net/${br}/brif ]] ; then + # LNX + test -L /sys/class/net/${br}/brif/${veth} || return $OCF_ERR_GENERIC + else + # OVS + ovs-vsctl list-ports "${br}" | grep "${veth}" || return $OCF_ERR_GENERIC + fi + return $OCF_SUCCESS +} + ip_monitor() { local rc ip_validate @@ -483,6 +496,8 @@ ip_monitor() { [ -z "$iface" ] && return $OCF_NOT_RUNNING + check_patchcord_exists_in_bridge $OCF_RESKEY_bridge $OCF_RESKEY_base_veth || return $OCF_ERR_GENERIC + check_interfaces_for_up_state "$OCF_RESKEY_bridge:$OCF_RESKEY_also_check_interfaces" || return $OCF_NOT_RUNNING # use arping here, because no IP from VIP network allowed on host system ocf_run arping -c 10 -w 2 -I $OCF_RESKEY_bridge $OCF_RESKEY_ip || return $OCF_NOT_RUNNING