diff options
| author | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2007-06-18 21:10:10 +0000 |
|---|---|---|
| committer | luke <luke@1f5c1d6a-bddf-0310-8f58-fc49e503516a> | 2007-06-18 21:10:10 +0000 |
| commit | 68449a95efc4245313df38bbee5838522930108f (patch) | |
| tree | a7e7e25f53287b44e9407bdce868988f603ee1aa /lib | |
| parent | 750a0c632d3f1e1ff910245c70653b86c85a1dd8 (diff) | |
| download | facter-68449a95efc4245313df38bbee5838522930108f.tar.gz facter-68449a95efc4245313df38bbee5838522930108f.tar.xz facter-68449a95efc4245313df38bbee5838522930108f.zip | |
Adding manufacturer code, as requested by digant on the Puppet Trac site.
git-svn-id: http://reductivelabs.com/svn/facter/trunk@210 1f5c1d6a-bddf-0310-8f58-fc49e503516a
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/facter/manufacturer.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/facter/manufacturer.rb b/lib/facter/manufacturer.rb new file mode 100644 index 0000000..049bcd9 --- /dev/null +++ b/lib/facter/manufacturer.rb @@ -0,0 +1,25 @@ +# Info about the manufacturer +# + +module Facter::Manufacturer + def self.dmi_find_system_info(name) + dmiinfo = `/usr/sbin/dmidecode` + info = dmiinfo.scan(/^\s*System Information(.*?)\n\S/m).join.split("\n").map { |line| + line.split(":").map { |line2| line2.strip } + }.reject { |array| array.empty? } + info.select { |array| array[0] == name} [0][1] + end +end + +# Add the facts to Facter + +{:SerialNumber => "Serial Number", + :Manufacturer => "Manufacturer", + :ProductName=> "Product Name"}.each do |fact, name| + Facter.add(fact) do + confine :kernel => :linux + setcode do + Facter::Manufacturer.dmi_find_system_info(name) + end + end +end |
