|
13 | 13 |
|
14 | 14 | # lvm_vgs: [0-9]+ |
15 | 15 | # Number of VGs |
| 16 | +vg_list = [] |
16 | 17 | Facter.add('lvm_vgs') do |
17 | 18 | confine lvm_support: true |
18 | 19 |
|
19 | | - setcode do |
20 | | - vgs = Facter::Core::Execution.execute('vgs -o name --noheadings 2>/dev/null', timeout: 30) |
| 20 | + vgs = Facter::Core::Execution.execute('vgs -o name --noheadings 2>/dev/null', timeout: 30) |
21 | 21 |
|
22 | | - if vgs.nil? |
23 | | - 0 |
24 | | - else |
25 | | - vg_list = vgs.split |
| 22 | + if vgs.nil? |
| 23 | + setcode { 0 } |
| 24 | + else |
| 25 | + vg_list = vgs.split |
| 26 | + setcode { vg_list.length } |
| 27 | + end |
| 28 | +end |
26 | 29 |
|
27 | | - # lvm_vg_[0-9]+ |
28 | | - # VG name by index |
29 | | - vg_list.each_with_index do |vg, i| |
30 | | - Facter.add("lvm_vg_#{i}") { setcode { vg } } |
31 | | - Facter.add("lvm_vg_#{vg}_pvs") do |
32 | | - setcode do |
33 | | - pvs = Facter::Core::Execution.execute("vgs -o pv_name #{vg} 2>/dev/null", timeout: 30) |
34 | | - res = nil |
35 | | - res = pvs.split("\n").grep(%r{^\s+/}).collect(&:strip).sort.join(',') unless pvs.nil? |
36 | | - res |
37 | | - end |
38 | | - end |
| 30 | +# lvm_vg_[0-9]+ |
| 31 | +# VG name by index |
| 32 | +vg_list.each_with_index do |vg, i| |
| 33 | + Facter.add("lvm_vg_#{i}") { setcode { vg } } |
| 34 | + Facter.add("lvm_vg_#{vg}_pvs") do |
| 35 | + setcode do |
| 36 | + pvs = Facter::Core::Execution.execute("vgs -o pv_name #{vg} 2>/dev/null", timeout: 30) |
| 37 | + res = nil |
| 38 | + unless pvs.nil? |
| 39 | + res = pvs.split("\n").select { |l| l =~ %r{^\s+/} }.map(&:strip).sort.join(',') |
39 | 40 | end |
40 | | - vg_list.length |
| 41 | + res |
41 | 42 | end |
42 | 43 | end |
43 | 44 | end |
|
48 | 49 | Facter.add('lvm_pvs') do |
49 | 50 | confine lvm_support: true |
50 | 51 |
|
51 | | - setcode do |
52 | | - pvs = Facter::Core::Execution.execute('pvs -o name --noheadings 2>/dev/null', timeout: 30) |
53 | | - |
54 | | - if pvs.nil? |
55 | | - 0 |
56 | | - else |
57 | | - pv_list = pvs.split |
58 | | - |
59 | | - # lvm_pv_[0-9]+ |
60 | | - # PV name by index |
61 | | - pv_list.each_with_index do |pv, i| |
62 | | - Facter.add("lvm_pv_#{i}") { setcode { pv } } |
63 | | - end |
64 | | - pv_list.length |
65 | | - end |
| 52 | + pvs = Facter::Core::Execution.execute('pvs -o name --noheadings 2>/dev/null', timeout: 30) |
| 53 | + if pvs.nil? |
| 54 | + setcode { 0 } |
| 55 | + else |
| 56 | + pv_list = pvs.split |
| 57 | + setcode { pv_list.length } |
66 | 58 | end |
67 | 59 | end |
| 60 | + |
| 61 | +# lvm_pv_[0-9]+ |
| 62 | +# PV name by index |
| 63 | +pv_list.each_with_index do |pv, i| |
| 64 | + Facter.add("lvm_pv_#{i}") { setcode { pv } } |
| 65 | +end |
0 commit comments