facter 1.7.6 → 2.0.1.rc1

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 (155) hide show
  1. checksums.yaml +7 -0
  2. data/COMMITTERS.md +194 -0
  3. data/CONTRIBUTING.md +63 -235
  4. data/Gemfile +12 -8
  5. data/README.md +1 -2
  6. data/Rakefile +1 -1
  7. data/bin/facter +0 -4
  8. data/ext/build_defaults.yaml +2 -2
  9. data/ext/project_data.yaml +18 -0
  10. data/install.rb +1 -16
  11. data/lib/facter.rb +171 -171
  12. data/lib/facter/application.rb +65 -54
  13. data/lib/facter/core/aggregate.rb +220 -0
  14. data/lib/facter/core/directed_graph.rb +46 -0
  15. data/lib/facter/core/execution.rb +100 -0
  16. data/lib/facter/core/execution/base.rb +73 -0
  17. data/lib/facter/core/execution/posix.rb +50 -0
  18. data/lib/facter/core/execution/windows.rb +57 -0
  19. data/lib/facter/core/logging.rb +169 -0
  20. data/lib/facter/core/resolvable.rb +94 -0
  21. data/lib/facter/core/suitable.rb +117 -0
  22. data/lib/facter/domain.rb +15 -9
  23. data/lib/facter/filesystems.rb +1 -1
  24. data/lib/facter/hardwaremodel.rb +1 -1
  25. data/lib/facter/hostname.rb +3 -3
  26. data/lib/facter/interfaces.rb +6 -1
  27. data/lib/facter/ipaddress.rb +2 -2
  28. data/lib/facter/kernel.rb +1 -1
  29. data/lib/facter/kernelrelease.rb +1 -1
  30. data/lib/facter/ldom.rb +1 -1
  31. data/lib/facter/lsbdistcodename.rb +1 -1
  32. data/lib/facter/lsbdistdescription.rb +1 -1
  33. data/lib/facter/lsbdistid.rb +1 -1
  34. data/lib/facter/lsbdistrelease.rb +1 -1
  35. data/lib/facter/lsbrelease.rb +1 -1
  36. data/lib/facter/macaddress.rb +1 -14
  37. data/lib/facter/macosx.rb +2 -2
  38. data/lib/facter/memory.rb +8 -19
  39. data/lib/facter/operatingsystem.rb +1 -1
  40. data/lib/facter/operatingsystemrelease.rb +34 -1
  41. data/lib/facter/physicalprocessorcount.rb +6 -6
  42. data/lib/facter/processor.rb +11 -10
  43. data/lib/facter/selinux.rb +4 -15
  44. data/lib/facter/ssh.rb +5 -2
  45. data/lib/facter/util/architecture.rb +2 -2
  46. data/lib/facter/util/collection.rb +42 -38
  47. data/lib/facter/util/config.rb +19 -9
  48. data/lib/facter/util/confine.rb +34 -4
  49. data/lib/facter/util/ec2.rb +1 -1
  50. data/lib/facter/util/fact.rb +108 -36
  51. data/lib/facter/util/file_read.rb +7 -6
  52. data/lib/facter/util/formatter.rb +38 -0
  53. data/lib/facter/util/ip.rb +3 -3
  54. data/lib/facter/util/loader.rb +62 -42
  55. data/lib/facter/util/macosx.rb +7 -8
  56. data/lib/facter/util/manufacturer.rb +3 -3
  57. data/lib/facter/util/memory.rb +13 -13
  58. data/lib/facter/util/monkey_patches.rb +0 -31
  59. data/lib/facter/util/netmask.rb +3 -3
  60. data/lib/facter/util/normalization.rb +94 -0
  61. data/lib/facter/util/nothing_loader.rb +3 -6
  62. data/lib/facter/util/parser.rb +3 -5
  63. data/lib/facter/util/plist/generator.rb +1 -1
  64. data/lib/facter/util/processor.rb +15 -15
  65. data/lib/facter/util/resolution.rb +112 -289
  66. data/lib/facter/util/solaris_zones.rb +4 -4
  67. data/lib/facter/util/uptime.rb +8 -3
  68. data/lib/facter/util/values.rb +67 -1
  69. data/lib/facter/util/virtual.rb +10 -10
  70. data/lib/facter/util/xendomains.rb +1 -1
  71. data/lib/facter/version.rb +42 -39
  72. data/lib/facter/virtual.rb +6 -7
  73. data/lib/facter/zfs_version.rb +3 -3
  74. data/lib/facter/zpool_version.rb +3 -3
  75. data/spec/fixtures/unit/netmask/darwin_10_8_5.txt +30 -0
  76. data/spec/unit/application_spec.rb +46 -1
  77. data/spec/unit/core/aggregate_spec.rb +125 -0
  78. data/spec/unit/core/directed_graph_spec.rb +79 -0
  79. data/spec/unit/core/execution/base_spec.rb +119 -0
  80. data/spec/unit/core/execution/posix_spec.rb +86 -0
  81. data/spec/unit/core/execution/windows_spec.rb +106 -0
  82. data/spec/unit/core/execution_spec.rb +37 -0
  83. data/spec/unit/core/logging_spec.rb +104 -0
  84. data/spec/unit/core/resolvable_spec.rb +81 -0
  85. data/spec/unit/core/suitable_spec.rb +96 -0
  86. data/spec/unit/domain_spec.rb +5 -5
  87. data/spec/unit/facter_spec.rb +61 -222
  88. data/spec/unit/filesystems_spec.rb +2 -2
  89. data/spec/unit/hardwareisa_spec.rb +5 -5
  90. data/spec/unit/hardwaremodel_spec.rb +1 -1
  91. data/spec/unit/hostname_spec.rb +4 -4
  92. data/spec/unit/id_spec.rb +3 -3
  93. data/spec/unit/interfaces_spec.rb +10 -0
  94. data/spec/unit/ipaddress6_spec.rb +4 -4
  95. data/spec/unit/ipaddress_spec.rb +1 -1
  96. data/spec/unit/kernel_spec.rb +2 -2
  97. data/spec/unit/kernelmajversion_spec.rb +1 -1
  98. data/spec/unit/kernelrelease_spec.rb +4 -4
  99. data/spec/unit/kernelversion_spec.rb +2 -2
  100. data/spec/unit/ldom_spec.rb +2 -2
  101. data/spec/unit/lsbdistcodename_spec.rb +2 -2
  102. data/spec/unit/lsbdistdescription_spec.rb +2 -2
  103. data/spec/unit/lsbdistid_spec.rb +2 -2
  104. data/spec/unit/lsbdistrelease_spec.rb +2 -2
  105. data/spec/unit/lsbrelease_spec.rb +2 -2
  106. data/spec/unit/manufacturer_spec.rb +1 -1
  107. data/spec/unit/memory_spec.rb +24 -31
  108. data/spec/unit/netmask_spec.rb +9 -0
  109. data/spec/unit/operatingsystem_spec.rb +1 -1
  110. data/spec/unit/operatingsystemrelease_spec.rb +62 -4
  111. data/spec/unit/physicalprocessorcount_spec.rb +10 -10
  112. data/spec/unit/processor_spec.rb +11 -11
  113. data/spec/unit/selinux_spec.rb +2 -8
  114. data/spec/unit/ssh_spec.rb +3 -2
  115. data/spec/unit/uniqueid_spec.rb +3 -3
  116. data/spec/unit/util/collection_spec.rb +37 -35
  117. data/spec/unit/util/config_spec.rb +20 -0
  118. data/spec/unit/util/confine_spec.rb +21 -0
  119. data/spec/unit/util/directory_loader_spec.rb +1 -0
  120. data/spec/unit/util/ec2_spec.rb +6 -6
  121. data/spec/unit/util/fact_spec.rb +92 -90
  122. data/spec/unit/util/ip_spec.rb +2 -2
  123. data/spec/unit/util/loader_spec.rb +127 -186
  124. data/spec/unit/util/macaddress_spec.rb +2 -2
  125. data/spec/unit/util/macosx_spec.rb +8 -8
  126. data/spec/unit/util/manufacturer_spec.rb +3 -3
  127. data/spec/unit/util/normalization_spec.rb +113 -0
  128. data/spec/unit/util/parser_spec.rb +25 -3
  129. data/spec/unit/util/processor_spec.rb +2 -2
  130. data/spec/unit/util/resolution_spec.rb +60 -631
  131. data/spec/unit/util/solaris_zones_spec.rb +5 -5
  132. data/spec/unit/util/uptime_spec.rb +1 -1
  133. data/spec/unit/util/values_spec.rb +131 -0
  134. data/spec/unit/util/virtual_spec.rb +16 -16
  135. data/spec/unit/util/xendomains_spec.rb +2 -2
  136. data/spec/unit/virtual_spec.rb +39 -39
  137. data/spec/unit/zfs_version_spec.rb +11 -11
  138. data/spec/unit/zonename_spec.rb +2 -2
  139. data/spec/unit/zones_spec.rb +1 -1
  140. data/spec/unit/zpool_version_spec.rb +11 -11
  141. metadata +466 -447
  142. data/lib/facter/util/cfpropertylist.rb +0 -6
  143. data/lib/facter/util/cfpropertylist/LICENSE +0 -19
  144. data/lib/facter/util/cfpropertylist/README +0 -44
  145. data/lib/facter/util/cfpropertylist/Rakefile +0 -44
  146. data/lib/facter/util/cfpropertylist/THANKS +0 -7
  147. data/lib/facter/util/cfpropertylist/lib/cfpropertylist.rb +0 -6
  148. data/lib/facter/util/cfpropertylist/lib/rbBinaryCFPropertyList.rb +0 -562
  149. data/lib/facter/util/cfpropertylist/lib/rbCFPlistError.rb +0 -26
  150. data/lib/facter/util/cfpropertylist/lib/rbCFPropertyList.rb +0 -407
  151. data/lib/facter/util/cfpropertylist/lib/rbCFTypes.rb +0 -244
  152. data/lib/facter/util/cfpropertylist/lib/rbLibXMLParser.rb +0 -135
  153. data/lib/facter/util/cfpropertylist/lib/rbNokogiriParser.rb +0 -140
  154. data/lib/facter/util/cfpropertylist/lib/rbREXMLParser.rb +0 -136
  155. data/spec/unit/util/monkey_patches_spec.rb +0 -42
@@ -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::Util::Resolution.expects(:exec).with(subject.zoneadm_cmd).returns(zone_list)
50
+ Facter::Core::Execution.expects(:exec).with(subject.zoneadm_cmd).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::Util::Resolution.expects(:exec).never
72
+ Facter::Core::Execution.expects(:exec).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::Util::Resolution.expects(:exec).once.returns(zone_list2)
104
+ Facter::Core::Execution.expects(:exec).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::Util::Resolution.stubs(:exec).
114
+ Facter::Core::Execution.stubs(:exec).
115
115
  with(subject.zoneadm_cmd).
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::Util::Resolution.stubs(:exec).returns(zone_list2)
124
+ Facter::Core::Execution.stubs(:exec).returns(zone_list2)
125
125
  Facter.flush
126
126
  end
127
127
  end
@@ -99,7 +99,7 @@ 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::Util::Resolution.stubs(:exec).with('uptime 2>/dev/null').returns(uptime)
102
+ Facter::Core::Execution.stubs(:exec).with('uptime 2>/dev/null').returns(uptime)
103
103
  Facter.fact(:uptime_seconds).value.should == expected
104
104
  end
105
105
  end
@@ -0,0 +1,131 @@
1
+ require 'spec_helper'
2
+ require 'facter/util/values'
3
+
4
+ describe Facter::Util::Values do
5
+ describe 'deep_freeze' do
6
+ it "it dups and freezes strings" do
7
+ input = "hi"
8
+ output = described_class.deep_freeze(input)
9
+ expect(input).to_not be_frozen
10
+ expect(output).to be_frozen
11
+ end
12
+
13
+ it "freezes arrays and each element in the array" do
14
+ input = %w[one two three]
15
+ output = described_class.deep_freeze(input)
16
+
17
+ input.each { |entry| expect(entry).to_not be_frozen }
18
+ output.each { |entry| expect(entry).to be_frozen }
19
+
20
+ expect(input).to_not be_frozen
21
+ expect(output).to be_frozen
22
+ end
23
+
24
+ it "freezes hashes and each key and value in the hash" do
25
+ input = {'one' => 'two', 'three' => 'four'}
26
+
27
+ output = described_class.deep_freeze(input)
28
+
29
+ input.each_pair do |key, val|
30
+ # Ruby freezes all string keys, so these will always be frozen
31
+ expect(key).to be_frozen
32
+ expect(val).to_not be_frozen
33
+ end
34
+
35
+ output.each_pair do |key, val|
36
+ expect(key).to be_frozen
37
+ expect(val).to be_frozen
38
+ end
39
+
40
+ expect(input).to_not be_frozen
41
+ expect(output).to be_frozen
42
+ end
43
+
44
+ it "raises an error when given a structure that cannot be deeply frozen" do
45
+ expect {
46
+ described_class.deep_freeze(Set.new)
47
+ }.to raise_error(Facter::Util::Values::DeepFreezeError, /Cannot deep freeze.*Set/)
48
+ end
49
+ end
50
+
51
+ describe 'deep_merge' do
52
+ it "non-destructively concatenates arrays" do
53
+ first = %w[foo bar]
54
+ second = %w[baz quux]
55
+
56
+ expect(described_class.deep_merge(first, second)).to eq %w[foo bar baz quux]
57
+ expect(first).to eq %w[foo bar]
58
+ expect(second).to eq %w[baz quux]
59
+ end
60
+
61
+ it "returns the left value if the right value is nil" do
62
+ expect(described_class.deep_merge("left", nil)).to eq "left"
63
+ end
64
+
65
+ it "returns the right value if the left value is nil" do
66
+ expect(described_class.deep_merge(nil, "right")).to eq "right"
67
+ end
68
+
69
+ it "returns nil if both values are nil" do
70
+ expect(described_class.deep_merge(nil, nil)).to be_nil
71
+ end
72
+
73
+ describe "with hashes" do
74
+ it "merges when keys do not overlap" do
75
+
76
+ first = {:foo => 'bar'}
77
+ second = {:baz => 'quux'}
78
+
79
+ expect(described_class.deep_merge(first, second)).to eq(:foo => 'bar', :baz => 'quux')
80
+ expect(first).to eq(:foo => 'bar')
81
+ expect(second).to eq(:baz => 'quux')
82
+ end
83
+
84
+ it "concatenates arrays when both keys are arrays" do
85
+ first = {:foo => %w[bar]}
86
+ second = {:foo => %w[baz quux]}
87
+
88
+ expect(described_class.deep_merge(first, second)).to eq(:foo => %w[bar baz quux])
89
+ expect(first).to eq(:foo => %w[bar])
90
+ expect(second).to eq(:foo => %w[baz quux])
91
+ end
92
+
93
+ it "merges hashes when both keys are hashes" do
94
+ first = {:foo => {:pb => 'lead', :ag => 'silver'}}
95
+ second = {:foo => {:au => 'gold', :na => 'sodium'}}
96
+
97
+ expect(described_class.deep_merge(first, second)).to eq(
98
+ :foo => {
99
+ :pb => 'lead',
100
+ :ag => 'silver',
101
+ :au => 'gold',
102
+ :na => 'sodium'
103
+ }
104
+ )
105
+ end
106
+
107
+ it "prints the data structure path if an error is raised" do
108
+ first = {:foo => {:bar => {:baz => {:quux => true}}}}
109
+ second = {:foo => {:bar => {:baz => {:quux => false}}}}
110
+
111
+ expect {
112
+ described_class.deep_merge(first, second)
113
+ }.to raise_error(Facter::Util::Values::DeepMergeError, /Cannot merge .*at .*foo.*bar.*baz.*quux/)
114
+ end
115
+ end
116
+
117
+ describe "with unmergable scalar values" do
118
+ [
119
+ [true, false],
120
+ [1, 2],
121
+ ['up', 'down']
122
+ ].each do |(left, right)|
123
+ it "raises an error when merging #{left}:#{left.class} and #{right}:#{right.class}" do
124
+ expect {
125
+ described_class.deep_merge(left, right)
126
+ }.to raise_error(Facter::Util::Values::DeepMergeError, /Cannot merge #{left.inspect}:#{left.class} and #{right.inspect}:#{right.class}/)
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
@@ -30,31 +30,31 @@ describe Facter::Util::Virtual do
30
30
  it "should identify openvzhn when /proc/self/status has envID of 0" do
31
31
  Facter::Util::Virtual.stubs(:openvz?).returns(true)
32
32
  FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
33
- Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 0")
33
+ Facter::Core::Execution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 0")
34
34
  Facter::Util::Virtual.openvz_type().should == "openvzhn"
35
35
  end
36
36
 
37
37
  it "should identify openvzve when /proc/self/status has envID of 0" do
38
38
  Facter::Util::Virtual.stubs(:openvz?).returns(true)
39
39
  FileTest.stubs(:exists?).with('/proc/self/status').returns(true)
40
- Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 666")
40
+ Facter::Core::Execution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 666")
41
41
  Facter::Util::Virtual.openvz_type().should == "openvzve"
42
42
  end
43
43
 
44
44
  it "should not attempt to identify openvz when /proc/self/status has no envID" do
45
45
  Facter::Util::Virtual.stubs(:openvz?).returns(true)
46
46
  FileTest.stubs(:exists?).with('/proc/self/status').returns(true)
47
- Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("")
47
+ Facter::Core::Execution.stubs(:exec).with('grep "envID" /proc/self/status').returns("")
48
48
  Facter::Util::Virtual.openvz_type().should be_nil
49
49
  end
50
50
 
51
51
  it "should identify Solaris zones when non-global zone" do
52
- Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("somezone")
52
+ Facter::Core::Execution.stubs(:exec).with("/sbin/zonename").returns("somezone")
53
53
  Facter::Util::Virtual.should be_zone
54
54
  end
55
55
 
56
56
  it "should not identify Solaris zones when global zone" do
57
- Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("global")
57
+ Facter::Core::Execution.stubs(:exec).with("/sbin/zonename").returns("global")
58
58
  Facter::Util::Virtual.should_not be_zone
59
59
  end
60
60
 
@@ -91,7 +91,7 @@ describe Facter::Util::Virtual do
91
91
 
92
92
  it "should identify kvm" do
93
93
  Facter::Util::Virtual.stubs(:kvm?).returns(true)
94
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("something")
94
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("something")
95
95
  Facter::Util::Virtual.kvm_type().should == "kvm"
96
96
  end
97
97
 
@@ -202,38 +202,38 @@ describe Facter::Util::Virtual do
202
202
  it "should detect kvm on FreeBSD" do
203
203
  FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false)
204
204
  Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
205
- Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns("QEMU Virtual CPU version 0.12.4")
205
+ Facter::Core::Execution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns("QEMU Virtual CPU version 0.12.4")
206
206
  Facter::Util::Virtual.should be_kvm
207
207
  end
208
208
 
209
209
  it "should detect kvm on OpenBSD" do
210
210
  FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false)
211
211
  Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
212
- Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns('QEMU Virtual CPU version (cpu64-rhel6) ("AuthenticAMD" 686-class, 512KB L2 cache)')
212
+ Facter::Core::Execution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns('QEMU Virtual CPU version (cpu64-rhel6) ("AuthenticAMD" 686-class, 512KB L2 cache)')
213
213
  Facter::Util::Virtual.should be_kvm
214
214
  end
215
215
 
216
216
  it "should identify FreeBSD jail when in jail" do
217
217
  Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
218
- Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("1")
218
+ Facter::Core::Execution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("1")
219
219
  Facter::Util::Virtual.should be_jail
220
220
  end
221
221
 
222
222
  it "should not identify GNU/kFreeBSD jail when not in jail" do
223
223
  Facter.fact(:kernel).stubs(:value).returns("GNU/kFreeBSD")
224
- Facter::Util::Resolution.stubs(:exec).with("/bin/sysctl -n security.jail.jailed").returns("0")
224
+ Facter::Core::Execution.stubs(:exec).with("/bin/sysctl -n security.jail.jailed").returns("0")
225
225
  Facter::Util::Virtual.should_not be_jail
226
226
  end
227
227
 
228
228
  it "should detect hpvm on HP-UX" do
229
229
  Facter.fact(:kernel).stubs(:value).returns("HP-UX")
230
- Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server Integrity Virtual Machine')
230
+ Facter::Core::Execution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server Integrity Virtual Machine')
231
231
  Facter::Util::Virtual.should be_hpvm
232
232
  end
233
233
 
234
234
  it "should not detect hpvm on HP-UX when not in hpvm" do
235
235
  Facter.fact(:kernel).stubs(:value).returns("HP-UX")
236
- Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server rx660')
236
+ Facter::Core::Execution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server rx660')
237
237
  Facter::Util::Virtual.should_not be_hpvm
238
238
  end
239
239
 
@@ -263,8 +263,8 @@ describe Facter::Util::Virtual do
263
263
  shared_examples_for "virt-what" do |kernel, path, null_device|
264
264
  before(:each) do
265
265
  Facter.fact(:kernel).stubs(:value).returns(kernel)
266
- Facter::Util::Resolution.expects(:which).with("virt-what").returns(path)
267
- Facter::Util::Resolution.expects(:exec).with("#{path} 2>#{null_device}")
266
+ Facter::Core::Execution.expects(:which).with("virt-what").returns(path)
267
+ Facter::Core::Execution.expects(:exec).with("#{path} 2>#{null_device}")
268
268
  end
269
269
 
270
270
  it "on #{kernel} virt-what is at #{path} and stderr is sent to #{null_device}" do
@@ -278,8 +278,8 @@ describe Facter::Util::Virtual do
278
278
  it "should strip out warnings on stdout from virt-what" do
279
279
  virt_what_warning = "virt-what: this script must be run as root"
280
280
  Facter.fact(:kernel).stubs(:value).returns('linux')
281
- Facter::Util::Resolution.expects(:which).with('virt-what').returns "/usr/bin/virt-what"
282
- Facter::Util::Resolution.expects(:exec).with('/usr/bin/virt-what 2>/dev/null').returns virt_what_warning
281
+ Facter::Core::Execution.expects(:which).with('virt-what').returns "/usr/bin/virt-what"
282
+ Facter::Core::Execution.expects(:exec).with('/usr/bin/virt-what 2>/dev/null').returns virt_what_warning
283
283
  Facter::Util::Virtual.virt_what.should_not match /^virt-what: /
284
284
  end
285
285
  end
@@ -7,13 +7,13 @@ describe Facter::Util::Xendomains do
7
7
  describe ".get_domains" do
8
8
  it "should return a list of running Xen Domains on Xen0" do
9
9
  xen0_domains = my_fixture_read("xendomains")
10
- Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains)
10
+ Facter::Core::Execution.stubs(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains)
11
11
  Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
12
12
  end
13
13
 
14
14
  describe "when xm list isn't executable" do
15
15
  it "should be nil" do
16
- Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(nil)
16
+ Facter::Core::Execution.stubs(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(nil)
17
17
  Facter::Util::Xendomains.get_domains.should == nil
18
18
  end
19
19
  end
@@ -78,7 +78,7 @@ describe "Virtual fact" do
78
78
  Facter.fact(:kernel).stubs(:value).returns("Linux")
79
79
  Facter.fact(:operatingsystem).stubs(:value).returns("Linux")
80
80
 
81
- Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false
81
+ Facter::Core::Execution.stubs(:exec).with("vmware -v").returns false
82
82
 
83
83
  FileTest.stubs(:exists?).with("/proc/sys/xen").returns false
84
84
  FileTest.stubs(:exists?).with("/sys/bus/xen").returns false
@@ -97,18 +97,18 @@ describe "Virtual fact" do
97
97
  end
98
98
 
99
99
  it "should be vmware with VMware vendor name from lspci 2>/dev/null" do
100
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter")
100
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns("00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter")
101
101
  Facter.fact(:virtual).value.should == "vmware"
102
102
  end
103
103
 
104
104
  it "should be virtualbox with VirtualBox vendor name from lspci 2>/dev/null" do
105
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
105
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
106
106
  Facter.fact(:virtual).value.should == "virtualbox"
107
107
  end
108
108
 
109
109
  it "should be vmware with VMWare vendor name from dmidecode" do
110
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
111
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
110
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
111
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
112
112
  Facter.fact(:virtual).value.should == "vmware"
113
113
  end
114
114
 
@@ -128,50 +128,50 @@ describe "Virtual fact" do
128
128
  end
129
129
 
130
130
  it "should be xenhvm with Xen HVM vendor name from lspci 2>/dev/null" do
131
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
131
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
132
132
  Facter.fact(:virtual).value.should == "xenhvm"
133
133
  end
134
134
 
135
135
  it "should be xenhvm with Xen HVM vendor name from dmidecode" do
136
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
137
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU")
136
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
137
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU")
138
138
  Facter.fact(:virtual).value.should == "xenhvm"
139
139
  end
140
140
 
141
141
  it "should be parallels with Parallels vendor name from dmidecode" do
142
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
143
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device Information\nType: Video\nStatus: Disabled\nDescription: Parallels Video Adapter")
142
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
143
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device Information\nType: Video\nStatus: Disabled\nDescription: Parallels Video Adapter")
144
144
  Facter.fact(:virtual).value.should == "parallels"
145
145
  end
146
146
 
147
147
  it "should be virtualbox with VirtualBox vendor name from dmidecode" do
148
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
149
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine")
148
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
149
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine")
150
150
  Facter.fact(:virtual).value.should == "virtualbox"
151
151
  end
152
152
 
153
153
  it "should be rhev with RHEV Hypervisor product name from dmidecode" do
154
154
  Facter.fact(:kernel).stubs(:value).returns("Linux")
155
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
156
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Product Name: RHEV Hypervisor")
155
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
156
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Product Name: RHEV Hypervisor")
157
157
  Facter.fact(:virtual).value.should == "rhev"
158
158
  end
159
159
 
160
160
  it "should be ovirt with oVirt Node product name from dmidecode" do
161
161
  Facter.fact(:kernel).stubs(:value).returns("Linux")
162
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
163
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Product Name: oVirt Node")
162
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
163
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("Product Name: oVirt Node")
164
164
  Facter.fact(:virtual).value.should == "ovirt"
165
165
  end
166
166
 
167
167
  it "should be hyperv with Microsoft vendor name from lspci 2>/dev/null" do
168
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA")
168
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns("00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA")
169
169
  Facter.fact(:virtual).value.should == "hyperv"
170
170
  end
171
171
 
172
172
  it "should be hyperv with Microsoft vendor name from dmidecode" do
173
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
174
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("System Information\nManufacturer: Microsoft Corporation\nProduct Name: Virtual Machine")
173
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
174
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("System Information\nManufacturer: Microsoft Corporation\nProduct Name: Virtual Machine")
175
175
  Facter.fact(:virtual).value.should == "hyperv"
176
176
  end
177
177
 
@@ -186,7 +186,7 @@ describe "Virtual fact" do
186
186
  end
187
187
 
188
188
  it "should be gce with gce vendor name from lspci 2>/dev/null" do
189
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("00:05.0 Class 8007: Google, Inc. Device 6442")
189
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns("00:05.0 Class 8007: Google, Inc. Device 6442")
190
190
  Facter.fact(:virtual).value.should == "gce"
191
191
  end
192
192
  end
@@ -207,69 +207,69 @@ describe "Virtual fact" do
207
207
  end
208
208
 
209
209
  it "(#20236) is vmware when dmidecode contains vmware and lspci returns insufficient information" do
210
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns("garbage\ninformation\n")
211
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
210
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns("garbage\ninformation\n")
211
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
212
212
  Facter.fact(:virtual).value.should eq("vmware")
213
213
  end
214
214
  end
215
215
 
216
216
  describe "on Solaris" do
217
217
  before(:each) do
218
- Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false
218
+ Facter::Core::Execution.stubs(:exec).with("vmware -v").returns false
219
219
  Facter.fact(:kernel).stubs(:value).returns("SunOS")
220
220
  end
221
221
 
222
222
  it "should be vmware with VMWare vendor name from prtdiag" do
223
223
  Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
224
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
225
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil)
226
- Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
224
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
225
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil)
226
+ Facter::Core::Execution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
227
227
  Facter.fact(:virtual).value.should == "vmware"
228
228
  end
229
229
 
230
230
  it "should be parallels with Parallels vendor name from prtdiag" do
231
231
  Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
232
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
233
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil)
234
- Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
232
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
233
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil)
234
+ Facter::Core::Execution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
235
235
  Facter.fact(:virtual).value.should == "parallels"
236
236
  end
237
237
 
238
238
  it "should be virtualbox with VirtualBox vendor name from prtdiag" do
239
239
  Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
240
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
241
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil)
242
- Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox")
240
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
241
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil)
242
+ Facter::Core::Execution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox")
243
243
  Facter.fact(:virtual).value.should == "virtualbox"
244
244
  end
245
245
  end
246
246
 
247
247
  describe "on OpenBSD" do
248
248
  before do
249
- Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false
249
+ Facter::Core::Execution.stubs(:exec).with("vmware -v").returns false
250
250
  Facter.fact(:kernel).stubs(:value).returns("OpenBSD")
251
251
  Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
252
- Facter::Util::Resolution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
253
- Facter::Util::Resolution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil)
252
+ Facter::Core::Execution.stubs(:exec).with('lspci 2>/dev/null').returns(nil)
253
+ Facter::Core::Execution.stubs(:exec).with('dmidecode 2> /dev/null').returns(nil)
254
254
  end
255
255
 
256
256
  it "should be parallels with Parallels product name from sysctl" do
257
- Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("Parallels Virtual Platform")
257
+ Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("Parallels Virtual Platform")
258
258
  Facter.fact(:virtual).value.should == "parallels"
259
259
  end
260
260
 
261
261
  it "should be vmware with VMware product name from sysctl" do
262
- Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("VMware Virtual Platform")
262
+ Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("VMware Virtual Platform")
263
263
  Facter.fact(:virtual).value.should == "vmware"
264
264
  end
265
265
 
266
266
  it "should be virtualbox with VirtualBox product name from sysctl" do
267
- Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("VirtualBox")
267
+ Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("VirtualBox")
268
268
  Facter.fact(:virtual).value.should == "virtualbox"
269
269
  end
270
270
 
271
271
  it "should be xenhvm with Xen HVM product name from sysctl" do
272
- Facter::Util::Resolution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("HVM domU")
272
+ Facter::Core::Execution.stubs(:exec).with('sysctl -n hw.product 2>/dev/null').returns("HVM domU")
273
273
  Facter.fact(:virtual).value.should == "xenhvm"
274
274
  end
275
275
  end