[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, experimental_upstream, updated. 1.5.9-54-g5a4eeed
Adrien Thebo
adrien.thebo at gmail.com
Wed Jun 22 08:51:48 UTC 2011
The following commit has been merged in the experimental_upstream branch:
commit 0c4a98b2271ed5d84f2aa8783398f08502b578ee
Author: Krzysztof Wilczynski <krzysztof.wilczynski at linux.com>
Date: Sun Jan 2 04:24:42 2011 +0000
Re-factor. Do not use pure-Ruby file reading against "/proc/cpuinfo" and possibly any entry under "/sys" from the sysfs file system.
diff --git a/lib/facter/physicalprocessorcount.rb b/lib/facter/physicalprocessorcount.rb
index 86d0749..144183c 100644
--- a/lib/facter/physicalprocessorcount.rb
+++ b/lib/facter/physicalprocessorcount.rb
@@ -36,8 +36,12 @@ Facter.add('physicalprocessorcount') do
#
# (...)
#
- lookup_pattern = "#{sysfs_cpu_directory}/cpu*/topology/physical_package_id"
- Dir[lookup_pattern].map { |i| File.read(i).strip }.uniq.size
+ lookup_pattern = "#{sysfs_cpu_directory}" +
+ "/cpu*/topology/physical_package_id"
+
+ Facter::Util::Resolution.exec(
+ "cat #{lookup_pattern}"
+ ).scan(/\d+/).uniq.size
else
#
# Try to count number of CPUs using the proc file system next ...
@@ -45,7 +49,9 @@ Facter.add('physicalprocessorcount') do
# We assume that /proc/cpuinfo has what we need and is so then we need
# to make sure that we only count unique entries ...
#
- File.read('/proc/cpuinfo').scan(/physical.+:\s(\d+)/).uniq.size
+ Facter::Util::Resolution.exec(
+ "grep 'physical.\\+:' /proc/cpuinfo"
+ ).scan(/\d+/).uniq.size
end
end
end
--
Packaging of Facter for debian
More information about the Pkg-puppet-devel
mailing list