check if /proc/bus/pci/devices is available

This avoids an error thrown if the file is not available.
Hint: the facter code is executed even if the module is
not included on the catalog.

Change-Id: Ie7a3dce6d42d3b2274bb5578862d677841e7bdc3
This commit is contained in:
Benedikt Trefzer 2017-06-02 14:58:56 +02:00
parent ee4b105351
commit 8a3479db80

View File

@ -1,6 +1,10 @@
require 'facter'
drivers_details=Facter::Util::Resolution.exec("cat /proc/bus/pci/devices")
drivers_lines=drivers_details.split("\n")
if File.file?("/proc/bus/pci/devices")
drivers_details=File.read("/proc/bus/pci/devices")
drivers_lines=drivers_details.split("\n")
else
drivers_lines=Array.new
end
drivers=Hash.new
drivers_lines.each do |line|
line = line.gsub(/^\s+|\s+$/m, '').split(" ")