facter 1.6.2 → 1.6.3

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 (57) hide show
  1. data/CHANGELOG +11 -0
  2. data/LICENSE +1 -1
  3. data/conf/osx/createpackage.sh +1 -1
  4. data/conf/redhat/facter.spec +9 -6
  5. data/conf/solaris/pkginfo +1 -1
  6. data/install.rb +1 -1
  7. data/lib/facter.rb +2 -2
  8. data/lib/facter/architecture.rb +1 -2
  9. data/lib/facter/augeasversion.rb +1 -2
  10. data/lib/facter/domain.rb +3 -3
  11. data/lib/facter/hardwareisa.rb +1 -1
  12. data/lib/facter/ipaddress.rb +2 -2
  13. data/lib/facter/lsbmajdistrelease.rb +1 -1
  14. data/lib/facter/macaddress.rb +2 -2
  15. data/lib/facter/manufacturer.rb +1 -1
  16. data/lib/facter/netmask.rb +0 -3
  17. data/lib/facter/network.rb +2 -3
  18. data/lib/facter/operatingsystem.rb +5 -2
  19. data/lib/facter/operatingsystemrelease.rb +3 -3
  20. data/lib/facter/osfamily.rb +1 -1
  21. data/lib/facter/processor.rb +2 -2
  22. data/lib/facter/selinux.rb +3 -3
  23. data/lib/facter/uniqueid.rb +1 -1
  24. data/lib/facter/uptime_days.rb +0 -1
  25. data/lib/facter/uptime_hours.rb +0 -1
  26. data/lib/facter/util/manufacturer.rb +2 -3
  27. data/lib/facter/util/processor.rb +3 -3
  28. data/lib/facter/util/resolution.rb +3 -3
  29. data/lib/facter/util/values.rb +1 -1
  30. data/lib/facter/virtual.rb +2 -2
  31. data/lib/facter/vlans.rb +1 -2
  32. data/lib/facter/xendomains.rb +0 -1
  33. data/spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag +33 -0
  34. data/spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag +136 -0
  35. data/spec/spec_helper.rb +5 -0
  36. data/spec/unit/architecture_spec.rb +40 -40
  37. data/spec/unit/facter_spec.rb +220 -220
  38. data/spec/unit/id_spec.rb +16 -16
  39. data/spec/unit/interfaces_spec.rb +6 -6
  40. data/spec/unit/memory_spec.rb +105 -105
  41. data/spec/unit/operatingsystem_spec.rb +72 -63
  42. data/spec/unit/operatingsystemrelease_spec.rb +44 -43
  43. data/spec/unit/processor_spec.rb +2 -2
  44. data/spec/unit/selinux_spec.rb +53 -53
  45. data/spec/unit/util/collection_spec.rb +183 -183
  46. data/spec/unit/util/confine_spec.rb +92 -92
  47. data/spec/unit/util/fact_spec.rb +96 -96
  48. data/spec/unit/util/ip_spec.rb +218 -218
  49. data/spec/unit/util/loader_spec.rb +193 -193
  50. data/spec/unit/util/macosx_spec.rb +63 -63
  51. data/spec/unit/util/manufacturer_spec.rb +124 -107
  52. data/spec/unit/util/resolution_spec.rb +235 -235
  53. data/spec/unit/util/virtual_spec.rb +167 -167
  54. data/spec/unit/util/vlans_spec.rb +6 -6
  55. data/spec/unit/virtual_spec.rb +246 -246
  56. data/spec/watchr.rb +1 -1
  57. metadata +6 -4
@@ -4,172 +4,172 @@ require 'facter/util/virtual'
4
4
 
5
5
  describe Facter::Util::Virtual do
6
6
 
7
- after do
8
- Facter.clear
9
- end
10
- it "should detect openvz" do
11
- FileTest.stubs(:directory?).with("/proc/vz").returns(true)
12
- Dir.stubs(:glob).with("/proc/vz/*").returns(['vzquota'])
13
- Facter::Util::Virtual.should be_openvz
14
- end
15
-
16
- it "should not detect openvz when /proc/lve/list is present" do
17
- FileTest.stubs(:file?).with("/proc/lve/list").returns(true)
18
- Facter::Util::Virtual.should_not be_openvz
19
- end
20
-
21
- it "should not detect openvz when /proc/vz/ is empty" do
22
- FileTest.stubs(:file?).with("/proc/lve/list").returns(false)
23
- FileTest.stubs(:directory?).with("/proc/vz").returns(true)
24
- Dir.stubs(:glob).with("/proc/vz/*").returns([])
25
- Facter::Util::Virtual.should_not be_openvz
26
- end
27
-
28
- it "should identify openvzhn when /proc/self/status has envID of 0" do
29
- Facter::Util::Virtual.stubs(:openvz?).returns(true)
7
+ after do
8
+ Facter.clear
9
+ end
10
+ it "should detect openvz" do
11
+ FileTest.stubs(:directory?).with("/proc/vz").returns(true)
12
+ Dir.stubs(:glob).with("/proc/vz/*").returns(['vzquota'])
13
+ Facter::Util::Virtual.should be_openvz
14
+ end
15
+
16
+ it "should not detect openvz when /proc/lve/list is present" do
17
+ FileTest.stubs(:file?).with("/proc/lve/list").returns(true)
18
+ Facter::Util::Virtual.should_not be_openvz
19
+ end
20
+
21
+ it "should not detect openvz when /proc/vz/ is empty" do
22
+ FileTest.stubs(:file?).with("/proc/lve/list").returns(false)
23
+ FileTest.stubs(:directory?).with("/proc/vz").returns(true)
24
+ Dir.stubs(:glob).with("/proc/vz/*").returns([])
25
+ Facter::Util::Virtual.should_not be_openvz
26
+ end
27
+
28
+ it "should identify openvzhn when /proc/self/status has envID of 0" do
29
+ Facter::Util::Virtual.stubs(:openvz?).returns(true)
30
+ FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
31
+ Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 0")
32
+ Facter::Util::Virtual.openvz_type().should == "openvzhn"
33
+ end
34
+
35
+ it "should identify openvzve when /proc/self/status has envID of 0" do
36
+ Facter::Util::Virtual.stubs(:openvz?).returns(true)
37
+ FileTest.stubs(:exists?).with('/proc/self/status').returns(true)
38
+ Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 666")
39
+ Facter::Util::Virtual.openvz_type().should == "openvzve"
40
+ end
41
+
42
+ it "should not attempt to identify openvz when /proc/self/status has no envID" do
43
+ Facter::Util::Virtual.stubs(:openvz?).returns(true)
44
+ FileTest.stubs(:exists?).with('/proc/self/status').returns(true)
45
+ Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("")
46
+ Facter::Util::Virtual.openvz_type().should be_nil
47
+ end
48
+
49
+ it "should identify Solaris zones when non-global zone" do
50
+ Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("somezone")
51
+ Facter::Util::Virtual.should be_zone
52
+ end
53
+
54
+ it "should not identify Solaris zones when global zone" do
55
+ Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("global")
56
+ Facter::Util::Virtual.should_not be_zone
57
+ end
58
+
59
+ it "should not detect vserver if no self status" do
60
+ FileTest.stubs(:exists?).with("/proc/self/status").returns(false)
61
+ Facter::Util::Virtual.should_not be_vserver
62
+ end
63
+
64
+ it "should detect vserver when vxid present in process status" do
65
+ FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
66
+ File.stubs(:read).with("/proc/self/status").returns("VxID: 42\n")
67
+ Facter::Util::Virtual.should be_vserver
68
+ end
69
+
70
+ it "should detect vserver when s_context present in process status" do
71
+ FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
72
+ File.stubs(:read).with("/proc/self/status").returns("s_context: 42\n")
73
+ Facter::Util::Virtual.should be_vserver
74
+ end
75
+
76
+ it "should not detect vserver when vserver flags not present in process status" do
77
+ FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
78
+ File.stubs(:read).with("/proc/self/status").returns("wibble: 42\n")
79
+ Facter::Util::Virtual.should_not be_vserver
80
+ end
81
+
82
+ fixture_path = File.join(SPECDIR, 'fixtures', 'virtual', 'proc_self_status')
83
+
84
+ test_cases = [
85
+ [File.join(fixture_path, 'vserver_2_1', 'guest'), true, 'vserver 2.1 guest'],
86
+ [File.join(fixture_path, 'vserver_2_1', 'host'), true, 'vserver 2.1 host'],
87
+ [File.join(fixture_path, 'vserver_2_3', 'guest'), true, 'vserver 2.3 guest'],
88
+ [File.join(fixture_path, 'vserver_2_3', 'host'), true, 'vserver 2.3 host']
89
+ ]
90
+
91
+ test_cases.each do |status_file, expected, description|
92
+ describe "with /proc/self/status from #{description}" do
93
+ it "should detect vserver as #{expected.inspect}" do
94
+ status = File.read(status_file)
30
95
  FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
31
- Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 0")
32
- Facter::Util::Virtual.openvz_type().should == "openvzhn"
33
- end
34
-
35
- it "should identify openvzve when /proc/self/status has envID of 0" do
36
- Facter::Util::Virtual.stubs(:openvz?).returns(true)
37
- FileTest.stubs(:exists?).with('/proc/self/status').returns(true)
38
- Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 666")
39
- Facter::Util::Virtual.openvz_type().should == "openvzve"
40
- end
41
-
42
- it "should not attempt to identify openvz when /proc/self/status has no envID" do
43
- Facter::Util::Virtual.stubs(:openvz?).returns(true)
44
- FileTest.stubs(:exists?).with('/proc/self/status').returns(true)
45
- Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("")
46
- Facter::Util::Virtual.openvz_type().should be_nil
47
- end
48
-
49
- it "should identify Solaris zones when non-global zone" do
50
- Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("somezone")
51
- Facter::Util::Virtual.should be_zone
52
- end
53
-
54
- it "should not identify Solaris zones when global zone" do
55
- Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("global")
56
- Facter::Util::Virtual.should_not be_zone
57
- end
58
-
59
- it "should not detect vserver if no self status" do
60
- FileTest.stubs(:exists?).with("/proc/self/status").returns(false)
61
- Facter::Util::Virtual.should_not be_vserver
62
- end
63
-
64
- it "should detect vserver when vxid present in process status" do
65
- FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
66
- File.stubs(:read).with("/proc/self/status").returns("VxID: 42\n")
67
- Facter::Util::Virtual.should be_vserver
68
- end
69
-
70
- it "should detect vserver when s_context present in process status" do
71
- FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
72
- File.stubs(:read).with("/proc/self/status").returns("s_context: 42\n")
73
- Facter::Util::Virtual.should be_vserver
74
- end
75
-
76
- it "should not detect vserver when vserver flags not present in process status" do
77
- FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
78
- File.stubs(:read).with("/proc/self/status").returns("wibble: 42\n")
79
- Facter::Util::Virtual.should_not be_vserver
80
- end
81
-
82
- fixture_path = File.join(SPECDIR, 'fixtures', 'virtual', 'proc_self_status')
83
-
84
- test_cases = [
85
- [File.join(fixture_path, 'vserver_2_1', 'guest'), true, 'vserver 2.1 guest'],
86
- [File.join(fixture_path, 'vserver_2_1', 'host'), true, 'vserver 2.1 host'],
87
- [File.join(fixture_path, 'vserver_2_3', 'guest'), true, 'vserver 2.3 guest'],
88
- [File.join(fixture_path, 'vserver_2_3', 'host'), true, 'vserver 2.3 host']
89
- ]
90
-
91
- test_cases.each do |status_file, expected, description|
92
- describe "with /proc/self/status from #{description}" do
93
- it "should detect vserver as #{expected.inspect}" do
94
- status = File.read(status_file)
95
- FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
96
- File.stubs(:read).with("/proc/self/status").returns(status)
97
- Facter::Util::Virtual.vserver?.should == expected
98
- end
99
- end
100
- end
101
-
102
- it "should identify vserver_host when /proc/virtual exists" do
103
- Facter::Util::Virtual.expects(:vserver?).returns(true)
104
- FileTest.stubs(:exists?).with("/proc/virtual").returns(true)
105
- Facter::Util::Virtual.vserver_type().should == "vserver_host"
106
- end
107
-
108
- it "should identify vserver_type as vserver when /proc/virtual does not exist" do
109
- Facter::Util::Virtual.expects(:vserver?).returns(true)
110
- FileTest.stubs(:exists?).with("/proc/virtual").returns(false)
111
- Facter::Util::Virtual.vserver_type().should == "vserver"
112
- end
113
-
114
- it "should detect xen when /proc/sys/xen exists" do
115
- FileTest.expects(:exists?).with("/proc/sys/xen").returns(true)
116
- Facter::Util::Virtual.should be_xen
117
- end
118
-
119
- it "should detect xen when /sys/bus/xen exists" do
120
- FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
121
- FileTest.expects(:exists?).with("/sys/bus/xen").returns(true)
122
- Facter::Util::Virtual.should be_xen
123
- end
124
-
125
- it "should detect xen when /proc/xen exists" do
126
- FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
127
- FileTest.expects(:exists?).with("/sys/bus/xen").returns(false)
128
- FileTest.expects(:exists?).with("/proc/xen").returns(true)
129
- Facter::Util::Virtual.should be_xen
130
- end
131
-
132
- it "should not detect xen when no sysfs/proc xen directories exist" do
133
- FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
134
- FileTest.expects(:exists?).with("/sys/bus/xen").returns(false)
135
- FileTest.expects(:exists?).with("/proc/xen").returns(false)
136
- Facter::Util::Virtual.should_not be_xen
137
- end
138
-
139
- it "should detect kvm" do
140
- FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(true)
141
- File.stubs(:read).with("/proc/cpuinfo").returns("model name : QEMU Virtual CPU version 0.9.1\n")
142
- Facter::Util::Virtual.should be_kvm
143
- end
144
-
145
- it "should detect kvm on FreeBSD" do
146
- FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false)
147
- Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
148
- Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns("QEMU Virtual CPU version 0.12.4")
149
- Facter::Util::Virtual.should be_kvm
150
- end
151
-
152
- it "should identify FreeBSD jail when in jail" do
153
- Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
154
- Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("1")
155
- Facter::Util::Virtual.should be_jail
156
- end
157
-
158
- it "should not identify GNU/kFreeBSD jail when not in jail" do
159
- Facter.fact(:kernel).stubs(:value).returns("GNU/kFreeBSD")
160
- Facter::Util::Resolution.stubs(:exec).with("/bin/sysctl -n security.jail.jailed").returns("0")
161
- Facter::Util::Virtual.should_not be_jail
162
- end
163
-
164
- it "should detect hpvm on HP-UX" do
165
- Facter.fact(:kernel).stubs(:value).returns("HP-UX")
166
- Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server Integrity Virtual Machine')
167
- Facter::Util::Virtual.should be_hpvm
168
- end
169
-
170
- it "should not detect hpvm on HP-UX when not in hpvm" do
171
- Facter.fact(:kernel).stubs(:value).returns("HP-UX")
172
- Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server rx660')
173
- Facter::Util::Virtual.should_not be_hpvm
174
- end
96
+ File.stubs(:read).with("/proc/self/status").returns(status)
97
+ Facter::Util::Virtual.vserver?.should == expected
98
+ end
99
+ end
100
+ end
101
+
102
+ it "should identify vserver_host when /proc/virtual exists" do
103
+ Facter::Util::Virtual.expects(:vserver?).returns(true)
104
+ FileTest.stubs(:exists?).with("/proc/virtual").returns(true)
105
+ Facter::Util::Virtual.vserver_type().should == "vserver_host"
106
+ end
107
+
108
+ it "should identify vserver_type as vserver when /proc/virtual does not exist" do
109
+ Facter::Util::Virtual.expects(:vserver?).returns(true)
110
+ FileTest.stubs(:exists?).with("/proc/virtual").returns(false)
111
+ Facter::Util::Virtual.vserver_type().should == "vserver"
112
+ end
113
+
114
+ it "should detect xen when /proc/sys/xen exists" do
115
+ FileTest.expects(:exists?).with("/proc/sys/xen").returns(true)
116
+ Facter::Util::Virtual.should be_xen
117
+ end
118
+
119
+ it "should detect xen when /sys/bus/xen exists" do
120
+ FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
121
+ FileTest.expects(:exists?).with("/sys/bus/xen").returns(true)
122
+ Facter::Util::Virtual.should be_xen
123
+ end
124
+
125
+ it "should detect xen when /proc/xen exists" do
126
+ FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
127
+ FileTest.expects(:exists?).with("/sys/bus/xen").returns(false)
128
+ FileTest.expects(:exists?).with("/proc/xen").returns(true)
129
+ Facter::Util::Virtual.should be_xen
130
+ end
131
+
132
+ it "should not detect xen when no sysfs/proc xen directories exist" do
133
+ FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
134
+ FileTest.expects(:exists?).with("/sys/bus/xen").returns(false)
135
+ FileTest.expects(:exists?).with("/proc/xen").returns(false)
136
+ Facter::Util::Virtual.should_not be_xen
137
+ end
138
+
139
+ it "should detect kvm" do
140
+ FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(true)
141
+ File.stubs(:read).with("/proc/cpuinfo").returns("model name : QEMU Virtual CPU version 0.9.1\n")
142
+ Facter::Util::Virtual.should be_kvm
143
+ end
144
+
145
+ it "should detect kvm on FreeBSD" do
146
+ FileTest.stubs(:exists?).with("/proc/cpuinfo").returns(false)
147
+ Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
148
+ Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns("QEMU Virtual CPU version 0.12.4")
149
+ Facter::Util::Virtual.should be_kvm
150
+ end
151
+
152
+ it "should identify FreeBSD jail when in jail" do
153
+ Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
154
+ Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("1")
155
+ Facter::Util::Virtual.should be_jail
156
+ end
157
+
158
+ it "should not identify GNU/kFreeBSD jail when not in jail" do
159
+ Facter.fact(:kernel).stubs(:value).returns("GNU/kFreeBSD")
160
+ Facter::Util::Resolution.stubs(:exec).with("/bin/sysctl -n security.jail.jailed").returns("0")
161
+ Facter::Util::Virtual.should_not be_jail
162
+ end
163
+
164
+ it "should detect hpvm on HP-UX" do
165
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
166
+ Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server Integrity Virtual Machine')
167
+ Facter::Util::Virtual.should be_hpvm
168
+ end
169
+
170
+ it "should not detect hpvm on HP-UX when not in hpvm" do
171
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
172
+ Facter::Util::Resolution.stubs(:exec).with("/usr/bin/getconf MACHINE_MODEL").returns('ia64 hp server rx660')
173
+ Facter::Util::Virtual.should_not be_hpvm
174
+ end
175
175
  end
@@ -5,10 +5,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
5
5
  require 'facter/util/vlans'
6
6
 
7
7
  describe Facter::Util::Vlans do
8
- it "should return a list of vlans on Linux" do
9
- sample_output_file = File.dirname(__FILE__) + '/../data/linux_vlan_config'
10
- linux_vlanconfig = File.new(sample_output_file).read();
11
- Facter::Util::Vlans.stubs(:get_vlan_config).returns(linux_vlanconfig)
12
- Facter::Util::Vlans.get_vlans().should == %{400,300,200,100}
13
- end
8
+ it "should return a list of vlans on Linux" do
9
+ sample_output_file = File.dirname(__FILE__) + '/../data/linux_vlan_config'
10
+ linux_vlanconfig = File.new(sample_output_file).read();
11
+ Facter::Util::Vlans.stubs(:get_vlan_config).returns(linux_vlanconfig)
12
+ Facter::Util::Vlans.get_vlans().should == %{400,300,200,100}
13
+ end
14
14
  end
@@ -6,302 +6,302 @@ require 'facter/util/macosx'
6
6
 
7
7
  describe "Virtual fact" do
8
8
  before do
9
- Facter::Util::Virtual.stubs(:zone?).returns(false)
10
- Facter::Util::Virtual.stubs(:openvz?).returns(false)
11
- Facter::Util::Virtual.stubs(:vserver?).returns(false)
12
- Facter::Util::Virtual.stubs(:xen?).returns(false)
13
- Facter::Util::Virtual.stubs(:kvm?).returns(false)
14
- Facter::Util::Virtual.stubs(:hpvm?).returns(false)
15
- Facter::Util::Virtual.stubs(:zlinux?).returns(false)
9
+ Facter::Util::Virtual.stubs(:zone?).returns(false)
10
+ Facter::Util::Virtual.stubs(:openvz?).returns(false)
11
+ Facter::Util::Virtual.stubs(:vserver?).returns(false)
12
+ Facter::Util::Virtual.stubs(:xen?).returns(false)
13
+ Facter::Util::Virtual.stubs(:kvm?).returns(false)
14
+ Facter::Util::Virtual.stubs(:hpvm?).returns(false)
15
+ Facter::Util::Virtual.stubs(:zlinux?).returns(false)
16
16
  end
17
17
 
18
18
  it "should be zone on Solaris when a zone" do
19
- Facter.fact(:kernel).stubs(:value).returns("SunOS")
20
- Facter::Util::Virtual.stubs(:zone?).returns(true)
21
- Facter::Util::Virtual.stubs(:vserver?).returns(false)
22
- Facter::Util::Virtual.stubs(:xen?).returns(false)
23
- Facter.fact(:virtual).value.should == "zone"
19
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
20
+ Facter::Util::Virtual.stubs(:zone?).returns(true)
21
+ Facter::Util::Virtual.stubs(:vserver?).returns(false)
22
+ Facter::Util::Virtual.stubs(:xen?).returns(false)
23
+ Facter.fact(:virtual).value.should == "zone"
24
24
  end
25
25
 
26
26
  it "should be jail on FreeBSD when a jail in kvm" do
27
- Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
28
- Facter::Util::Virtual.stubs(:jail?).returns(true)
29
- Facter::Util::Virtual.stubs(:kvm?).returns(true)
30
- Facter.fact(:virtual).value.should == "jail"
27
+ Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
28
+ Facter::Util::Virtual.stubs(:jail?).returns(true)
29
+ Facter::Util::Virtual.stubs(:kvm?).returns(true)
30
+ Facter.fact(:virtual).value.should == "jail"
31
31
  end
32
32
 
33
33
  it "should be hpvm on HP-UX when in HP-VM" do
34
- Facter.fact(:kernel).stubs(:value).returns("HP-UX")
35
- Facter::Util::Virtual.stubs(:hpvm?).returns(true)
36
- Facter.fact(:virtual).value.should == "hpvm"
34
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
35
+ Facter::Util::Virtual.stubs(:hpvm?).returns(true)
36
+ Facter.fact(:virtual).value.should == "hpvm"
37
37
  end
38
38
 
39
39
  it "should be zlinux on s390x" do
40
- Facter.fact(:kernel).stubs(:value).returns("Linux")
41
- Facter.fact(:architecture).stubs(:value).returns("s390x")
42
- Facter::Util::Virtual.stubs(:zlinux?).returns(true)
43
- Facter.fact(:virtual).value.should == "zlinux"
40
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
41
+ Facter.fact(:architecture).stubs(:value).returns("s390x")
42
+ Facter::Util::Virtual.stubs(:zlinux?).returns(true)
43
+ Facter.fact(:virtual).value.should == "zlinux"
44
44
  end
45
45
 
46
46
  describe "on Darwin" do
47
- it "should be parallels with Parallels vendor id" do
48
- Facter.fact(:kernel).stubs(:value).returns("Darwin")
49
- Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor-id" => "0x1ab8" })
50
- Facter.fact(:virtual).value.should == "parallels"
51
- end
52
-
53
- it "should be parallels with Parallels vendor name" do
54
- Facter.fact(:kernel).stubs(:value).returns("Darwin")
55
- Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor" => "Parallels" })
56
- Facter.fact(:virtual).value.should == "parallels"
57
- end
58
-
59
- it "should be vmware with VMWare vendor id" do
60
- Facter.fact(:kernel).stubs(:value).returns("Darwin")
61
- Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor-id" => "0x15ad" })
62
- Facter.fact(:virtual).value.should == "vmware"
63
- end
64
-
65
- it "should be vmware with VMWare vendor name" do
66
- Facter.fact(:kernel).stubs(:value).returns("Darwin")
67
- Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor" => "VMWare" })
68
- Facter.fact(:virtual).value.should == "vmware"
69
- end
70
- end
47
+ it "should be parallels with Parallels vendor id" do
48
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
49
+ Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor-id" => "0x1ab8" })
50
+ Facter.fact(:virtual).value.should == "parallels"
51
+ end
71
52
 
72
- describe "on Linux" do
53
+ it "should be parallels with Parallels vendor name" do
54
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
55
+ Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor" => "Parallels" })
56
+ Facter.fact(:virtual).value.should == "parallels"
57
+ end
73
58
 
74
- before do
75
- Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false
76
- Facter.fact(:operatingsystem).stubs(:value).returns(true)
77
- # Ensure the tests don't fail on Xen
78
- FileTest.stubs(:exists?).with("/proc/sys/xen").returns false
79
- FileTest.stubs(:exists?).with("/sys/bus/xen").returns false
80
- FileTest.stubs(:exists?).with("/proc/xen").returns false
81
- Facter.fact(:architecture).stubs(:value).returns(true)
82
- end
83
-
84
- it "should be parallels with Parallels vendor id from lspci" do
85
- Facter.fact(:kernel).stubs(:value).returns("Linux")
86
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns("01:00.0 VGA compatible controller: Unknown device 1ab8:4005")
87
- Facter.fact(:virtual).value.should == "parallels"
88
- end
89
-
90
- it "should be parallels with Parallels vendor name from lspci" do
91
- Facter.fact(:kernel).stubs(:value).returns("Linux")
92
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns("01:00.0 VGA compatible controller: Parallels Display Adapter")
93
- Facter.fact(:virtual).value.should == "parallels"
94
- end
95
-
96
- it "should be vmware with VMware vendor name from lspci" do
97
- Facter.fact(:kernel).stubs(:value).returns("Linux")
98
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter")
99
- Facter.fact(:virtual).value.should == "vmware"
100
- end
101
-
102
- it "should be virtualbox with VirtualBox vendor name from lspci" do
103
- Facter.fact(:kernel).stubs(:value).returns("Linux")
104
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
105
- Facter.fact(:virtual).value.should == "virtualbox"
106
- end
107
-
108
- it "should be vmware with VMWare vendor name from dmidecode" do
109
- Facter.fact(:kernel).stubs(:value).returns("Linux")
110
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
111
- Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
112
- Facter.fact(:virtual).value.should == "vmware"
113
- end
114
-
115
- it "should be xenhvm with Xen HVM vendor name from lspci" do
116
- Facter.fact(:kernel).stubs(:value).returns("Linux")
117
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
118
- Facter.fact(:virtual).value.should == "xenhvm"
119
- end
120
-
121
- it "should be xenhvm with Xen HVM vendor name from dmidecode" do
122
- Facter.fact(:kernel).stubs(:value).returns("Linux")
123
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
124
- Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU")
125
- Facter.fact(:virtual).value.should == "xenhvm"
126
- end
127
-
128
- it "should be parallels with Parallels vendor name from dmidecode" do
129
- Facter.fact(:kernel).stubs(:value).returns("Linux")
130
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
131
- Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device Information\nType: Video\nStatus: Disabled\nDescription: Parallels Video Adapter")
132
- Facter.fact(:virtual).value.should == "parallels"
133
- end
134
-
135
- it "should be virtualbox with VirtualBox vendor name from dmidecode" do
136
- Facter.fact(:kernel).stubs(:value).returns("Linux")
137
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
138
- Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine")
139
- Facter.fact(:virtual).value.should == "virtualbox"
140
- end
141
-
142
- it "should be hyperv with Microsoft vendor name from lspci" do
143
- Facter.fact(:kernel).stubs(:value).returns("Linux")
144
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA")
145
- Facter.fact(:virtual).value.should == "hyperv"
146
- end
147
-
148
- it "should be hyperv with Microsoft vendor name from dmidecode" do
149
- Facter.fact(:kernel).stubs(:value).returns("Linux")
150
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
151
- Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Microsoft Corporation\nProduct Name: Virtual Machine")
152
- Facter.fact(:virtual).value.should == "hyperv"
153
- end
59
+ it "should be vmware with VMWare vendor id" do
60
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
61
+ Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor-id" => "0x15ad" })
62
+ Facter.fact(:virtual).value.should == "vmware"
63
+ end
154
64
 
65
+ it "should be vmware with VMWare vendor name" do
66
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
67
+ Facter::Util::Macosx.stubs(:profiler_data).returns({ "spdisplays_vendor" => "VMWare" })
68
+ Facter.fact(:virtual).value.should == "vmware"
69
+ end
155
70
  end
156
- describe "on Solaris" do
157
- before(:each) do
158
- Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false
159
- end
160
-
161
- it "should be vmware with VMWare vendor name from prtdiag" do
162
- Facter.fact(:kernel).stubs(:value).returns("SunOS")
163
- Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
164
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
165
- Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
166
- Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
167
- Facter.fact(:virtual).value.should == "vmware"
168
- end
169
-
170
- it "should be parallels with Parallels vendor name from prtdiag" do
171
- Facter.fact(:kernel).stubs(:value).returns("SunOS")
172
- Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
173
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
174
- Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
175
- Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
176
- Facter.fact(:virtual).value.should == "parallels"
177
- end
178
-
179
- it "should be virtualbox with VirtualBox vendor name from prtdiag" do
180
- Facter.fact(:kernel).stubs(:value).returns("SunOS")
181
- Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
182
- Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
183
- Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
184
- Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox")
185
- Facter.fact(:virtual).value.should == "virtualbox"
186
- end
187
-
188
- it "should be xen0 with xen dom0 files in /proc" do
189
- Facter.fact(:kernel).stubs(:value).returns("Linux")
190
- Facter.fact(:operatingsystem).stubs(:value).returns("Linux")
191
- Facter.fact(:hardwaremodel).stubs(:value).returns("i386")
192
- Facter::Util::Virtual.expects(:xen?).returns(true)
193
- FileTest.expects(:exists?).with("/proc/xen/xsd_kva").returns(true)
194
- Facter.fact(:virtual).value.should == "xen0"
195
- end
196
-
197
- it "should be xenu with xen domU files in /proc" do
198
- Facter.fact(:kernel).stubs(:value).returns("Linux")
199
- Facter.fact(:operatingsystem).stubs(:value).returns("Linux")
200
- Facter.fact(:hardwaremodel).stubs(:value).returns("i386")
201
- Facter::Util::Virtual.expects(:xen?).returns(true)
202
- FileTest.expects(:exists?).with("/proc/xen/xsd_kva").returns(false)
203
- FileTest.expects(:exists?).with("/proc/xen/capabilities").returns(true)
204
- Facter.fact(:virtual).value.should == "xenu"
205
- end
206
- end
207
- end
208
71
 
209
- describe "is_virtual fact" do
72
+ describe "on Linux" do
210
73
 
211
- it "should be virtual when running on xen" do
212
- Facter.fact(:kernel).stubs(:value).returns("Linux")
213
- Facter.fact(:virtual).stubs(:value).returns("xenu")
214
- Facter.fact(:is_virtual).value.should == "true"
74
+ before do
75
+ Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false
76
+ Facter.fact(:operatingsystem).stubs(:value).returns(true)
77
+ # Ensure the tests don't fail on Xen
78
+ FileTest.stubs(:exists?).with("/proc/sys/xen").returns false
79
+ FileTest.stubs(:exists?).with("/sys/bus/xen").returns false
80
+ FileTest.stubs(:exists?).with("/proc/xen").returns false
81
+ Facter.fact(:architecture).stubs(:value).returns(true)
215
82
  end
216
83
 
217
- it "should be false when running on xen0" do
218
- Facter.fact(:kernel).stubs(:value).returns("Linux")
219
- Facter.fact(:virtual).stubs(:value).returns("xen0")
220
- Facter.fact(:is_virtual).value.should == "false"
84
+ it "should be parallels with Parallels vendor id from lspci" do
85
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
86
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("01:00.0 VGA compatible controller: Unknown device 1ab8:4005")
87
+ Facter.fact(:virtual).value.should == "parallels"
221
88
  end
222
89
 
223
- it "should be true when running on xenhvm" do
224
- Facter.fact(:kernel).stubs(:value).returns("Linux")
225
- Facter.fact(:virtual).stubs(:value).returns("xenhvm")
226
- Facter.fact(:is_virtual).value.should == "true"
90
+ it "should be parallels with Parallels vendor name from lspci" do
91
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
92
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("01:00.0 VGA compatible controller: Parallels Display Adapter")
93
+ Facter.fact(:virtual).value.should == "parallels"
227
94
  end
228
95
 
229
- it "should be false when running on physical" do
230
- Facter.fact(:kernel).stubs(:value).returns("Linux")
231
- Facter.fact(:virtual).stubs(:value).returns("physical")
232
- Facter.fact(:is_virtual).value.should == "false"
96
+ it "should be vmware with VMware vendor name from lspci" do
97
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
98
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter")
99
+ Facter.fact(:virtual).value.should == "vmware"
233
100
  end
234
101
 
235
- it "should be true when running on vmware" do
236
- Facter.fact(:kernel).stubs(:value).returns("Linux")
237
- Facter.fact(:virtual).stubs(:value).returns("vmware")
238
- Facter.fact(:is_virtual).value.should == "true"
102
+ it "should be virtualbox with VirtualBox vendor name from lspci" do
103
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
104
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
105
+ Facter.fact(:virtual).value.should == "virtualbox"
239
106
  end
240
107
 
241
- it "should be true when running on virtualbox" do
242
- Facter.fact(:kernel).stubs(:value).returns("Linux")
243
- Facter.fact(:virtual).stubs(:value).returns("virtualbox")
244
- Facter.fact(:is_virtual).value.should == "true"
108
+ it "should be vmware with VMWare vendor name from dmidecode" do
109
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
110
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
111
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
112
+ Facter.fact(:virtual).value.should == "vmware"
245
113
  end
246
114
 
247
- it "should be true when running on openvzve" do
248
- Facter.fact(:kernel).stubs(:value).returns("Linux")
249
- Facter.fact(:virtual).stubs(:value).returns("openvzve")
250
- Facter.fact(:is_virtual).value.should == "true"
115
+ it "should be xenhvm with Xen HVM vendor name from lspci" do
116
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
117
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
118
+ Facter.fact(:virtual).value.should == "xenhvm"
251
119
  end
252
120
 
253
- it "should be true when running on kvm" do
254
- Facter.fact(:kernel).stubs(:value).returns("Linux")
255
- Facter.fact(:virtual).stubs(:value).returns("kvm")
256
- Facter.fact(:is_virtual).value.should == "true"
121
+ it "should be xenhvm with Xen HVM vendor name from dmidecode" do
122
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
123
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
124
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU")
125
+ Facter.fact(:virtual).value.should == "xenhvm"
257
126
  end
258
127
 
259
- it "should be true when running in jail" do
260
- Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
261
- Facter.fact(:virtual).stubs(:value).returns("jail")
262
- Facter.fact(:is_virtual).value.should == "true"
128
+ it "should be parallels with Parallels vendor name from dmidecode" do
129
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
130
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
131
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device Information\nType: Video\nStatus: Disabled\nDescription: Parallels Video Adapter")
132
+ Facter.fact(:virtual).value.should == "parallels"
263
133
  end
264
134
 
265
- it "should be true when running in zone" do
266
- Facter.fact(:kernel).stubs(:value).returns("SunOS")
267
- Facter.fact(:virtual).stubs(:value).returns("zone")
268
- Facter.fact(:is_virtual).value.should == "true"
135
+ it "should be virtualbox with VirtualBox vendor name from dmidecode" do
136
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
137
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
138
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine")
139
+ Facter.fact(:virtual).value.should == "virtualbox"
269
140
  end
270
141
 
271
- it "should be true when running on hp-vm" do
272
- Facter.fact(:kernel).stubs(:value).returns("HP-UX")
273
- Facter.fact(:virtual).stubs(:value).returns("hpvm")
274
- Facter.fact(:is_virtual).value.should == "true"
142
+ it "should be hyperv with Microsoft vendor name from lspci" do
143
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
144
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:08.0 VGA compatible controller: Microsoft Corporation Hyper-V virtual VGA")
145
+ Facter.fact(:virtual).value.should == "hyperv"
275
146
  end
276
147
 
277
- it "should be true when running on S390" do
278
- Facter.fact(:architecture).stubs(:value).returns("s390x")
279
- Facter.fact(:kernel).stubs(:value).returns("Linux")
280
- Facter.fact(:virtual).stubs(:value).returns("zlinux")
281
- Facter.fact(:is_virtual).value.should == "true"
148
+ it "should be hyperv with Microsoft vendor name from dmidecode" do
149
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
150
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
151
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Microsoft Corporation\nProduct Name: Virtual Machine")
152
+ Facter.fact(:virtual).value.should == "hyperv"
282
153
  end
283
154
 
284
- it "should be true when running on parallels" do
285
- Facter.fact(:kernel).stubs(:value).returns("Darwin")
286
- Facter.fact(:virtual).stubs(:value).returns("parallels")
287
- Facter.fact(:is_virtual).value.should == "true"
155
+ end
156
+ describe "on Solaris" do
157
+ before(:each) do
158
+ Facter::Util::Resolution.stubs(:exec).with("vmware -v").returns false
288
159
  end
289
160
 
290
- it "should be false on vmware_server" do
291
- Facter.fact(:kernel).stubs(:value).returns("Linux")
292
- Facter.fact(:virtual).stubs(:value).returns("vmware_server")
293
- Facter.fact(:is_virtual).value.should == "false"
161
+ it "should be vmware with VMWare vendor name from prtdiag" do
162
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
163
+ Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
164
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
165
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
166
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
167
+ Facter.fact(:virtual).value.should == "vmware"
294
168
  end
295
169
 
296
- it "should be false on openvz host nodes" do
297
- Facter.fact(:kernel).stubs(:value).returns("Linux")
298
- Facter.fact(:virtual).stubs(:value).returns("openvzhn")
299
- Facter.fact(:is_virtual).value.should == "false"
170
+ it "should be parallels with Parallels vendor name from prtdiag" do
171
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
172
+ Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
173
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
174
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
175
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
176
+ Facter.fact(:virtual).value.should == "parallels"
177
+ end
178
+
179
+ it "should be virtualbox with VirtualBox vendor name from prtdiag" do
180
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
181
+ Facter.fact(:hardwaremodel).stubs(:value).returns(nil)
182
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
183
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
184
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox")
185
+ Facter.fact(:virtual).value.should == "virtualbox"
300
186
  end
301
187
 
302
- it "should be true when running on hyperv" do
303
- Facter.fact(:kernel).stubs(:value).returns("Linux")
304
- Facter.fact(:virtual).stubs(:value).returns("hyperv")
305
- Facter.fact(:is_virtual).value.should == "true"
188
+ it "should be xen0 with xen dom0 files in /proc" do
189
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
190
+ Facter.fact(:operatingsystem).stubs(:value).returns("Linux")
191
+ Facter.fact(:hardwaremodel).stubs(:value).returns("i386")
192
+ Facter::Util::Virtual.expects(:xen?).returns(true)
193
+ FileTest.expects(:exists?).with("/proc/xen/xsd_kva").returns(true)
194
+ Facter.fact(:virtual).value.should == "xen0"
306
195
  end
196
+
197
+ it "should be xenu with xen domU files in /proc" do
198
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
199
+ Facter.fact(:operatingsystem).stubs(:value).returns("Linux")
200
+ Facter.fact(:hardwaremodel).stubs(:value).returns("i386")
201
+ Facter::Util::Virtual.expects(:xen?).returns(true)
202
+ FileTest.expects(:exists?).with("/proc/xen/xsd_kva").returns(false)
203
+ FileTest.expects(:exists?).with("/proc/xen/capabilities").returns(true)
204
+ Facter.fact(:virtual).value.should == "xenu"
205
+ end
206
+ end
207
+ end
208
+
209
+ describe "is_virtual fact" do
210
+
211
+ it "should be virtual when running on xen" do
212
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
213
+ Facter.fact(:virtual).stubs(:value).returns("xenu")
214
+ Facter.fact(:is_virtual).value.should == "true"
215
+ end
216
+
217
+ it "should be false when running on xen0" do
218
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
219
+ Facter.fact(:virtual).stubs(:value).returns("xen0")
220
+ Facter.fact(:is_virtual).value.should == "false"
221
+ end
222
+
223
+ it "should be true when running on xenhvm" do
224
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
225
+ Facter.fact(:virtual).stubs(:value).returns("xenhvm")
226
+ Facter.fact(:is_virtual).value.should == "true"
227
+ end
228
+
229
+ it "should be false when running on physical" do
230
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
231
+ Facter.fact(:virtual).stubs(:value).returns("physical")
232
+ Facter.fact(:is_virtual).value.should == "false"
233
+ end
234
+
235
+ it "should be true when running on vmware" do
236
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
237
+ Facter.fact(:virtual).stubs(:value).returns("vmware")
238
+ Facter.fact(:is_virtual).value.should == "true"
239
+ end
240
+
241
+ it "should be true when running on virtualbox" do
242
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
243
+ Facter.fact(:virtual).stubs(:value).returns("virtualbox")
244
+ Facter.fact(:is_virtual).value.should == "true"
245
+ end
246
+
247
+ it "should be true when running on openvzve" do
248
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
249
+ Facter.fact(:virtual).stubs(:value).returns("openvzve")
250
+ Facter.fact(:is_virtual).value.should == "true"
251
+ end
252
+
253
+ it "should be true when running on kvm" do
254
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
255
+ Facter.fact(:virtual).stubs(:value).returns("kvm")
256
+ Facter.fact(:is_virtual).value.should == "true"
257
+ end
258
+
259
+ it "should be true when running in jail" do
260
+ Facter.fact(:kernel).stubs(:value).returns("FreeBSD")
261
+ Facter.fact(:virtual).stubs(:value).returns("jail")
262
+ Facter.fact(:is_virtual).value.should == "true"
263
+ end
264
+
265
+ it "should be true when running in zone" do
266
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
267
+ Facter.fact(:virtual).stubs(:value).returns("zone")
268
+ Facter.fact(:is_virtual).value.should == "true"
269
+ end
270
+
271
+ it "should be true when running on hp-vm" do
272
+ Facter.fact(:kernel).stubs(:value).returns("HP-UX")
273
+ Facter.fact(:virtual).stubs(:value).returns("hpvm")
274
+ Facter.fact(:is_virtual).value.should == "true"
275
+ end
276
+
277
+ it "should be true when running on S390" do
278
+ Facter.fact(:architecture).stubs(:value).returns("s390x")
279
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
280
+ Facter.fact(:virtual).stubs(:value).returns("zlinux")
281
+ Facter.fact(:is_virtual).value.should == "true"
282
+ end
283
+
284
+ it "should be true when running on parallels" do
285
+ Facter.fact(:kernel).stubs(:value).returns("Darwin")
286
+ Facter.fact(:virtual).stubs(:value).returns("parallels")
287
+ Facter.fact(:is_virtual).value.should == "true"
288
+ end
289
+
290
+ it "should be false on vmware_server" do
291
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
292
+ Facter.fact(:virtual).stubs(:value).returns("vmware_server")
293
+ Facter.fact(:is_virtual).value.should == "false"
294
+ end
295
+
296
+ it "should be false on openvz host nodes" do
297
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
298
+ Facter.fact(:virtual).stubs(:value).returns("openvzhn")
299
+ Facter.fact(:is_virtual).value.should == "false"
300
+ end
301
+
302
+ it "should be true when running on hyperv" do
303
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
304
+ Facter.fact(:virtual).stubs(:value).returns("hyperv")
305
+ Facter.fact(:is_virtual).value.should == "true"
306
+ end
307
307
  end