summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2010-11-23 16:48:25 -0800
committerNick Lewis <nick@puppetlabs.com>2010-11-23 16:48:25 -0800
commitd53526a52af6be154f7f7b741f5bffb95c76500a (patch)
treec388f198121bfa13ccfad7f6c978994cfa5e2313
parent03af0ccd085a39f60b20a313d8b9f5b71da8a22f (diff)
parent2cbbc2c1063cc46b1fb77e69e41a872d2e5bfae1 (diff)
downloadfacter-d53526a52af6be154f7f7b741f5bffb95c76500a.tar.gz
facter-d53526a52af6be154f7f7b741f5bffb95c76500a.tar.xz
facter-d53526a52af6be154f7f7b741f5bffb95c76500a.zip
Merge branch 'next'
-rw-r--r--lib/facter/manufacturer.rb2
-rw-r--r--lib/facter/util/manufacturer.rb20
-rw-r--r--spec/unit/util/macaddress.rb6
-rw-r--r--spec/unit/util/manufacturer.rb13
-rw-r--r--spec/unit/util/uptime.rb6
5 files changed, 40 insertions, 7 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/macaddress.rb b/spec/unit/util/macaddress.rb
index 8349b36..1ccca18 100644
--- a/spec/unit/util/macaddress.rb
+++ b/spec/unit/util/macaddress.rb
@@ -25,7 +25,7 @@ context "Darwin" do
context "when netstat has a default interface" do
before do
- Facter::Util::Macaddress::Darwin.stubs(:netstat_command).returns("cat #{netstat_file}")
+ Facter::Util::Macaddress::Darwin.stubs(:netstat_command).returns("cat \"#{netstat_file}\"")
end
it "should return the default interface name" do
@@ -40,7 +40,7 @@ context "Darwin" do
before do
Facter.stubs(:warn)
Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns('')
- Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns("cat #{ifconfig_file}")
+ Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns("cat \"#{ifconfig_file}\"")
end
it "should return the macaddress of the default interface" do
@@ -52,7 +52,7 @@ context "Darwin" do
context "when netstat does not have a default interface" do
before do
Facter::Util::Macaddress::Darwin.stubs(:default_interface).returns("")
- Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns("cat #{ifconfig_file_no_iface}")
+ Facter::Util::Macaddress::Darwin.stubs(:ifconfig_command).returns("cat \"#{ifconfig_file_no_iface}\"")
end
it "should warn about the lack of default" do
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()
diff --git a/spec/unit/util/uptime.rb b/spec/unit/util/uptime.rb
index 9ba6665..72c97ed 100644
--- a/spec/unit/util/uptime.rb
+++ b/spec/unit/util/uptime.rb
@@ -10,7 +10,7 @@ describe Facter::Util::Uptime do
context "when /proc/uptime is available" do
before do
uptime_file = File.join(SPECDIR, "fixtures", "uptime", "ubuntu_proc_uptime")
- Facter::Util::Uptime.stubs(:uptime_file).returns(uptime_file)
+ Facter::Util::Uptime.stubs(:uptime_file).returns("\"#{uptime_file}\"")
end
it "should return the uptime in seconds as an integer" do
@@ -24,7 +24,7 @@ describe Facter::Util::Uptime do
File.exists?(nonexistent_file).should == false
Facter::Util::Uptime.stubs(:uptime_file).returns(nonexistent_file)
sysctl_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'sysctl_kern_boottime') # Aug 01 14:13:47 -0700 2010
- Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat #{sysctl_output_file}")
+ Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"")
Time.stubs(:now).returns Time.parse("Aug 01 15:13:47 -0700 2010") # one hour later
Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
end
@@ -35,7 +35,7 @@ describe Facter::Util::Uptime do
Facter::Util::Uptime.stubs(:uptime_file).returns(nonexistent_file)
Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat #{nonexistent_file}")
who_b_output_file = File.join(SPECDIR, 'fixtures', 'uptime', 'who_b_boottime') # Aug 1 14:13
- Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat #{who_b_output_file}")
+ Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat \"#{who_b_output_file}\"")
Time.stubs(:now).returns Time.parse("Aug 01 15:13") # one hour later
Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
end