summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2010-11-22 15:54:22 -0800
committerMatt Robinson <matt@puppetlabs.com>2010-11-22 15:54:22 -0800
commit2cbbc2c1063cc46b1fb77e69e41a872d2e5bfae1 (patch)
treec388f198121bfa13ccfad7f6c978994cfa5e2313
parent4b8469dadcbc7ec1860288021b54fb281e7208a5 (diff)
parent9332f8a69fcf1f623f57f808085af3e1aafabc38 (diff)
Merge branch 'ticket/next/5325' into next
* ticket/next/5325: (#5325) Add tests for SPARC manufacturer and product name (#5325) Manufacturer and product name on SPARC
-rw-r--r--lib/facter/manufacturer.rb2
-rw-r--r--lib/facter/util/manufacturer.rb20
-rw-r--r--spec/unit/util/manufacturer.rb13
3 files changed, 34 insertions, 1 deletions
diff --git a/lib/facter/manufacturer.rb b/lib/facter/manufacturer.rb
index 9d66465..cbbb88b 100644
--- a/lib/facter/manufacturer.rb
+++ b/lib/facter/manufacturer.rb
@@ -13,6 +13,8 @@ if Facter.value(:kernel) == "OpenBSD"
}
Facter::Manufacturer.sysctl_find_system_info(mfg_keys)
+elsif Facter.value(:kernel) == "SunOS" and Facter.value(:hardwareisa) == "sparc"
+ Facter::Manufacturer.prtdiag_sparc_find_system_info()
else
query = {
'[Ss]ystem [Ii]nformation' => [
diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb
index 112380b..5ac0585 100644
--- a/lib/facter/util/manufacturer.rb
+++ b/lib/facter/util/manufacturer.rb
@@ -60,4 +60,24 @@ module Facter::Manufacturer
end
end
end
+
+ def self.prtdiag_sparc_find_system_info()
+ # Parses prtdiag for a SPARC architecture string, won't work with Solaris x86
+ output = Facter::Util::Resolution.exec('/usr/sbin/prtdiag')
+
+ # System Configuration: Sun Microsystems sun4u Sun SPARC Enterprise M3000 Server
+ sysconfig = output.split("\n")[0]
+ if sysconfig =~ /^System Configuration:\s+(.+?)\s+(sun\d+\S+)\s+(.+)/ then
+ Facter.add('manufacturer') do
+ setcode do
+ $1
+ end
+ end
+ Facter.add('productname') do
+ setcode do
+ $3
+ end
+ end
+ end
+ end
end
diff --git a/spec/unit/util/manufacturer.rb b/spec/unit/util/manufacturer.rb
index c0d4b13..291a6ff 100644
--- a/spec/unit/util/manufacturer.rb
+++ b/spec/unit/util/manufacturer.rb
@@ -3,6 +3,10 @@ require File.dirname(__FILE__) + '/../../spec_helper'
require 'facter/util/manufacturer'
describe Facter::Manufacturer do
+ before :each do
+ Facter.clear
+ end
+
it "should return the system DMI table" do
Facter::Manufacturer.should respond_to(:get_dmi_table)
end
@@ -12,6 +16,13 @@ describe Facter::Manufacturer do
Facter::Manufacturer.get_dmi_table().should be_nil
end
+ it "should parse prtdiag output" do
+ Facter::Util::Resolution.stubs(:exec).returns("System Configuration: Sun Microsystems sun4u Sun SPARC Enterprise M3000 Server")
+ Facter::Manufacturer.prtdiag_sparc_find_system_info()
+ Facter.value(:manufacturer).should == "Sun Microsystems"
+ Facter.value(:productname).should == "Sun SPARC Enterprise M3000 Server"
+ end
+
it "should strip white space on dmi output with spaces" do
sample_output_file = File.dirname(__FILE__) + "/../data/linux_dmidecode_with_spaces"
dmidecode_output = File.new(sample_output_file).read()
@@ -23,7 +34,7 @@ describe Facter::Manufacturer do
Facter::Manufacturer.dmi_find_system_info(query)
Facter.value(:productname).should == "MS-6754"
end
-
+
it "should handle output from smbios when run under sunos" do
sample_output_file = File.dirname(__FILE__) + "/../data/opensolaris_smbios"
smbios_output = File.new(sample_output_file).read()