facter 2.0.1.rc2 → 2.0.1.rc3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of facter might be problematic. Click here for more details.

Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/facter/core/execution.rb +16 -5
  4. data/lib/facter/core/execution/base.rb +1 -1
  5. data/lib/facter/domain.rb +2 -2
  6. data/lib/facter/hostname.rb +1 -1
  7. data/lib/facter/ipaddress.rb +1 -1
  8. data/lib/facter/kernelrelease.rb +1 -1
  9. data/lib/facter/operatingsystemmajrelease.rb +15 -2
  10. data/lib/facter/operatingsystemrelease.rb +5 -0
  11. data/lib/facter/util/resolution.rb +1 -1
  12. data/lib/facter/util/solaris_zones.rb +1 -1
  13. data/lib/facter/util/uptime.rb +3 -3
  14. data/lib/facter/version.rb +1 -1
  15. data/spec/unit/core/execution/base_spec.rb +10 -10
  16. data/spec/unit/core/execution_spec.rb +7 -2
  17. data/spec/unit/domain_spec.rb +5 -5
  18. data/spec/unit/hardwareisa_spec.rb +5 -5
  19. data/spec/unit/hardwaremodel_spec.rb +1 -1
  20. data/spec/unit/hostname_spec.rb +4 -4
  21. data/spec/unit/id_spec.rb +3 -3
  22. data/spec/unit/ipaddress_spec.rb +1 -1
  23. data/spec/unit/kernelrelease_spec.rb +3 -3
  24. data/spec/unit/kernelversion_spec.rb +1 -1
  25. data/spec/unit/lsbdistcodename_spec.rb +1 -1
  26. data/spec/unit/lsbdistid_spec.rb +1 -1
  27. data/spec/unit/lsbdistrelease_spec.rb +2 -2
  28. data/spec/unit/lsbrelease_spec.rb +1 -1
  29. data/spec/unit/operatingsystemmajrelease_spec.rb +22 -0
  30. data/spec/unit/operatingsystemrelease_spec.rb +2 -0
  31. data/spec/unit/processor_spec.rb +5 -5
  32. data/spec/unit/uniqueid_spec.rb +3 -3
  33. data/spec/unit/util/resolution_spec.rb +1 -1
  34. data/spec/unit/util/solaris_zones_spec.rb +5 -5
  35. data/spec/unit/util/uptime_spec.rb +2 -2
  36. data/spec/unit/zonename_spec.rb +1 -1
  37. data/spec/unit/zones_spec.rb +1 -1
  38. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d199e09642d31db53de5a1c0b30d8c52dd21e59b
4
- data.tar.gz: d5b98ff29d794725423191c8ebbbcadf518ef7ba
3
+ metadata.gz: bf2b28456e6ba49e87f2424478114ddd5491fdbf
4
+ data.tar.gz: f32f1c68a017140c0349aa5204a0f4083dd02594
5
5
  SHA512:
6
- metadata.gz: c5f37318a479dc3e4962b252d0ad1c3ab83706937efa55c2b66d2b944dfa6a3814ff278b2737eb1feb47d65cd294820f2969a492c95fd1a7898a6ec84be8e164
7
- data.tar.gz: b81e27242129a9375fa59ee6e03bcc243bb1d1818ca3c3b6402d922d103df153976bbc93fbc844546c4fe8f32f19f88e2f2541c91a303df118f9f5cf2ae1897c
6
+ metadata.gz: b0cfb768e0be5c22c5e5f84618105e6bca44eac1064984c93c9925e644fa339f6c6f5981340af6ff64e69fbd6e3f8a8fbbea83fb45f60192fa1fa6a778273ee5
7
+ data.tar.gz: 5f52ace8ca02a973171c7ae24d89285a70846b62a5a9bc33823f8c7b832b82c78da6940ef56ef0c5a7fb526ab237964d961129d6ff0dd2e31a038e2841ca8fb4
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ platforms :ruby do
9
9
  end
10
10
 
11
11
  group :development, :test do
12
- gem 'rake'
12
+ gem 'rake', "~> 10.1.0"
13
13
  gem 'rspec', "~> 2.11.0"
14
14
  gem 'mocha', "~> 0.10.5"
15
15
  gem 'json', "~> 1.7", :platforms => :ruby
@@ -83,10 +83,20 @@ module Facter
83
83
  @@impl.with_env(values, &block)
84
84
  end
85
85
 
86
- # Executes a program and return the output of that program.
86
+ # Try to execute a command and return the output.
87
87
  #
88
- # Returns nil if the program can't be found, or if there is a problem
89
- # executing the code.
88
+ # @param code [String] the program to run
89
+ #
90
+ # @return [String] the output of the program, or nil if the command does
91
+ # not exist or could not be executed.
92
+ #
93
+ # @deprecated Use #{execute} instead
94
+ # @api public
95
+ def exec(command)
96
+ @@impl.execute(command, :on_fail => nil)
97
+ end
98
+
99
+ # Execute a command and return the output of that program.
90
100
  #
91
101
  # @param code [String] the program to run
92
102
  # @param options [Hash]
@@ -102,8 +112,9 @@ module Facter
102
112
  # command execution failed and :on_fail was specified.
103
113
  #
104
114
  # @api public
105
- def exec(command, options = {})
106
- @@impl.exec(command, options)
115
+ # @since 2.0.1
116
+ def execute(command, options = {})
117
+ @@impl.execute(command, options)
107
118
  end
108
119
 
109
120
  class ExecutionFailure < StandardError; end
@@ -27,7 +27,7 @@ class Facter::Core::Execution::Base
27
27
  rv
28
28
  end
29
29
 
30
- def exec(command, options = {})
30
+ def execute(command, options = {})
31
31
 
32
32
  on_fail = options.fetch(:on_fail, :raise)
33
33
 
data/lib/facter/domain.rb CHANGED
@@ -41,11 +41,11 @@ Facter.add(:domain) do
41
41
  basic_hostname
42
42
  end
43
43
 
44
- if name = Facter::Core::Execution.exec(hostname_command, :on_fail => nil) \
44
+ if name = Facter::Core::Execution.exec(hostname_command) \
45
45
  and name =~ /.*?\.(.+$)/
46
46
 
47
47
  return_value = $1
48
- elsif Facter.value(:kernel) != "windows" and domain = Facter::Core::Execution.exec('dnsdomainname 2> /dev/null', :on_fail => nil) \
48
+ elsif Facter.value(:kernel) != "windows" and domain = Facter::Core::Execution.exec('dnsdomainname 2> /dev/null') \
49
49
  and domain =~ /.+/
50
50
 
51
51
  return_value = domain
@@ -14,7 +14,7 @@
14
14
  Facter.add(:hostname) do
15
15
  setcode do
16
16
  hostname = nil
17
- if name = Facter::Core::Execution.exec('hostname')
17
+ if name = Facter::Core::Execution.execute('hostname')
18
18
  if name =~ /(.*?)\./
19
19
  hostname = $1
20
20
  else
@@ -155,7 +155,7 @@ Facter.add(:ipaddress, :timeout => 2) do
155
155
  if hostname = Facter.value(:hostname)
156
156
  # we need Hostname to exist for this to work
157
157
  host = nil
158
- if host = Facter::Core::Execution.exec("host #{hostname}")
158
+ if host = Facter::Core::Execution.execute("host #{hostname}")
159
159
  list = host.chomp.split(/\s/)
160
160
  if defined? list[-1] and
161
161
  list[-1] =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/
@@ -23,7 +23,7 @@ end
23
23
  Facter.add(:kernelrelease) do
24
24
  confine :kernel => "hp-ux"
25
25
  setcode do
26
- version = Facter::Core::Execution.exec('uname -r')
26
+ version = Facter::Core::Execution.execute('uname -r')
27
27
  version[2..-1]
28
28
  end
29
29
  end
@@ -2,8 +2,11 @@
2
2
  #
3
3
  # Purpose: Returns the major release of the operating system.
4
4
  #
5
- # Resolution: splits down the operatingsystemrelease fact at decimal point for
6
- # osfamily RedHat derivatives and Debian.
5
+ # Resolution:
6
+ # Splits down the operatingsystemrelease fact at decimal point for
7
+ # osfamily RedHat derivatives and Debian.
8
+ # Uses operatingsystemrelease to the first non decimal character for
9
+ # operatingsystem Solaris
7
10
  #
8
11
  # This should be the same as lsbmajdistrelease, but on minimal systems there
9
12
  # are too many dependencies to use LSB
@@ -13,6 +16,7 @@
13
16
  #"Debian" "Fedora" "Gentoo" "Mandrake" "Mandriva" "MeeGo" "OEL" "OpenSuSE"
14
17
  #"OracleLinux" "OVS" "PSBM" "RedHat" "Scientific" "Slackware" "Slamd64" "SLC"
15
18
  #"SLED" "SLES" "SuSE" "Ubuntu" "VMWareESX"
19
+
16
20
  Facter.add(:operatingsystemmajrelease) do
17
21
  confine :operatingsystem => [
18
22
  :Amazon,
@@ -31,3 +35,12 @@ Facter.add(:operatingsystemmajrelease) do
31
35
  Facter.value('operatingsystemrelease').split('.').first
32
36
  end
33
37
  end
38
+
39
+ Facter.add(:operatingsystemmajrelease) do
40
+ confine :operatingsystem => :solaris
41
+ setcode do
42
+ if match = Facter.value(:operatingsystemrelease).match(/^(\d+)/)
43
+ match.captures[0]
44
+ end
45
+ end
46
+ end
@@ -181,8 +181,13 @@ Facter.add(:operatingsystemrelease) do
181
181
  setcode do
182
182
  if release = Facter::Util::FileRead.read('/etc/release')
183
183
  line = release.split("\n").first.chomp
184
+ # Solaris 10: Solaris 10 10/09 s10x_u8wos_08a X86
185
+ # Solaris 11 (old naming scheme): Oracle Solaris 11 11/11 X86
186
+ # Solaris 11 (new naming scheme): Oracle Solaris 11.1 SPARC
184
187
  if match = /\s+s(\d+)[sx]?(_u\d+)?.*(?:SPARC|X86)/.match(line)
185
188
  match.captures.join('')
189
+ elsif match = /Solaris ([0-9\.]+(?:\s*[0-9\.\/]+))\s*(?:SPARC|X86)/.match(line)
190
+ match.captures[0]
186
191
  end
187
192
  end
188
193
  end
@@ -128,7 +128,7 @@ class Facter::Util::Resolution
128
128
  def setcode(string = nil, &block)
129
129
  if string
130
130
  @code = Proc.new do
131
- output = Facter::Core::Execution.exec(string, :on_fail => nil)
131
+ output = Facter::Core::Execution.execute(string, :on_fail => nil)
132
132
  if output.nil? or output.empty?
133
133
  nil
134
134
  else
@@ -93,7 +93,7 @@ module Util
93
93
  #
94
94
  # @return [Hash] the parsed output of the zoneadm command
95
95
  def refresh
96
- @zoneadm_output = Facter::Core::Execution.exec(zoneadm_cmd, {:on_fail => nil})
96
+ @zoneadm_output = Facter::Core::Execution.execute(zoneadm_cmd, {:on_fail => nil})
97
97
  parse!
98
98
  end
99
99
 
@@ -20,7 +20,7 @@ module Facter::Util::Uptime
20
20
  private
21
21
 
22
22
  def self.uptime_proc_uptime
23
- output = Facter::Core::Execution.exec("/bin/cat #{uptime_file} 2>/dev/null")
23
+ output = Facter::Core::Execution.execute("/bin/cat #{uptime_file} 2>/dev/null")
24
24
 
25
25
  if not output.empty?
26
26
  output.chomp.split(" ").first.to_i
@@ -28,14 +28,14 @@ module Facter::Util::Uptime
28
28
  end
29
29
 
30
30
  def self.uptime_sysctl
31
- output = Facter::Core::Execution.exec("#{uptime_sysctl_cmd} 2>/dev/null", :on_fail => nil)
31
+ output = Facter::Core::Execution.execute("#{uptime_sysctl_cmd} 2>/dev/null", :on_fail => nil)
32
32
  if output
33
33
  compute_uptime(Time.at(output.match(/\d+/)[0].to_i))
34
34
  end
35
35
  end
36
36
 
37
37
  def self.uptime_executable
38
- output = Facter::Core::Execution.exec("#{uptime_executable_cmd} 2>/dev/null", :on_fail => nil)
38
+ output = Facter::Core::Execution.execute("#{uptime_executable_cmd} 2>/dev/null", :on_fail => nil)
39
39
 
40
40
  if output
41
41
  up=0
@@ -1,6 +1,6 @@
1
1
  module Facter
2
2
  if not defined? FACTERVERSION then
3
- FACTERVERSION = '2.0.1-rc2'
3
+ FACTERVERSION = '2.0.1-rc3'
4
4
  end
5
5
 
6
6
  # Returns the running version of Facter.
@@ -62,11 +62,11 @@ describe Facter::Core::Execution::Base do
62
62
  end
63
63
  end
64
64
 
65
- describe "#exec" do
65
+ describe "#execute" do
66
66
 
67
67
  it "switches LANG to C when executing the command" do
68
68
  subject.expects(:with_env).with('LANG' => 'C')
69
- subject.exec('foo')
69
+ subject.execute('foo')
70
70
  end
71
71
 
72
72
  it "switches LC_ALL to C when executing the command"
@@ -74,18 +74,18 @@ describe Facter::Core::Execution::Base do
74
74
  it "expands the command before running it" do
75
75
  subject.stubs(:`).returns ''
76
76
  subject.expects(:expand_command).with('foo').returns '/bin/foo'
77
- subject.exec('foo')
77
+ subject.execute('foo')
78
78
  end
79
79
 
80
80
  describe "and the command is not present" do
81
81
  it "raises an error when the :on_fail behavior is :raise" do
82
82
  subject.expects(:expand_command).with('foo').returns nil
83
- expect { subject.exec('foo') }.to raise_error(Facter::Core::Execution::ExecutionFailure)
83
+ expect { subject.execute('foo') }.to raise_error(Facter::Core::Execution::ExecutionFailure)
84
84
  end
85
85
 
86
86
  it "returns the given value when :on_fail is set to a value" do
87
87
  subject.expects(:expand_command).with('foo').returns nil
88
- expect(subject.exec('foo', :on_fail => nil)).to be_nil
88
+ expect(subject.execute('foo', :on_fail => nil)).to be_nil
89
89
  end
90
90
  end
91
91
 
@@ -96,11 +96,11 @@ describe Facter::Core::Execution::Base do
96
96
  end
97
97
 
98
98
  it "raises an error when the :on_fail behavior is :raise" do
99
- expect { subject.exec('foo') }.to raise_error(Facter::Core::Execution::ExecutionFailure)
99
+ expect { subject.execute('foo') }.to raise_error(Facter::Core::Execution::ExecutionFailure)
100
100
  end
101
101
 
102
102
  it "returns the given value when :on_fail is set to a value" do
103
- expect(subject.exec('foo', :on_fail => nil)).to be_nil
103
+ expect(subject.execute('foo', :on_fail => nil)).to be_nil
104
104
  end
105
105
  end
106
106
 
@@ -112,21 +112,21 @@ describe Facter::Core::Execution::Base do
112
112
  Thread.expects(:new).yields
113
113
  Process.expects(:waitall).once
114
114
 
115
- subject.exec("foo", :on_fail => nil)
115
+ subject.execute("foo", :on_fail => nil)
116
116
  end
117
117
 
118
118
  it "returns the output of the command" do
119
119
  subject.expects(:`).with("/bin/foo").returns 'hi'
120
120
  subject.expects(:expand_command).with('foo').returns '/bin/foo'
121
121
 
122
- expect(subject.exec("foo")).to eq 'hi'
122
+ expect(subject.execute("foo")).to eq 'hi'
123
123
  end
124
124
 
125
125
  it "strips off trailing newlines" do
126
126
  subject.expects(:`).with("/bin/foo").returns "hi\n"
127
127
  subject.expects(:expand_command).with('foo').returns '/bin/foo'
128
128
 
129
- expect(subject.exec("foo")).to eq 'hi'
129
+ expect(subject.execute("foo")).to eq 'hi'
130
130
  end
131
131
  end
132
132
  end
@@ -30,8 +30,13 @@ describe Facter::Core::Execution do
30
30
  subject.expand_command('waffles')
31
31
  end
32
32
 
33
- it "delegates #exec to the implementation" do
34
- impl.expects(:exec).with('waffles', {})
33
+ it "delegates #exec to #execute" do
34
+ impl.expects(:execute).with('waffles', {:on_fail => nil})
35
35
  subject.exec('waffles')
36
36
  end
37
+
38
+ it "delegates #execute to the implementation" do
39
+ impl.expects(:execute).with('waffles', {})
40
+ subject.execute('waffles')
41
+ end
37
42
  end
@@ -24,11 +24,11 @@ describe "Domain name facts" do
24
24
  let(:dnsdomain_command) { "dnsdomainname 2> /dev/null" }
25
25
 
26
26
  def the_hostname_is(value)
27
- Facter::Core::Execution.stubs(:exec).with(hostname_command, {:on_fail => nil}).returns(value)
27
+ Facter::Core::Execution.stubs(:exec).with(hostname_command).returns(value)
28
28
  end
29
29
 
30
30
  def the_dnsdomainname_is(value)
31
- Facter::Core::Execution.stubs(:exec).with(dnsdomain_command, {:on_fail => nil}).returns(value)
31
+ Facter::Core::Execution.stubs(:exec).with(dnsdomain_command).returns(value)
32
32
  end
33
33
 
34
34
  before do
@@ -197,7 +197,7 @@ describe "Domain name facts" do
197
197
  it "should return nil" do
198
198
  expects_dnsdomains([nil])
199
199
 
200
- Facter::Core::Execution.stubs(:exec).with(hostname_command, {:on_fail => nil}).returns('sometest')
200
+ Facter::Core::Execution.stubs(:exec).with(hostname_command).returns('sometest')
201
201
  FileTest.stubs(:exists?).with("/etc/resolv.conf").returns(false)
202
202
 
203
203
  Facter.fact(:domain).value.should be_nil
@@ -288,8 +288,8 @@ describe "Domain name facts" do
288
288
 
289
289
  describe scenario[:scenario] do
290
290
  before(:each) do
291
- Facter::Core::Execution.stubs(:exec).with("hostname -f 2> /dev/null", {:on_fail => nil}).returns(scenario[:hostname])
292
- Facter::Core::Execution.stubs(:exec).with("dnsdomainname 2> /dev/null", {:on_fail => nil}).returns(scenario[:dnsdomainname])
291
+ Facter::Core::Execution.stubs(:exec).with("hostname -f 2> /dev/null").returns(scenario[:hostname])
292
+ Facter::Core::Execution.stubs(:exec).with("dnsdomainname 2> /dev/null").returns(scenario[:dnsdomainname])
293
293
  resolv_conf_contains(
294
294
  "search #{scenario[:resolve_search]}",
295
295
  "domain #{scenario[:resolve_domain]}"
@@ -6,35 +6,35 @@ require 'facter'
6
6
  describe "Hardwareisa fact" do
7
7
  it "should match uname -p on Linux" do
8
8
  Facter.fact(:kernel).stubs(:value).returns("Linux")
9
- Facter::Core::Execution.stubs(:exec).with("uname -p", anything).returns("Inky")
9
+ Facter::Core::Execution.stubs(:execute).with("uname -p", anything).returns("Inky")
10
10
 
11
11
  Facter.fact(:hardwareisa).value.should == "Inky"
12
12
  end
13
13
 
14
14
  it "should match uname -p on Darwin" do
15
15
  Facter.fact(:kernel).stubs(:value).returns("Darwin")
16
- Facter::Core::Execution.stubs(:exec).with("uname -p", anything).returns("Blinky")
16
+ Facter::Core::Execution.stubs(:execute).with("uname -p", anything).returns("Blinky")
17
17
 
18
18
  Facter.fact(:hardwareisa).value.should == "Blinky"
19
19
  end
20
20
 
21
21
  it "should match uname -p on SunOS" do
22
22
  Facter.fact(:kernel).stubs(:value).returns("SunOS")
23
- Facter::Core::Execution.stubs(:exec).with("uname -p", anything).returns("Pinky")
23
+ Facter::Core::Execution.stubs(:execute).with("uname -p", anything).returns("Pinky")
24
24
 
25
25
  Facter.fact(:hardwareisa).value.should == "Pinky"
26
26
  end
27
27
 
28
28
  it "should match uname -p on FreeBSD" do
29
29
  Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
30
- Facter::Core::Execution.stubs(:exec).with("uname -p", anything).returns("Clyde")
30
+ Facter::Core::Execution.stubs(:execute).with("uname -p", anything).returns("Clyde")
31
31
 
32
32
  Facter.fact(:hardwareisa).value.should == "Clyde"
33
33
  end
34
34
 
35
35
  it "should match uname -m on HP-UX" do
36
36
  Facter.fact(:kernel).stubs(:value).returns("HP-UX")
37
- Facter::Core::Execution.stubs(:exec).with("uname -m", anything).returns("Pac-Man")
37
+ Facter::Core::Execution.stubs(:execute).with("uname -m", anything).returns("Pac-Man")
38
38
 
39
39
  Facter.fact(:hardwareisa).value.should == "Pac-Man"
40
40
  end
@@ -6,7 +6,7 @@ require 'facter'
6
6
  describe "Hardwaremodel fact" do
7
7
  it "should match uname -m by default" do
8
8
  Facter.fact(:kernel).stubs(:value).returns("Darwin")
9
- Facter::Core::Execution.stubs(:exec).with("uname -m", anything).returns("Inky")
9
+ Facter::Core::Execution.stubs(:execute).with("uname -m", anything).returns("Inky")
10
10
 
11
11
  Facter.fact(:hardwaremodel).value.should == "Inky"
12
12
  end
@@ -11,17 +11,17 @@ describe "Hostname facts" do
11
11
  end
12
12
 
13
13
  it "should use the hostname command" do
14
- Facter::Core::Execution.expects(:exec).with('hostname').at_least_once
14
+ Facter::Core::Execution.expects(:execute).with('hostname').at_least_once
15
15
  Facter.fact(:hostname).value.should be_nil
16
16
  end
17
17
 
18
18
  it "should use hostname as the fact if unqualified" do
19
- Facter::Core::Execution.stubs(:exec).with('hostname').returns('host1')
19
+ Facter::Core::Execution.stubs(:execute).with('hostname').returns('host1')
20
20
  Facter.fact(:hostname).value.should == "host1"
21
21
  end
22
22
 
23
23
  it "should truncate the domain name if qualified" do
24
- Facter::Core::Execution.stubs(:exec).with('hostname').returns('host1.example.com')
24
+ Facter::Core::Execution.stubs(:execute).with('hostname').returns('host1.example.com')
25
25
  Facter.fact(:hostname).value.should == "host1"
26
26
  end
27
27
  end
@@ -33,7 +33,7 @@ describe "Hostname facts" do
33
33
  end
34
34
 
35
35
  it "should use scutil to get the hostname" do
36
- Facter::Core::Execution.expects(:exec).with('/usr/sbin/scutil --get LocalHostName', anything).returns("host1")
36
+ Facter::Core::Execution.expects(:execute).with('/usr/sbin/scutil --get LocalHostName', anything).returns("host1")
37
37
  Facter.fact(:hostname).value.should == "host1"
38
38
  end
39
39
  end
data/spec/unit/id_spec.rb CHANGED
@@ -12,7 +12,7 @@ describe "id fact" do
12
12
  it "should return the current user" do
13
13
  given_a_configuration_of(:is_windows => k == 'windows')
14
14
  Facter.fact(:kernel).stubs(:value).returns(k)
15
- Facter::Core::Execution.expects(:exec).once.with('whoami', anything).returns 'bar'
15
+ Facter::Core::Execution.expects(:execute).once.with('whoami', anything).returns 'bar'
16
16
 
17
17
  Facter.fact(:id).value.should == 'bar'
18
18
  end
@@ -21,8 +21,8 @@ describe "id fact" do
21
21
 
22
22
  it "should return the current user on Solaris" do
23
23
  given_a_configuration_of(:is_windows => false)
24
- Facter::Core::Execution.stubs(:exec).with('uname -s').returns('SunOS')
25
- Facter::Core::Execution.expects(:exec).once.with('/usr/xpg4/bin/id -un', anything).returns 'bar'
24
+ Facter.fact(:kernel).stubs(:value).returns 'SunOS'
25
+ Facter::Core::Execution.expects(:execute).once.with('/usr/xpg4/bin/id -un', anything).returns 'bar'
26
26
 
27
27
  Facter.fact(:id).value.should == 'bar'
28
28
  end
@@ -60,7 +60,7 @@ describe "ipaddress fact" do
60
60
  context "when you have no active network adapter" do
61
61
  it "should return nil if there are no active (or any) network adapters" do
62
62
  Facter::Util::WMI.expects(:execquery).with(Facter::Util::IP::Windows::WMI_IP_INFO_QUERY).returns([])
63
- Facter::Core::Execution.stubs(:exec)
63
+ Facter::Core::Execution.stubs(:execute)
64
64
 
65
65
  Facter.value(:ipaddress).should == nil
66
66
  end
@@ -21,7 +21,7 @@ describe "Kernel release fact" do
21
21
  describe "on AIX" do
22
22
  before do
23
23
  Facter.fact(:kernel).stubs(:value).returns("aix")
24
- Facter::Core::Execution.stubs(:exec).with('oslevel -s', anything).returns("test_kernel")
24
+ Facter::Core::Execution.stubs(:execute).with('oslevel -s', anything).returns("test_kernel")
25
25
  end
26
26
 
27
27
  it "should return the kernel release" do
@@ -32,7 +32,7 @@ describe "Kernel release fact" do
32
32
  describe "on HP-UX" do
33
33
  before do
34
34
  Facter.fact(:kernel).stubs(:value).returns("hp-ux")
35
- Facter::Core::Execution.stubs(:exec).with('uname -r').returns("B.11.31")
35
+ Facter::Core::Execution.stubs(:execute).with('uname -r').returns("B.11.31")
36
36
  end
37
37
 
38
38
  it "should remove preceding letters" do
@@ -43,7 +43,7 @@ describe "Kernel release fact" do
43
43
  describe "on everything else" do
44
44
  before do
45
45
  Facter.fact(:kernel).stubs(:value).returns("linux")
46
- Facter::Core::Execution.stubs(:exec).with('uname -r', anything).returns("test_kernel")
46
+ Facter::Core::Execution.stubs(:execute).with('uname -r', anything).returns("test_kernel")
47
47
  end
48
48
 
49
49
  it "should return the kernel release" do
@@ -7,7 +7,7 @@ describe "Kernel version fact" do
7
7
  describe "on Solaris/Sun OS" do
8
8
  before do
9
9
  Facter.fact(:kernel).stubs(:value).returns('sunos')
10
- Facter::Core::Execution.stubs(:exec).with('uname -v', anything).returns("1.234.5")
10
+ Facter::Core::Execution.stubs(:execute).with('uname -v', anything).returns("1.234.5")
11
11
  end
12
12
 
13
13
  it "should return the kernel version using 'uname -v'" do
@@ -11,7 +11,7 @@ describe "lsbdistcodename fact" do
11
11
  end
12
12
 
13
13
  it "returns the codename through lsb_release -c -s 2>/dev/null" do
14
- Facter::Core::Execution.impl.stubs(:exec).with('lsb_release -c -s 2>/dev/null', anything).returns 'n/a'
14
+ Facter::Core::Execution.impl.stubs(:execute).with('lsb_release -c -s 2>/dev/null', anything).returns 'n/a'
15
15
  expect(Facter.fact(:lsbdistcodename).value).to eq 'n/a'
16
16
  end
17
17
 
@@ -11,7 +11,7 @@ describe "lsbdistid fact" do
11
11
  end
12
12
 
13
13
  it "returns the id through lsb_release -i -s 2>/dev/null" do
14
- Facter::Core::Execution.impl.stubs(:exec).with('lsb_release -i -s 2>/dev/null', anything).returns 'Gentoo'
14
+ Facter::Core::Execution.impl.stubs(:execute).with('lsb_release -i -s 2>/dev/null', anything).returns 'Gentoo'
15
15
  expect(Facter.fact(:lsbdistid).value).to eq 'Gentoo'
16
16
  end
17
17
 
@@ -11,12 +11,12 @@ describe "lsbdistrelease fact" do
11
11
  end
12
12
 
13
13
  it "should return the release through lsb_release -r -s 2>/dev/null" do
14
- Facter::Core::Execution.stubs(:exec).with('lsb_release -r -s 2>/dev/null', anything).returns '2.1'
14
+ Facter::Core::Execution.stubs(:execute).with('lsb_release -r -s 2>/dev/null', anything).returns '2.1'
15
15
  Facter.fact(:lsbdistrelease).value.should == '2.1'
16
16
  end
17
17
 
18
18
  it "should return nil if lsb_release is not installed" do
19
- Facter::Core::Execution.stubs(:exec).with('lsb_release -r -s 2>/dev/null', anything).returns nil
19
+ Facter::Core::Execution.stubs(:execute).with('lsb_release -r -s 2>/dev/null', anything).returns nil
20
20
  Facter.fact(:lsbdistrelease).value.should be_nil
21
21
  end
22
22
  end
@@ -11,7 +11,7 @@ describe "lsbrelease fact" do
11
11
  end
12
12
 
13
13
  it "returns the release through lsb_release -v -s 2>/dev/null" do
14
- Facter::Core::Execution.impl.stubs(:exec).with('lsb_release -v -s 2>/dev/null', anything).returns 'n/a'
14
+ Facter::Core::Execution.impl.stubs(:execute).with('lsb_release -v -s 2>/dev/null', anything).returns 'n/a'
15
15
  expect(Facter.fact(:lsbrelease).value).to eq 'n/a'
16
16
  end
17
17
 
@@ -13,4 +13,26 @@ describe "OS Major Release fact" do
13
13
  end
14
14
  end
15
15
  end
16
+
17
+ context "on Solaris operatingsystems" do
18
+ before :each do
19
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
20
+ Facter.fact(:operatingsystem).stubs(:value).returns("Solaris")
21
+ end
22
+
23
+ it "should correctly derive from operatingsystemrelease on solaris 10" do
24
+ Facter.fact(:operatingsystemrelease).expects(:value).returns("10_u8")
25
+ Facter.fact(:operatingsystemmajrelease).value.should == "10"
26
+ end
27
+
28
+ it "should correctly derive from operatingsystemrelease on solaris 11 (old version scheme)" do
29
+ Facter.fact(:operatingsystemrelease).expects(:value).returns("11 11/11")
30
+ Facter.fact(:operatingsystemmajrelease).value.should == "11"
31
+ end
32
+
33
+ it "should correctly derive from operatingsystemrelease on solaris 11 (new version scheme)" do
34
+ Facter.fact(:operatingsystemrelease).expects(:value).returns("11.1")
35
+ Facter.fact(:operatingsystemmajrelease).value.should == "11"
36
+ end
37
+ end
16
38
  end
@@ -119,6 +119,8 @@ describe "Operating System Release fact" do
119
119
  'Solaris 10 10/09 s10x_u8wos_08a X86' => '10_u8',
120
120
  'Oracle Solaris 10 9/10 s10x_u9wos_14a X86' => '10_u9',
121
121
  'Oracle Solaris 10 8/11 s10x_u10wos_17b X86' => '10_u10',
122
+ 'Oracle Solaris 11 11/11 X86' => '11 11/11',
123
+ 'Oracle Solaris 11.1 SPARC' => '11.1'
122
124
  }.each do |fakeinput,expected_output|
123
125
  it "should be able to parse a release of #{fakeinput}" do
124
126
  Facter::Util::FileRead.stubs(:read).with('/etc/release').returns fakeinput
@@ -185,35 +185,35 @@ describe "Processor facts" do
185
185
 
186
186
  it "should be 2 on dual-processor Darwin box" do
187
187
  Facter.fact(:kernel).stubs(:value).returns("Darwin")
188
- Facter::Core::Execution.stubs(:exec).with("sysctl -n hw.ncpu", anything).returns('2')
188
+ Facter::Core::Execution.stubs(:execute).with("sysctl -n hw.ncpu", anything).returns('2')
189
189
 
190
190
  Facter.fact(:processorcount).value.should == "2"
191
191
  end
192
192
 
193
193
  it "should be 2 on dual-processor OpenBSD box" do
194
194
  Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
195
- Facter::Core::Execution.stubs(:exec).with("sysctl -n hw.ncpu", anything).returns('2')
195
+ Facter::Core::Execution.stubs(:execute).with("sysctl -n hw.ncpu", anything).returns('2')
196
196
 
197
197
  Facter.fact(:processorcount).value.should == "2"
198
198
  end
199
199
 
200
200
  it "should be 2 on dual-processor FreeBSD box" do
201
201
  Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
202
- Facter::Core::Execution.stubs(:exec).with("sysctl -n hw.ncpu", anything).returns('2')
202
+ Facter::Core::Execution.stubs(:execute).with("sysctl -n hw.ncpu", anything).returns('2')
203
203
 
204
204
  Facter.fact(:processorcount).value.should == "2"
205
205
  end
206
206
 
207
207
  it "should print the correct CPU Model on FreeBSD" do
208
208
  Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
209
- Facter::Core::Execution.stubs(:exec).with("sysctl -n hw.model", anything).returns('SomeVendor CPU 3GHz')
209
+ Facter::Core::Execution.stubs(:execute).with("sysctl -n hw.model", anything).returns('SomeVendor CPU 3GHz')
210
210
 
211
211
  Facter.fact(:processor).value.should == "SomeVendor CPU 3GHz"
212
212
  end
213
213
 
214
214
  it "should be 2 on dual-processor DragonFly box" do
215
215
  Facter.fact(:kernel).stubs(:value).returns("DragonFly")
216
- Facter::Core::Execution.stubs(:exec).with("sysctl -n hw.ncpu", anything).returns('2')
216
+ Facter::Core::Execution.stubs(:execute).with("sysctl -n hw.ncpu", anything).returns('2')
217
217
 
218
218
  Facter.fact(:processorcount).value.should == "2"
219
219
  end
@@ -6,21 +6,21 @@ require 'facter'
6
6
  describe "Uniqueid fact" do
7
7
  it "should match hostid on Solaris" do
8
8
  Facter.fact(:kernel).stubs(:value).returns("SunOS")
9
- Facter::Core::Execution.stubs(:exec).with("hostid", anything).returns("Larry")
9
+ Facter::Core::Execution.stubs(:execute).with("hostid", anything).returns("Larry")
10
10
 
11
11
  Facter.fact(:uniqueid).value.should == "Larry"
12
12
  end
13
13
 
14
14
  it "should match hostid on Linux" do
15
15
  Facter.fact(:kernel).stubs(:value).returns("Linux")
16
- Facter::Core::Execution.stubs(:exec).with("hostid", anything).returns("Curly")
16
+ Facter::Core::Execution.stubs(:execute).with("hostid", anything).returns("Curly")
17
17
 
18
18
  Facter.fact(:uniqueid).value.should == "Curly"
19
19
  end
20
20
 
21
21
  it "should match hostid on AIX" do
22
22
  Facter.fact(:kernel).stubs(:value).returns("AIX")
23
- Facter::Core::Execution.stubs(:exec).with("hostid", anything).returns("Moe")
23
+ Facter::Core::Execution.stubs(:execute).with("hostid", anything).returns("Moe")
24
24
 
25
25
  Facter.fact(:uniqueid).value.should == "Moe"
26
26
  end
@@ -74,7 +74,7 @@ describe Facter::Util::Resolution do
74
74
  describe "and the code is a string" do
75
75
  it "returns the result of executing the code" do
76
76
  resolution.setcode "/bin/foo"
77
- Facter::Core::Execution.expects(:exec).once.with("/bin/foo", anything).returns "yup"
77
+ Facter::Core::Execution.expects(:execute).once.with("/bin/foo", anything).returns "yup"
78
78
 
79
79
  expect(resolution.value).to eq "yup"
80
80
  end
@@ -47,7 +47,7 @@ describe Facter::Util::SolarisZones do
47
47
 
48
48
  describe '#refresh' do
49
49
  it 'executes the zoneadm_cmd' do
50
- Facter::Core::Execution.expects(:exec).with(subject.zoneadm_cmd, {:on_fail => nil}).returns(zone_list)
50
+ Facter::Core::Execution.expects(:execute).with(subject.zoneadm_cmd, {:on_fail => nil}).returns(zone_list)
51
51
  subject.refresh
52
52
  end
53
53
  end
@@ -69,7 +69,7 @@ describe Facter::Util::SolarisZones do
69
69
  it 'uses a single read of the system information for all of the dynamically generated zone facts' do
70
70
  given_initial_zone_facts # <= single read happens here
71
71
 
72
- Facter::Core::Execution.expects(:exec).never
72
+ Facter::Core::Execution.expects(:execute).never
73
73
  Facter.fact(:zone_zoneA_id).value
74
74
  Facter.fact(:zone_local_id).value
75
75
  end
@@ -101,7 +101,7 @@ describe Facter::Util::SolarisZones do
101
101
  given_initial_zone_facts
102
102
  when_facts_have_been_resolved_then_flushed
103
103
 
104
- Facter::Core::Execution.expects(:exec).once.returns(zone_list2)
104
+ Facter::Core::Execution.expects(:execute).once.returns(zone_list2)
105
105
  Facter.fact(:zones).value
106
106
  Facter.fact(:zone_zoneA_id).value
107
107
  Facter.fact(:zone_local_id).value
@@ -111,7 +111,7 @@ describe Facter::Util::SolarisZones do
111
111
  end
112
112
 
113
113
  def given_initial_zone_facts
114
- Facter::Core::Execution.stubs(:exec).
114
+ Facter::Core::Execution.stubs(:execute).
115
115
  with(subject.zoneadm_cmd, {:on_fail => nil}).
116
116
  returns(zone_list)
117
117
  described_class.add_facts
@@ -121,7 +121,7 @@ describe Facter::Util::SolarisZones do
121
121
  Facter.fact(:zones).value
122
122
  Facter.fact(:zone_zoneA_id).value
123
123
  Facter.fact(:zone_local_id).value
124
- Facter::Core::Execution.stubs(:exec).returns(zone_list2)
124
+ Facter::Core::Execution.stubs(:execute).returns(zone_list2)
125
125
  Facter.flush
126
126
  end
127
127
  end
@@ -99,14 +99,14 @@ describe Facter::Util::Uptime do
99
99
 
100
100
  test_cases.each do |uptime, expected|
101
101
  it "should return #{expected} for #{uptime}" do
102
- Facter::Core::Execution.stubs(:exec).with('uptime 2>/dev/null', {:on_fail => nil}).returns(uptime)
102
+ Facter::Core::Execution.stubs(:execute).with('uptime 2>/dev/null', {:on_fail => nil}).returns(uptime)
103
103
  Facter.fact(:uptime_seconds).value.should == expected
104
104
  end
105
105
  end
106
106
 
107
107
  describe "nor is 'uptime' command" do
108
108
  before :each do
109
- Facter::Core::Execution.stubs(:exec).with('uptime 2>/dev/null', {:on_fail => nil}).returns(nil)
109
+ Facter::Core::Execution.stubs(:execute).with('uptime 2>/dev/null', {:on_fail => nil}).returns(nil)
110
110
  end
111
111
 
112
112
  it "should return nil" do
@@ -7,7 +7,7 @@ describe "zonename fact" do
7
7
 
8
8
  it "should return global zone" do
9
9
  Facter.fact(:kernel).stubs(:value).returns("SunOS")
10
- Facter::Core::Execution.stubs(:exec).with("zonename", anything).returns('global')
10
+ Facter::Core::Execution.stubs(:execute).with("zonename", anything).returns('global')
11
11
 
12
12
  Facter.fact(:zonename).value.should == "global"
13
13
  end
@@ -10,7 +10,7 @@ describe "on Solaris" do
10
10
  -:local:configured:/::native:shared
11
11
  -:zoneA:stopped:/::native:shared
12
12
  EOF
13
- Facter::Core::Execution.stubs(:exec).with('/usr/sbin/zoneadm list -cp', {:on_fail => nil}).returns(zone_list)
13
+ Facter::Core::Execution.stubs(:execute).with('/usr/sbin/zoneadm list -cp', {:on_fail => nil}).returns(zone_list)
14
14
  Facter.collection.internal_loader.load(:zones)
15
15
  end
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1.rc2
4
+ version: 2.0.1.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-03-25 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: You can prove anything with facts!
14
14
  email: info@puppetlabs.com