facter 2.1.0-x86-mingw32 → 2.2.0-x86-mingw32

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 (139) hide show
  1. data/COMMITTERS.md +25 -34
  2. data/CONTRIBUTING.md +27 -5
  3. data/README.md +32 -0
  4. data/ext/build_defaults.yaml +1 -1
  5. data/ext/debian/control +3 -2
  6. data/ext/osx/file_mapping.yaml +5 -0
  7. data/ext/redhat/facter.spec.erb +4 -1
  8. data/lib/facter/Cfkey.rb +2 -2
  9. data/lib/facter/architecture.rb +2 -2
  10. data/lib/facter/augeasversion.rb +2 -2
  11. data/lib/facter/blockdevices.rb +12 -12
  12. data/lib/facter/dhcp_servers.rb +4 -4
  13. data/lib/facter/domain.rb +4 -4
  14. data/lib/facter/ec2.rb +17 -0
  15. data/lib/facter/ec2/rest.rb +2 -2
  16. data/lib/facter/facterversion.rb +2 -2
  17. data/lib/facter/filesystems.rb +10 -3
  18. data/lib/facter/fqdn.rb +1 -1
  19. data/lib/facter/gid.rb +16 -0
  20. data/lib/facter/hardwareisa.rb +3 -3
  21. data/lib/facter/hardwaremodel.rb +3 -3
  22. data/lib/facter/hostname.rb +1 -1
  23. data/lib/facter/id.rb +4 -4
  24. data/lib/facter/interfaces.rb +3 -0
  25. data/lib/facter/ipaddress6.rb +9 -9
  26. data/lib/facter/kernel.rb +2 -2
  27. data/lib/facter/kernelmajversion.rb +2 -2
  28. data/lib/facter/kernelrelease.rb +4 -4
  29. data/lib/facter/kernelversion.rb +3 -3
  30. data/lib/facter/ldom.rb +11 -0
  31. data/lib/facter/lsbdistcodename.rb +8 -4
  32. data/lib/facter/lsbdistdescription.rb +6 -10
  33. data/lib/facter/lsbdistid.rb +8 -4
  34. data/lib/facter/lsbdistrelease.rb +8 -4
  35. data/lib/facter/lsbmajdistrelease.rb +7 -12
  36. data/lib/facter/lsbminordistrelease.rb +22 -0
  37. data/lib/facter/lsbrelease.rb +8 -4
  38. data/lib/facter/macaddress.rb +1 -0
  39. data/lib/facter/macosx.rb +1 -1
  40. data/lib/facter/manufacturer.rb +3 -3
  41. data/lib/facter/memory.rb +8 -8
  42. data/lib/facter/netmask.rb +2 -1
  43. data/lib/facter/network.rb +3 -3
  44. data/lib/facter/operatingsystem.rb +9 -126
  45. data/lib/facter/operatingsystem/base.rb +61 -0
  46. data/lib/facter/operatingsystem/cumuluslinux.rb +27 -0
  47. data/lib/facter/operatingsystem/implementation.rb +30 -0
  48. data/lib/facter/operatingsystem/linux.rb +467 -0
  49. data/lib/facter/operatingsystem/sunos.rb +54 -0
  50. data/lib/facter/operatingsystem/vmkernel.rb +11 -0
  51. data/lib/facter/operatingsystem/windows.rb +37 -0
  52. data/lib/facter/operatingsystemmajrelease.rb +14 -33
  53. data/lib/facter/operatingsystemrelease.rb +14 -235
  54. data/lib/facter/os.rb +69 -0
  55. data/lib/facter/osfamily.rb +4 -23
  56. data/lib/facter/partitions.rb +4 -3
  57. data/lib/facter/path.rb +2 -2
  58. data/lib/facter/physicalprocessorcount.rb +10 -74
  59. data/lib/facter/processor.rb +13 -129
  60. data/lib/facter/processors.rb +60 -0
  61. data/lib/facter/processors/os.rb +234 -0
  62. data/lib/facter/ps.rb +5 -4
  63. data/lib/facter/puppetversion.rb +1 -1
  64. data/lib/facter/rackspace.rb +34 -0
  65. data/lib/facter/rubysitedir.rb +3 -0
  66. data/lib/facter/rubyversion.rb +2 -2
  67. data/lib/facter/selinux.rb +57 -2
  68. data/lib/facter/ssh.rb +1 -0
  69. data/lib/facter/system_uptime.rb +42 -0
  70. data/lib/facter/timezone.rb +1 -1
  71. data/lib/facter/uptime.rb +5 -23
  72. data/lib/facter/uptime_days.rb +4 -6
  73. data/lib/facter/uptime_hours.rb +4 -6
  74. data/lib/facter/uptime_seconds.rb +5 -9
  75. data/lib/facter/util/formatter.rb +1 -1
  76. data/lib/facter/util/manufacturer.rb +1 -1
  77. data/lib/facter/util/partitions.rb +3 -1
  78. data/lib/facter/util/partitions/linux.rb +1 -1
  79. data/lib/facter/util/partitions/openbsd.rb +35 -0
  80. data/lib/facter/util/uptime.rb +4 -3
  81. data/lib/facter/util/virtual.rb +3 -1
  82. data/lib/facter/util/xendomains.rb +12 -3
  83. data/lib/facter/version.rb +1 -1
  84. data/lib/facter/virtual.rb +24 -23
  85. data/lib/facter/vlans.rb +1 -1
  86. data/lib/facter/xendomains.rb +1 -1
  87. data/lib/facter/zfs_version.rb +6 -2
  88. data/lib/facter/zones.rb +6 -5
  89. data/lib/facter/zpool_version.rb +1 -1
  90. data/spec/fixtures/cpuinfo/amd64dual-grep +2 -0
  91. data/spec/fixtures/cpuinfo/amd64twentyfour-grep +24 -0
  92. data/spec/fixtures/cpuinfo/two_multicore-grep +4 -0
  93. data/spec/fixtures/cpuinfo/two_singlecore-grep +2 -0
  94. data/spec/fixtures/unit/processors/os/darwin-system-profiler +287 -0
  95. data/spec/fixtures/unit/zfs_version/zfs_new +61 -0
  96. data/spec/fixtures/unit/zfs_version/zfs_old +43 -0
  97. data/spec/fixtures/unit/zfs_version/zfsonlinux_0.6.1 +13 -0
  98. data/spec/fixtures/unit/zpool_version/zfsonlinux_0.6.1 +48 -0
  99. data/spec/unit/ec2/rest_spec.rb +6 -6
  100. data/spec/unit/gid_spec.rb +22 -0
  101. data/spec/unit/hardwaremodel_spec.rb +2 -0
  102. data/spec/unit/lsbdistcodename_spec.rb +22 -17
  103. data/spec/unit/lsbdistdescription_spec.rb +22 -17
  104. data/spec/unit/lsbdistid_spec.rb +23 -18
  105. data/spec/unit/lsbdistrelease_spec.rb +22 -17
  106. data/spec/unit/lsbmajdistrelease_spec.rb +23 -6
  107. data/spec/unit/lsbminordistrelease_spec.rb +31 -0
  108. data/spec/unit/lsbrelease_spec.rb +22 -17
  109. data/spec/unit/macaddress_spec.rb +3 -0
  110. data/spec/unit/operatingsystem/base_spec.rb +76 -0
  111. data/spec/unit/operatingsystem/cumuluslinux_spec.rb +40 -0
  112. data/spec/unit/operatingsystem/implementation_spec.rb +49 -0
  113. data/spec/unit/operatingsystem/linux_spec.rb +538 -0
  114. data/spec/unit/operatingsystem/sunos_spec.rb +144 -0
  115. data/spec/unit/operatingsystem/vmkernel_spec.rb +13 -0
  116. data/spec/unit/operatingsystem/windows_spec.rb +68 -0
  117. data/spec/unit/operatingsystem_spec.rb +10 -153
  118. data/spec/unit/operatingsystemmajrelease_spec.rb +14 -31
  119. data/spec/unit/operatingsystemrelease_spec.rb +13 -229
  120. data/spec/unit/os_spec.rb +131 -0
  121. data/spec/unit/osfamily_spec.rb +9 -54
  122. data/spec/unit/partitions_spec.rb +41 -3
  123. data/spec/unit/physicalprocessorcount_spec.rb +6 -78
  124. data/spec/unit/processor_spec.rb +18 -381
  125. data/spec/unit/processors/os_spec.rb +446 -0
  126. data/spec/unit/processors_spec.rb +203 -0
  127. data/spec/unit/rackspace_spec.rb +40 -0
  128. data/spec/unit/system_uptime_spec.rb +80 -0
  129. data/spec/unit/util/formatter_spec.rb +5 -0
  130. data/spec/unit/util/macaddress_spec.rb +2 -0
  131. data/spec/unit/util/processor_spec.rb +120 -0
  132. data/spec/unit/util/uptime_spec.rb +3 -4
  133. data/spec/unit/util/virtual_spec.rb +8 -0
  134. data/spec/unit/util/xendomains_spec.rb +54 -9
  135. data/spec/unit/virtual_spec.rb +8 -1
  136. data/spec/unit/zfs_version_spec.rb +20 -8
  137. data/spec/unit/zpool_version_spec.rb +5 -0
  138. metadata +660 -589
  139. checksums.yaml +0 -7
@@ -0,0 +1,144 @@
1
+ require 'spec_helper'
2
+ require 'facter/operatingsystem/sunos'
3
+
4
+ describe Facter::Operatingsystem::SunOS do
5
+ subject { described_class.new }
6
+
7
+ describe "Operating system fact" do
8
+ it "should be Nexenta if /etc/debian_version is present" do
9
+ FileTest.expects(:exists?).with("/etc/debian_version").returns true
10
+ os = subject.get_operatingsystem
11
+ expect(os).to eq "Nexenta"
12
+ end
13
+
14
+ it "should be Solaris if /etc/debian_version is missing and uname -v failed to match" do
15
+ FileTest.expects(:exists?).with("/etc/debian_version").returns false
16
+ os = subject.get_operatingsystem
17
+ expect(os).to eq "Solaris"
18
+ end
19
+
20
+ {
21
+ "SmartOS" => "joyent_20120629T002039Z",
22
+ "OmniOS" => "omnios-dda4bb3",
23
+ "OpenIndiana" => "oi_151a",
24
+ }.each_pair do |distribution, string|
25
+ it "should be #{distribution} if uname -v is '#{string}'" do
26
+ Facter::Core::Execution.expects(:exec).with('uname -v').returns(string)
27
+ os = subject.get_operatingsystem
28
+ expect(os).to eq distribution
29
+ end
30
+ end
31
+ end
32
+
33
+ describe "Osfamily fact" do
34
+ it "should return Solaris" do
35
+ osfamily = subject.get_osfamily
36
+ expect(osfamily).to eq "Solaris"
37
+ end
38
+ end
39
+
40
+ describe "Operatingsystemrelease fact" do
41
+ {
42
+ 'Solaris 8 s28_38shwp2 SPARC' => '28',
43
+ 'Solaris 8 6/00 s28s_u1wos_08 SPARC' => '28_u1',
44
+ 'Solaris 8 10/00 s28s_u2wos_11b SPARC' => '28_u2',
45
+ 'Solaris 8 1/01 s28s_u3wos_08 SPARC' => '28_u3',
46
+ 'Solaris 8 4/01 s28s_u4wos_08 SPARC' => '28_u4',
47
+ 'Solaris 8 7/01 s28s_u5wos_08 SPARC' => '28_u5',
48
+ 'Solaris 8 10/01 s28s_u6wos_08a SPARC' => '28_u6',
49
+ 'Solaris 8 2/02 s28s_u7wos_08a SPARC' => '28_u7',
50
+ 'Solaris 8 HW 12/02 s28s_hw1wos_06a SPARC' => '28',
51
+ 'Solaris 8 HW 5/03 s28s_hw2wos_06a SPARC' => '28',
52
+ 'Solaris 8 HW 7/03 s28s_hw3wos_05a SPARC' => '28',
53
+ 'Solaris 8 2/04 s28s_hw4wos_05a SPARC' => '28',
54
+ 'Solaris 9 s9_58shwpl3 SPARC' => '9',
55
+ 'Solaris 9 9/02 s9s_u1wos_08b SPARC' => '9_u1',
56
+ 'Solaris 9 12/02 s9s_u2wos_10 SPARC' => '9_u2',
57
+ 'Solaris 9 4/03 s9s_u3wos_08 SPARC' => '9_u3',
58
+ 'Solaris 9 8/03 s9s_u4wos_08a SPARC' => '9_u4',
59
+ 'Solaris 9 12/03 s9s_u5wos_08b SPARC' => '9_u5',
60
+ 'Solaris 9 4/04 s9s_u6wos_08a SPARC' => '9_u6',
61
+ 'Solaris 9 9/04 s9s_u7wos_09 SPARC' => '9_u7',
62
+ 'Solaris 9 9/05 s9s_u8wos_05 SPARC' => '9_u8',
63
+ 'Solaris 9 9/05 HW s9s_u9wos_06b SPARC' => '9_u9',
64
+ 'Solaris 10 3/05 s10_74L2a SPARC' => '10',
65
+ 'Solaris 10 3/05 HW1 s10s_wos_74L2a SPARC' => '10',
66
+ 'Solaris 10 3/05 HW2 s10s_hw2wos_05 SPARC' => '10',
67
+ 'Solaris 10 1/06 s10s_u1wos_19a SPARC' => '10_u1',
68
+ 'Solaris 10 6/06 s10s_u2wos_09a SPARC' => '10_u2',
69
+ 'Solaris 10 11/06 s10s_u3wos_10 SPARC' => '10_u3',
70
+ 'Solaris 10 8/07 s10s_u4wos_12b SPARC' => '10_u4',
71
+ 'Solaris 10 5/08 s10s_u5wos_10 SPARC' => '10_u5',
72
+ 'Solaris 10 10/08 s10s_u6wos_07b SPARC' => '10_u6',
73
+ 'Solaris 10 5/09 s10s_u7wos_08 SPARC' => '10_u7',
74
+ 'Solaris 10 10/09 s10s_u8wos_08a SPARC' => '10_u8',
75
+ 'Oracle Solaris 10 9/10 s10s_u9wos_14a SPARC' => '10_u9',
76
+ 'Oracle Solaris 10 8/11 s10s_u10wos_17b SPARC' => '10_u10',
77
+ 'Solaris 10 3/05 HW1 s10x_wos_74L2a X86' => '10',
78
+ 'Solaris 10 1/06 s10x_u1wos_19a X86' => '10_u1',
79
+ 'Solaris 10 6/06 s10x_u2wos_09a X86' => '10_u2',
80
+ 'Solaris 10 11/06 s10x_u3wos_10 X86' => '10_u3',
81
+ 'Solaris 10 8/07 s10x_u4wos_12b X86' => '10_u4',
82
+ 'Solaris 10 5/08 s10x_u5wos_10 X86' => '10_u5',
83
+ 'Solaris 10 10/08 s10x_u6wos_07b X86' => '10_u6',
84
+ 'Solaris 10 5/09 s10x_u7wos_08 X86' => '10_u7',
85
+ 'Solaris 10 10/09 s10x_u8wos_08a X86' => '10_u8',
86
+ 'Oracle Solaris 10 9/10 s10x_u9wos_14a X86' => '10_u9',
87
+ 'Oracle Solaris 10 9/10 s10x_u9wos_14a X86' => '10_u9',
88
+ 'Oracle Solaris 10 8/11 s10x_u10wos_17b X86' => '10_u10',
89
+ 'Oracle Solaris 11 11/11 X86' => '11 11/11',
90
+ 'Oracle Solaris 11.1 SPARC' => '11.1'
91
+ }.each do |fakeinput, expected_output|
92
+ it "should be able to parse a release of #{fakeinput}" do
93
+ Facter::Util::FileRead.expects(:read).with("/etc/release").returns fakeinput
94
+ release = subject.get_operatingsystemrelease
95
+ expect(release).to eq expected_output
96
+ end
97
+ end
98
+
99
+ context "malformed /etc/release files" do
100
+ it "should fallback to the kernelrelease fact if /etc/release is empty" do
101
+ Facter::Util::FileRead.expects(:read).with('/etc/release').returns("")
102
+ release = subject.get_operatingsystemrelease
103
+ expect(release).to eq Facter.fact(:kernelrelease).value
104
+ end
105
+
106
+ it "should fallback to the kernelrelease fact if /etc/release is not present" do
107
+ Facter::Util::FileRead.expects(:read).with('/etc/release').returns false
108
+ release = subject.get_operatingsystemrelease
109
+ expect(release).to eq Facter.fact(:kernelrelease).value
110
+ end
111
+
112
+ it "should fallback to the kernelrelease fact if /etc/release cannot be parsed" do
113
+ Facter::Util::FileRead.expects(:read).with('/etc/release').returns 'some future release string'
114
+ release = subject.get_operatingsystemrelease
115
+ expect(release).to eq Facter.fact(:kernelrelease).value
116
+ end
117
+ end
118
+ end
119
+
120
+ describe "Operatingsystemmajrelease fact" do
121
+ before :each do
122
+ Facter.fact(:kernel).stubs(:value).returns("SunOS")
123
+ subject.expects(:get_operatingsystem).returns("Solaris")
124
+ end
125
+
126
+ it "should correctly derive from operatingsystemrelease on solaris 10" do
127
+ subject.expects(:get_operatingsystemrelease).returns("10_u8")
128
+ release = subject.get_operatingsystemmajrelease
129
+ expect(release).to eq "10"
130
+ end
131
+
132
+ it "should correctly derive from operatingsystemrelease on solaris 11 (old version scheme)" do
133
+ subject.expects(:get_operatingsystemrelease).returns("11 11/11")
134
+ release = subject.get_operatingsystemmajrelease
135
+ expect(release).to eq "11"
136
+ end
137
+
138
+ it "should correctly derive from operatingsystemrelease on solaris 11 (new version scheme)" do
139
+ subject.expects(:get_operatingsystemrelease).returns("11.1")
140
+ release = subject.get_operatingsystemmajrelease
141
+ expect(release).to eq "11"
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'facter/operatingsystem/vmkernel'
3
+
4
+ describe Facter::Operatingsystem::VMkernel do
5
+ subject { described_class.new }
6
+
7
+ describe "Operating system fact" do
8
+ it "should be ESXi" do
9
+ os = subject.get_operatingsystem
10
+ expect(os).to eq "ESXi"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+ require 'facter/operatingsystem/windows'
3
+
4
+ describe Facter::Operatingsystem::Windows do
5
+ require 'facter/util/wmi'
6
+ subject { described_class.new }
7
+
8
+ describe "Operatingsystemrelease fact" do
9
+ before do
10
+ Facter.fact(:kernel).stubs(:value).returns("windows")
11
+ end
12
+
13
+ {
14
+ ['5.2.3790', 1] => "XP",
15
+ ['6.0.6002', 1] => "Vista",
16
+ ['6.0.6002', 2] => "2008",
17
+ ['6.0.6002', 3] => "2008",
18
+ ['6.1.7601', 1] => "7",
19
+ ['6.1.7601', 2] => "2008 R2",
20
+ ['6.1.7601', 3] => "2008 R2",
21
+ ['6.2.9200', 1] => "8",
22
+ ['6.2.9200', 2] => "2012",
23
+ ['6.2.9200', 3] => "2012",
24
+ }.each do |os_values, expected_output|
25
+ it "should be #{expected_output} with Version #{os_values[0]} and ProductType #{os_values[1]}" do
26
+ os = mock('os', :version => os_values[0], :producttype => os_values[1])
27
+ Facter::Util::WMI.expects(:execquery).returns([os])
28
+ release = subject.get_operatingsystemrelease
29
+ expect(release).to eq expected_output
30
+ end
31
+ end
32
+
33
+ {
34
+ ['5.2.3790', 2, ""] => "2003",
35
+ ['5.2.3790', 2, "R2"] => "2003 R2",
36
+ ['5.2.3790', 3, ""] => "2003",
37
+ ['5.2.3790', 3, "R2"] => "2003 R2",
38
+ }.each do |os_values, expected_output|
39
+ it "should be #{expected_output} with Version #{os_values[0]} and ProductType #{os_values[1]} and OtherTypeDescription #{os_values[2]}" do
40
+ os = mock('os', :version => os_values[0], :producttype => os_values[1], :othertypedescription => os_values[2])
41
+ Facter::Util::WMI.expects(:execquery).returns([os])
42
+ release = subject.get_operatingsystemrelease
43
+ expect(release).to eq expected_output
44
+ end
45
+ end
46
+
47
+ it "reports '2003' if the WMI method othertypedescription does not exist" do
48
+ os = mock('os', :version => '5.2.3790', :producttype => 2)
49
+ os.stubs(:othertypedescription).raises(NoMethodError)
50
+ Facter::Util::WMI.expects(:execquery).returns([os])
51
+ release = subject.get_operatingsystemrelease
52
+ expect(release).to eq "2003"
53
+ end
54
+
55
+ context "Unknown Windows version" do
56
+ before :each do
57
+ Facter.fact(:kernelrelease).stubs(:value).returns("X.Y.ZZZZ")
58
+ end
59
+
60
+ it "should be kernel version value with unknown values " do
61
+ os = mock('os', :version => "X.Y.ZZZZ")
62
+ Facter::Util::WMI.expects(:execquery).returns([os])
63
+ release = subject.get_operatingsystemrelease
64
+ expect(release).to eq "X.Y.ZZZZ"
65
+ end
66
+ end
67
+ end
68
+ end
@@ -3,158 +3,15 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe "Operating System fact" do
6
-
7
- before :each do
8
- FileTest.stubs(:exists?).returns false
9
- end
10
-
11
- it "should default to the kernel name" do
12
- Facter.fact(:kernel).stubs(:value).returns("Nutmeg")
13
-
14
- Facter.fact(:operatingsystem).value.should == "Nutmeg"
15
- end
16
- it "should be ESXi for VMkernel" do
17
- Facter.fact(:kernel).stubs(:value).returns("VMkernel")
18
-
19
- Facter.fact(:operatingsystem).value.should == "ESXi"
20
- end
21
-
22
- describe "on Solaris variants" do
23
- before :each do
24
- Facter.fact(:kernel).stubs(:value).returns("SunOS")
25
- end
26
-
27
- it "should be Nexenta if /etc/debian_version is present" do
28
- FileTest.expects(:exists?).with("/etc/debian_version").returns true
29
- Facter.fact(:operatingsystem).value.should == "Nexenta"
30
- end
31
-
32
- it "should be Solaris if /etc/debian_version is missing and uname -v failed to match" do
33
- FileTest.expects(:exists?).with("/etc/debian_version").returns false
34
- Facter.fact(:operatingsystem).value.should == "Solaris"
35
- end
36
-
37
- {
38
- "SmartOS" => "joyent_20120629T002039Z",
39
- "OmniOS" => "omnios-dda4bb3",
40
- "OpenIndiana" => "oi_151a",
41
- }.each_pair do |distribution, string|
42
- it "should be #{distribution} if uname -v is '#{string}'" do
43
- Facter::Core::Execution.stubs(:exec).with('uname -v').returns(string)
44
- Facter.fact(:operatingsystem).value.should == distribution
45
- end
46
- end
47
- end
48
-
49
- describe "on Linux" do
50
- before :each do
51
- Facter.fact(:kernel).stubs(:value).returns("Linux")
52
-
53
- # Always stub lsbdistid by default, so tests work on Ubuntu
54
- Facter.stubs(:value).with(:lsbdistid).returns(nil)
55
- end
56
-
57
- {
58
- "Debian" => "/etc/debian_version",
59
- "Gentoo" => "/etc/gentoo-release",
60
- "Fedora" => "/etc/fedora-release",
61
- "Mageia" => "/etc/mageia-release",
62
- "Mandriva" => "/etc/mandriva-release",
63
- "Mandrake" => "/etc/mandrake-release",
64
- "MeeGo" => "/etc/meego-release",
65
- "Archlinux" => "/etc/arch-release",
66
- "OracleLinux" => "/etc/oracle-release",
67
- "OpenWrt" => "/etc/openwrt_release",
68
- "Alpine" => "/etc/alpine-release",
69
- "VMWareESX" => "/etc/vmware-release",
70
- "Bluewhite64" => "/etc/bluewhite64-version",
71
- "Slamd64" => "/etc/slamd64-version",
72
- "Slackware" => "/etc/slackware-version",
73
- "Amazon" => "/etc/system-release",
74
- }.each_pair do |distribution, releasefile|
75
- it "should be #{distribution} if #{releasefile} exists" do
76
- FileTest.expects(:exists?).with(releasefile).returns true
77
- Facter.fact(:operatingsystem).value.should == distribution
78
- end
79
- end
80
-
81
- describe "depending on LSB release information" do
82
- before :each do
83
- Facter.collection.internal_loader.load(:lsb)
84
- end
85
-
86
- it "on Ubuntu should use the lsbdistid fact" do
87
- FileUtils.stubs(:exists?).with("/etc/debian_version").returns true
88
-
89
- Facter.stubs(:value).with(:lsbdistid).returns("Ubuntu")
90
- Facter.fact(:operatingsystem).value.should == "Ubuntu"
91
- end
92
-
93
- it "on LinuxMint should use the lsbdistid fact" do
94
- FileUtils.stubs(:exists?).with("/etc/debian_version").returns true
95
-
96
- Facter.stubs(:value).with(:lsbdistid).returns("LinuxMint")
97
- Facter.fact(:operatingsystem).value.should == "LinuxMint"
98
- end
99
-
100
- end
101
-
102
-
103
- # Check distributions that rely on the contents of /etc/redhat-release
104
- {
105
- "RedHat" => "Red Hat Enterprise Linux Server release 6.0 (Santiago)",
106
- "CentOS" => "CentOS release 5.6 (Final)",
107
- "Scientific" => "Scientific Linux release 6.0 (Carbon)",
108
- "SLC" => "Scientific Linux CERN SLC release 5.7 (Boron)",
109
- "Ascendos" => "Ascendos release 6.0 (Nameless)",
110
- "CloudLinux" => "CloudLinux Server release 5.5",
111
- "XenServer" => "XenServer release 5.6.0-31188p (xenenterprise)",
112
- }.each_pair do |operatingsystem, string|
113
- it "should be #{operatingsystem} based on /etc/redhat-release contents #{string}" do
114
- FileTest.expects(:exists?).with("/etc/redhat-release").returns true
115
- File.expects(:read).with("/etc/redhat-release").returns string
116
-
117
- Facter.fact(:operatingsystem).value.should == operatingsystem
118
- end
119
- end
120
-
121
- describe "Oracle variant" do
122
- it "should be OVS if /etc/ovs-release exists" do
123
- Facter.stubs(:value).with(:lsbdistid)
124
- FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
125
- FileTest.expects(:exists?).with("/etc/ovs-release").returns true
126
- Facter.fact(:operatingsystem).value.should == "OVS"
127
- end
128
-
129
- it "should be OEL if /etc/ovs-release doesn't exist" do
130
- FileTest.expects(:exists?).with("/etc/enterprise-release").returns true
131
- FileTest.expects(:exists?).with("/etc/ovs-release").returns false
132
- Facter.fact(:operatingsystem).value.should == "OEL"
133
- end
134
- end
135
-
136
- it "should identify VMWare ESX" do
137
- Facter.stubs(:value).with(:lsbdistid).returns(nil)
138
-
139
- FileTest.expects(:exists?).with("/etc/vmware-release").returns true
140
- Facter.fact(:operatingsystem).value.should == "VMWareESX"
141
- end
142
-
143
- it "should differentiate between Scientific Linux CERN and Scientific Linux" do
144
- FileTest.expects(:exists?).with("/etc/redhat-release").returns true
145
- File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)")
146
- Facter.fact(:operatingsystem).value.should == "SLC"
147
- end
148
-
149
- it "should identify Cumulus Linux" do
150
- Facter::Util::Operatingsystem.expects(:os_release).returns({'NAME' => 'Cumulus Linux'})
151
- Facter.fact(:operatingsystem).value.should == "CumulusLinux"
152
- end
153
-
154
- it "should not use '/etc/os-release' on platforms other than Cumulus Linux" do
155
- Facter::Util::Operatingsystem.expects(:os_release).returns({'NAME' => 'Debian GNU/Linux'})
156
- FileTest.expects(:exists?).with('/etc/debian_version').returns true
157
- Facter.fact(:operatingsystem).value.should == "Debian"
158
- end
6
+ let(:os_hash) { { "name" => "SomeOS",
7
+ "family" => "SomeFamily",
8
+ "release" => "1.2.3",
9
+ "releasemajor" => "1",
10
+ }
11
+ }
12
+
13
+ it "should use the 'operatingsystem' key from the 'os' fact" do
14
+ Facter.fact("os").stubs(:value).returns(os_hash)
15
+ Facter.fact(:operatingsystem).value.should eq "SomeOS"
159
16
  end
160
17
  end
@@ -1,38 +1,21 @@
1
1
  #! /usr/bin/env ruby -S rspec
2
+
2
3
  require 'spec_helper'
3
- require 'facter'
4
4
 
5
5
  describe "OS Major Release fact" do
6
- ['Amazon','CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC','CumulusLinux'].each do |operatingsystem|
7
- context "on #{operatingsystem} operatingsystems" do
8
- it "should be derived from operatingsystemrelease" do
9
- Facter.fact(:kernel).stubs(:value).returns("Linux")
10
- Facter.fact(:operatingsystem).stubs(:value).returns(operatingsystem)
11
- Facter.fact(:operatingsystemrelease).stubs(:value).returns("6.3")
12
- Facter.fact(:operatingsystemmajrelease).value.should == "6"
13
- end
14
- end
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
6
+ let(:os_hash) { { "name" => "SomeOS",
7
+ "family" => "SomeFamily",
8
+ "release" => {
9
+ "major" => "1",
10
+ "minor" => "2",
11
+ "full" => "1.2.3"
12
+ }
13
+ }
14
+ }
32
15
 
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
16
+ it "should use the 'major' key of the 'release' key from the 'os' fact" do
17
+ Facter.fact(:operatingsystem).stubs(:value).returns("Amazon")
18
+ Facter.fact("os").stubs(:value).returns(os_hash)
19
+ Facter.fact(:operatingsystemmajrelease).value.should eq "1"
37
20
  end
38
21
  end