Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move code to setcode to apply confine #209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions lib/facter/lvm_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
Facter.add('lvm_vgs') do
confine :lvm_support => true

if Facter.value(:lvm_support)
setcode do
vgs = Facter::Core::Execution.execute('vgs -o name --noheadings 2>/dev/null', timeout: 30)
end
if vgs.nil?
setcode { 0 }
else
vg_list = vgs.split
setcode { vg_list.length }
if vgs.nil?
0
else
vg_list = vgs.split
vg_list.length
end
end
end

# lvm_vg_[0-9]+
# VG name by index
vg_list.each_with_index do |vg, i|
Facter.add("lvm_vg_#{i}") { setcode { vg } }
Facter.add("lvm_vg_#{vg}_pvs") do
setcode do
setcode do
Facter.add("lvm_vg_#{i}") { vg }
Facter.add("lvm_vg_#{vg}_pvs") do
pvs = Facter::Core::Execution.execute("vgs -o pv_name #{vg} 2>/dev/null", timeout: 30)
res = nil
unless pvs.nil?
Expand All @@ -48,14 +48,14 @@
Facter.add('lvm_pvs') do
confine :lvm_support => true

if Facter.value(:lvm_support)
setcode do
pvs = Facter::Core::Execution.execute('pvs -o name --noheadings 2>/dev/null', timeout: 30)
end
if pvs.nil?
setcode { 0 }
else
pv_list = pvs.split
setcode { pv_list.length }
if pvs.nil?
0
else
pv_list = pvs.split
pv_list.length
end
end
end

Expand Down