Fix multiq configuration for dpdk in runtime

Change-Id: Ib4048eb037b34d0d8f0c651783b540922a7cfd98
Closes-Bug: #1643920
This commit is contained in:
Mikhail 2017-01-18 12:37:02 +04:00 committed by Mikhail Zhnichkov
parent 9fb1c276a2
commit a78b06ede0
5 changed files with 11 additions and 36 deletions

View File

@ -14,10 +14,6 @@ Puppet::Type.type(:l23_stored_config).provide(:dpdkovs_ubuntu, :parent => Puppet
L23network.get_dpdk_ports_mapping
end
def self.get_config
L23network::Scheme.get_config(Facter.value(:l3_fqdn_hostname))
end
def self.check_if_provider(if_data)
if if_data[:if_type] =~ /dpdkovsport/
if_data[:if_type] = "ethernet"
@ -106,12 +102,7 @@ Puppet::Type.type(:l23_stored_config).provide(:dpdkovs_ubuntu, :parent => Puppet
end
def multiq_threads
if self.if_type.to_s == 'bond'
cfg = self.class.get_config
multiq_threads = self.bond_slaves.map { |iface| cfg[:interfaces][iface.to_sym][:vendor_specific][:max_queues]}.min
else
multiq_threads = self.vendor_specific['max_queues']
end
multiq_threads = self.vendor_specific['max_queues']
end
def self.mangle__bond_slaves(val)

View File

@ -43,6 +43,10 @@ Puppet::Type.type(:l2_port).provide(:dpdkovs, :parent => Puppet::Provider::Ovs_b
def flush
if ! @property_flush.empty?
debug("FLUSH properties: #{@property_flush}")
if !@property_flush[:vendor_specific][:max_queues].nil? and @property_flush[:vendor_specific][:max_queues] != :absent
dpdk_port = self.class.get_dpdk_ports_mapping[@resource[:interface]]
vsctl('set', 'Interface', '#{dpdk_port}', 'options:n_rxq=#{@property_flush[:vendor_specific][:max_queues].to_i}')
end
@property_hash = resource.to_hash
end
end

View File

@ -11,4 +11,3 @@ iface bond_lacp inet manual
ovs_type DPDKOVSBond
ovs_bridge br-prv
ovs_options bond_mode=balance-tcp bond_updelay=111 bond_downdelay=222 lacp=active other_config:lacp-time=fast other_config:bond-miimon-interval=50
multiq_threads 3

View File

@ -25,20 +25,6 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
}
}
let(:config) {
{:interfaces =>
{:enp1s0f0 =>
{:vendor_specific =>
{:max_queues => 3}
},
:enp1s0f1 =>
{:vendor_specific =>
{:max_queues => 3}
}
}
}
}
let(:dpdk_ports_mapping) {
{
'enp1s0f0' => 'dpdk0',
@ -93,7 +79,6 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
subject { providers[:bond_lacp] }
let(:cfg_file) do
subject.class.stubs(:get_dpdk_ports_mapping).returns(dpdk_ports_mapping)
subject.class.stubs(:get_config).returns(config)
subject.class.format_file('filepath', [subject])
end
it { expect(cfg_file).not_to match(/auto\s+bond_lacp/) }
@ -110,8 +95,7 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
it { expect(cfg_file).to match(/ovs_options.+bond_updelay=111/) }
it { expect(cfg_file).to match(/ovs_options.+bond_downdelay=222/) }
it { expect(cfg_file).to match(/ovs_options.+lacp=active/) }
it { expect(cfg_file).to match(/multiq_threads\s+3/) }
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(8) } # no more lines in the interface file
it { expect(cfg_file.split(/\n/).reject{|x| x=~/(^\s*$)|(^#.*$)/}.length). to eq(7) } # no more lines in the interface file
end
context "parse data from fixture" do
@ -131,7 +115,6 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
it { expect(res[:bond_updelay]).to eq '111' }
it { expect(res[:bond_downdelay]).to eq '222' }
it { expect(res[:bond_slaves]).to eq ['enp1s0f0', 'enp1s0f1'] }
it { expect(res[:multiq_threads].to_s).to eq '3' }
end
end
end

View File

@ -4,13 +4,11 @@ describe Puppet::Type.type(:l23_stored_config).provider(:dpdkovs_ubuntu) do
let(:input_data) {
{
:'enp1s0f0' => {
:name => 'enp1s0f0',
:if_type => 'ethernet',
:bridge => 'br-prv',
:provider => 'dpdkovs_ubuntu',
:vendor_specific => {
:max_queues => 3
},
:name => 'enp1s0f0',
:if_type => 'ethernet',
:bridge => 'br-prv',
:provider => 'dpdkovs_ubuntu',
:vendor_specific => {'max_queues' => 3},
},
}
}