[Pkg-puppet-devel] [facter] 87/352: (fact-79) Commonize non-nil physicalprocessorcount values to string
Stig Sandbeck Mathisen
ssm at debian.org
Sun Apr 6 22:21:34 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit c436f400fa3d76b3f773f9d6ae7607f17309d638
Author: Kylo Ginsberg <kylo at puppetlabs.com>
Date: Tue Dec 17 17:28:25 2013 -0800
(fact-79) Commonize non-nil physicalprocessorcount values to string
Prior to this commit, physicalprocessorcount returned an integer on
non-sunos platforms, but a string on sunos. Also, all the other
processorcount-related facts returned strings regardless.
For consistency cross-platform and cross-processorcount-facts,
this changes all physicalprocessorcount values to be strings.
Note this doesn't change the one case where physicalprocessorcount
returns nil, as that is being addressed by fact-107.
---
lib/facter/physicalprocessorcount.rb | 6 +++---
schema/facter.json | 2 +-
spec/unit/physicalprocessorcount_spec.rb | 6 +++---
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/facter/physicalprocessorcount.rb b/lib/facter/physicalprocessorcount.rb
index dbfa35b..06a4881 100644
--- a/lib/facter/physicalprocessorcount.rb
+++ b/lib/facter/physicalprocessorcount.rb
@@ -39,7 +39,7 @@ Facter.add('physicalprocessorcount') do
lookup_pattern = "#{sysfs_cpu_directory}" +
"/cpu*/topology/physical_package_id"
- Dir.glob(lookup_pattern).collect { |f| Facter::Util::Resolution.exec("cat #{f}")}.uniq.size
+ Dir.glob(lookup_pattern).collect { |f| Facter::Util::Resolution.exec("cat #{f}")}.uniq.size.to_s
else
#
@@ -50,7 +50,7 @@ Facter.add('physicalprocessorcount') do
#
str = Facter::Util::Resolution.exec("grep 'physical.\\+:' /proc/cpuinfo")
- if str then str.scan(/\d+/).uniq.size; end
+ if str then str.scan(/\d+/).uniq.size.to_s; end
end
end
end
@@ -59,7 +59,7 @@ Facter.add('physicalprocessorcount') do
confine :kernel => :windows
setcode do
require 'facter/util/wmi'
- Facter::Util::WMI.execquery("select Name from Win32_Processor").Count
+ Facter::Util::WMI.execquery("select Name from Win32_Processor").Count.to_s
end
end
diff --git a/schema/facter.json b/schema/facter.json
index 34ad276..c689c6c 100644
--- a/schema/facter.json
+++ b/schema/facter.json
@@ -64,7 +64,7 @@
"operatingsystemrelease" : { "type": "string" },
"osfamily" : { "type": "string" },
"path" : { "type": "string" },
- "physicalprocessorcount" : { "type": "integer" },
+ "physicalprocessorcount" : { "type": "string" },
"processorcount" : { "type": "string" },
"productname" : { "type": "string" },
"ps" : { "type": "string" },
diff --git a/spec/unit/physicalprocessorcount_spec.rb b/spec/unit/physicalprocessorcount_spec.rb
index a36eed4..1e957fc 100755
--- a/spec/unit/physicalprocessorcount_spec.rb
+++ b/spec/unit/physicalprocessorcount_spec.rb
@@ -14,7 +14,7 @@ describe "Physical processor count facts" do
Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu*/topology/physical_package_id").returns(["/sys/devices/system/cpu/cpu0/topology/physical_package_id"])
Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu0/topology/physical_package_id").returns("0")
- Facter.fact(:physicalprocessorcount).value.should == 1
+ Facter.fact(:physicalprocessorcount).value.should == "1"
end
it "should return four physical CPUs" do
@@ -30,7 +30,7 @@ describe "Physical processor count facts" do
Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu2/topology/physical_package_id").returns("2")
Facter::Util::Resolution.stubs(:exec).with("cat /sys/devices/system/cpu/cpu3/topology/physical_package_id").returns("3")
- Facter.fact(:physicalprocessorcount).value.should == 4
+ Facter.fact(:physicalprocessorcount).value.should == "4"
end
end
@@ -43,7 +43,7 @@ describe "Physical processor count facts" do
Facter::Util::WMI.expects(:execquery).with("select Name from Win32_Processor").returns(ole)
ole.stubs(:Count).returns(4)
- Facter.fact(:physicalprocessorcount).value.should == 4
+ Facter.fact(:physicalprocessorcount).value.should == "4"
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list