-
Notifications
You must be signed in to change notification settings - Fork 0
/
dpdk_options.rb
68 lines (66 loc) · 1.96 KB
/
dpdk_options.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'puppet'
require 'facter'
Puppet::Type.newtype(:dpdk_options) do
desc 'DPDK Options'
ensurable
newparam(:path, :namevar => true) do
newvalues(/\S+\/\S+/)
end
newparam(:pci_list) do
desc 'PCI address for driver type'
end
newparam(:core_list) do
desc 'CPU core list for dpdk options'
newvalues(/^[0-9]+([,]{1}[0-9]+)*$/)
end
newparam(:socket_memory) do
desc 'Socket memory mapping'
end
newparam(:memory_channels) do
desc 'Memory channels'
validate do |value|
if !/^\d+$/.match(value) || value=="0" || value==" "
fail("Invalid memory channels #{value}")
end
end
end
validate do
cpu_core_list = self[:core_list].split(",")
pci_address_list=self[:pci_list].split(",")
numa_nodes_pci_address = Facter.value(:numa_pci_address)
if numa_nodes_pci_address.length>0
numa_nodes_core_info = Facter.value(:numa_core_info)
numa_nodes_list=[]
pci_address_list.each do |pci|
for node in 0..numa_nodes_pci_address.length-1
if (numa_nodes_pci_address[node].include? pci)
unless (numa_nodes_list.include? node)
numa_nodes_list.push(node)
end
break
end
end
end
pci_numa_nodes_core_info = []
numa_nodes_list.each do |pci_node|
pci_numa_nodes_core_info = pci_numa_nodes_core_info | numa_nodes_core_info[pci_node]
end
is_core_valid=false
cpu_core_list.each do |core|
if(pci_numa_nodes_core_info.include? core)
is_core_valid=true
break
end
end
if !is_core_valid
fail("Invalid core list #{self[:core_list]}")
end
socket_memory=self[:socket_memory].split(",")
numa_nodes_list.each do |node|
if(socket_memory[node]=="0" || socket_memory[node]==" " || socket_memory[node].length==0)
fail("Invalid socket memory #{self[:socket_memory]}")
end
end
end
end
end