[Pkg-puppet-devel] [facter] 07/18: (FACT-959) Incorrect processor counts on Windows

Stig Sandbeck Mathisen ssm at debian.org
Wed Jan 27 21:12:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit e3e7c4f072d86ae3ff794c4456ff9f2b45948ada
Author: jasminen <jasminen at liveperson.com>
Date:   Sun Nov 22 16:55:03 2015 +0200

    (FACT-959) Incorrect processor counts on Windows
    
    Facter is showing the CPU socket count on processorcount fact which
    should be the the logical count and not the physical count (which is
    already represented by the physicalprocessorcount fact).
    
    Apparently it is a bug in the
    proc.respond_to?(:NumberOfLogicalProcessors) which always returns
    false since the NumberOfLogicalProcessors is not a regular method but
    an OLE method. Therefore it should use the ole_respond_to? method
    (WIN32OLE class).
---
 lib/facter/processors/os.rb     | 2 +-
 spec/unit/processors/os_spec.rb | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/facter/processors/os.rb b/lib/facter/processors/os.rb
index f75d088..e7a7cf8 100644
--- a/lib/facter/processors/os.rb
+++ b/lib/facter/processors/os.rb
@@ -112,7 +112,7 @@ module Facter
         # get each physical processor
         Facter::Util::WMI.execquery("select * from Win32_Processor").each do |proc|
           # not supported before 2008
-          if proc.respond_to?(:NumberOfLogicalProcessors)
+          if proc.ole_respond_to?(:NumberOfLogicalProcessors)
             processor_num = proc.NumberOfLogicalProcessors
           else
             processor_num = 1
diff --git a/spec/unit/processors/os_spec.rb b/spec/unit/processors/os_spec.rb
index 8d23a6c..5e6be23 100644
--- a/spec/unit/processors/os_spec.rb
+++ b/spec/unit/processors/os_spec.rb
@@ -221,6 +221,7 @@ describe Facter::Processors::Windows do
       before :each do
         proc = stubs 'proc'
         proc.stubs(:Name).returns("Intel(R)    Celeron(R)   processor")
+        proc.stubs(:ole_respond_to?).with(:NumberOfLogicalProcessors).returns(false)
         load(Array.new(2, proc))
       end
 
@@ -235,6 +236,7 @@ describe Facter::Processors::Windows do
       before :each do
         proc = stubs 'proc'
         proc.stubs(:NumberOfLogicalProcessors).returns(2)
+        proc.stubs(:ole_respond_to?).with(:NumberOfLogicalProcessors).returns(true)
         proc.stubs(:Name).returns("Intel(R)    Celeron(R)   processor")
         load(Array.new(2, proc))
       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