[Pkg-puppet-devel] [SCM] Packaging of Facter for debian branch, upstream, updated. 51bcebe38cab6088c901f1006339bbe40a36d161

Marc Fournier marc.fournier at camptocamp.com
Wed Aug 18 05:55:49 UTC 2010


The following commit has been merged in the upstream branch:
commit c5b8d3b9c2621649d0559ed87a3d5493d706288a
Author: Marc Fournier <marc.fournier at camptocamp.com>
Date:   Fri May 7 08:46:36 2010 +0200

    Fixes #3740 - split dmi output on regex
    
    Splitting dmi output on the string "/^Handle/" didn't work, and
    caused the function to match the wrong key if it was found more
    than once.
    The intended behaviour of the function is restored by splitting
    the dmi output on the regex /^Handle/.

diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb
index baf24bc..61d617a 100644
--- a/lib/facter/util/manufacturer.rb
+++ b/lib/facter/util/manufacturer.rb
@@ -28,7 +28,7 @@ module Facter::Manufacturer
     end
 
     def self.dmi_find_system_info(name)
-        splitstr=  Facter.value(:kernel) ==  'SunOS' ? "ID    SIZE TYPE" : "/^Handle/"
+        splitstr=  Facter.value(:kernel) ==  'SunOS' ? "ID    SIZE TYPE" : /^Handle/
         output = self.get_dmi_table()
         return if output.nil?
         name.each_pair do |key,v|
diff --git a/spec/unit/util/manufacturer.rb b/spec/unit/util/manufacturer.rb
index 11d207d..f9ec81f 100644
--- a/spec/unit/util/manufacturer.rb
+++ b/spec/unit/util/manufacturer.rb
@@ -45,4 +45,42 @@ Handle 0x001F
         Facter::Manufacturer.dmi_find_system_info(query)
         Facter.value(:ramslots).should == "2"
     end
-end
\ No newline at end of file
+
+    it "should match the key in the defined section and not the first one found" do
+        dmidecode_output = <<-eos
+Handle 0x000C, DMI type 7, 19 bytes
+Cache Information
+        Socket Designation: Internal L2 Cache
+        Configuration: Enabled, Socketed, Level 2
+        Operational Mode: Write Back
+        Location: Internal
+        Installed Size: 4096 KB
+        Maximum Size: 4096 KB
+        Supported SRAM Types:
+                Burst
+        Installed SRAM Type: Burst
+        Speed: Unknown
+        Error Correction Type: Single-bit ECC
+        System Type: Unified
+        Associativity: 8-way Set-associative
+
+Handle 0x1000, DMI type 16, 15 bytes
+Physical Memory Array
+        Location: System Board Or Motherboard
+        Use: System Memory
+        Error Correction Type: None
+        Maximum Capacity: 4 GB
+        Error Information Handle: Not Provided
+        Number Of Devices: 2
+
+Handle 0x001F
+        DMI type 127, 4 bytes.
+        End Of Table
+        eos
+        Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output)
+        Facter.fact(:kernel).stubs(:value).returns("Linux")
+        query = { 'Physical Memory Array' => [ { 'Location:' => 'ramlocation'}]}
+        Facter::Manufacturer.dmi_find_system_info(query)
+        Facter.value(:ramlocation).should == "System Board Or Motherboard"
+    end
+end

-- 
Packaging of Facter for debian



More information about the Pkg-puppet-devel mailing list