ohai 15.3.1 → 15.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -6
  3. data/lib/ohai/mixin/{network_constants.rb → network_helper.rb} +8 -1
  4. data/lib/ohai/plugins/aix/network.rb +3 -8
  5. data/lib/ohai/plugins/darwin/network.rb +6 -4
  6. data/lib/ohai/plugins/filesystem.rb +166 -0
  7. data/lib/ohai/plugins/network.rb +5 -5
  8. data/lib/ohai/plugins/openstack.rb +2 -1
  9. data/lib/ohai/plugins/solaris2/network.rb +6 -4
  10. data/lib/ohai/version.rb +1 -1
  11. data/ohai.gemspec +1 -1
  12. metadata +3 -162
  13. data/Rakefile +0 -42
  14. data/lib/ohai/plugins/windows/filesystem.rb +0 -147
  15. data/spec/data/plugins/dpkg-query.output +0 -4
  16. data/spec/data/plugins/lslpp.output +0 -50
  17. data/spec/data/plugins/pacman.output +0 -51
  18. data/spec/data/plugins/pkg-query.output +0 -58
  19. data/spec/data/plugins/pkginfo.output +0 -50
  20. data/spec/data/plugins/pkglist.output +0 -24
  21. data/spec/data/plugins/rpmquery.output +0 -7
  22. data/spec/functional/application_spec.rb +0 -107
  23. data/spec/functional/loader_spec.rb +0 -53
  24. data/spec/functional/plugins/powershell_spec.rb +0 -88
  25. data/spec/functional/plugins/root_group_spec.rb +0 -41
  26. data/spec/functional/plugins/windows/uptime_spec.rb +0 -51
  27. data/spec/ohai_spec.rb +0 -27
  28. data/spec/rcov.opts +0 -2
  29. data/spec/spec.opts +0 -2
  30. data/spec/spec_helper.rb +0 -124
  31. data/spec/support/integration_helper.rb +0 -61
  32. data/spec/support/platform_helpers.rb +0 -38
  33. data/spec/unit/application_spec.rb +0 -96
  34. data/spec/unit/config_spec.rb +0 -57
  35. data/spec/unit/dsl/plugin_spec.rb +0 -634
  36. data/spec/unit/hints_spec.rb +0 -65
  37. data/spec/unit/loader_spec.rb +0 -195
  38. data/spec/unit/mixin/azure_metadata_spec.rb +0 -72
  39. data/spec/unit/mixin/command_spec.rb +0 -151
  40. data/spec/unit/mixin/dmi_decode.rb +0 -75
  41. data/spec/unit/mixin/ec2_metadata_spec.rb +0 -88
  42. data/spec/unit/mixin/softlayer_metadata_spec.rb +0 -72
  43. data/spec/unit/plugin_config_spec.rb +0 -117
  44. data/spec/unit/plugins/abort_spec.rb +0 -69
  45. data/spec/unit/plugins/aix/cpu_spec.rb +0 -127
  46. data/spec/unit/plugins/aix/filesystem_spec.rb +0 -238
  47. data/spec/unit/plugins/aix/hostname_spec.rb +0 -33
  48. data/spec/unit/plugins/aix/kernel_spec.rb +0 -61
  49. data/spec/unit/plugins/aix/memory_spec.rb +0 -49
  50. data/spec/unit/plugins/aix/network_spec.rb +0 -313
  51. data/spec/unit/plugins/aix/platform_spec.rb +0 -44
  52. data/spec/unit/plugins/aix/uptime_spec.rb +0 -42
  53. data/spec/unit/plugins/aix/virtualization_spec.rb +0 -319
  54. data/spec/unit/plugins/azure_spec.rb +0 -243
  55. data/spec/unit/plugins/bsd/filesystem_spec.rb +0 -138
  56. data/spec/unit/plugins/bsd/virtualization_spec.rb +0 -145
  57. data/spec/unit/plugins/c_spec.rb +0 -341
  58. data/spec/unit/plugins/chef_spec.rb +0 -44
  59. data/spec/unit/plugins/cloud_spec.rb +0 -484
  60. data/spec/unit/plugins/darwin/cpu_spec.rb +0 -124
  61. data/spec/unit/plugins/darwin/filesystem_spec.rb +0 -140
  62. data/spec/unit/plugins/darwin/hardware_spec.rb +0 -105
  63. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +0 -1110
  64. data/spec/unit/plugins/darwin/hostname_spec.rb +0 -43
  65. data/spec/unit/plugins/darwin/kernel_spec.rb +0 -65
  66. data/spec/unit/plugins/darwin/memory_spec.rb +0 -64
  67. data/spec/unit/plugins/darwin/network_spec.rb +0 -849
  68. data/spec/unit/plugins/darwin/platform_spec.rb +0 -71
  69. data/spec/unit/plugins/darwin/virtualization_spec.rb +0 -156
  70. data/spec/unit/plugins/digital_ocean_spec.rb +0 -106
  71. data/spec/unit/plugins/dmi_spec.rb +0 -156
  72. data/spec/unit/plugins/docker_spec.rb +0 -100
  73. data/spec/unit/plugins/ec2_spec.rb +0 -452
  74. data/spec/unit/plugins/elixir_spec.rb +0 -55
  75. data/spec/unit/plugins/erlang_spec.rb +0 -71
  76. data/spec/unit/plugins/eucalyptus_spec.rb +0 -109
  77. data/spec/unit/plugins/fail_spec.rb +0 -260
  78. data/spec/unit/plugins/freebsd/cpu_spec.rb +0 -129
  79. data/spec/unit/plugins/freebsd/hostname_spec.rb +0 -35
  80. data/spec/unit/plugins/freebsd/kernel_spec.rb +0 -36
  81. data/spec/unit/plugins/freebsd/platform_spec.rb +0 -38
  82. data/spec/unit/plugins/gce_spec.rb +0 -81
  83. data/spec/unit/plugins/go_spec.rb +0 -48
  84. data/spec/unit/plugins/groovy_spec.rb +0 -66
  85. data/spec/unit/plugins/haskell_spec.rb +0 -231
  86. data/spec/unit/plugins/hostname_spec.rb +0 -162
  87. data/spec/unit/plugins/init_package_spec.rb +0 -60
  88. data/spec/unit/plugins/java_spec.rb +0 -230
  89. data/spec/unit/plugins/joyent_spec.rb +0 -100
  90. data/spec/unit/plugins/kernel_spec.rb +0 -38
  91. data/spec/unit/plugins/linode_spec.rb +0 -135
  92. data/spec/unit/plugins/linux/block_device_spec.rb +0 -75
  93. data/spec/unit/plugins/linux/cpu_spec.rb +0 -441
  94. data/spec/unit/plugins/linux/filesystem_spec.rb +0 -550
  95. data/spec/unit/plugins/linux/fips_spec.rb +0 -60
  96. data/spec/unit/plugins/linux/hostname_spec.rb +0 -52
  97. data/spec/unit/plugins/linux/hostnamectl_spec.rb +0 -59
  98. data/spec/unit/plugins/linux/kernel_spec.rb +0 -71
  99. data/spec/unit/plugins/linux/lsb_spec.rb +0 -147
  100. data/spec/unit/plugins/linux/lspci_spec.rb +0 -133
  101. data/spec/unit/plugins/linux/machineid_spec.rb +0 -46
  102. data/spec/unit/plugins/linux/mdadm_spec.rb +0 -170
  103. data/spec/unit/plugins/linux/memory_spec.rb +0 -256
  104. data/spec/unit/plugins/linux/network_spec.rb +0 -1392
  105. data/spec/unit/plugins/linux/platform_spec.rb +0 -812
  106. data/spec/unit/plugins/linux/sessions_spec.rb +0 -98
  107. data/spec/unit/plugins/linux/sysctl_spec.rb +0 -53
  108. data/spec/unit/plugins/linux/systemd_paths_spec.rb +0 -122
  109. data/spec/unit/plugins/linux/uptime_spec.rb +0 -48
  110. data/spec/unit/plugins/linux/virtualization_spec.rb +0 -650
  111. data/spec/unit/plugins/lua_spec.rb +0 -60
  112. data/spec/unit/plugins/mono_spec.rb +0 -67
  113. data/spec/unit/plugins/netbsd/hostname_spec.rb +0 -43
  114. data/spec/unit/plugins/netbsd/kernel_spec.rb +0 -35
  115. data/spec/unit/plugins/netbsd/platform_spec.rb +0 -38
  116. data/spec/unit/plugins/network_spec.rb +0 -1078
  117. data/spec/unit/plugins/nodejs_spec.rb +0 -55
  118. data/spec/unit/plugins/ohai_spec.rb +0 -32
  119. data/spec/unit/plugins/ohai_time_spec.rb +0 -44
  120. data/spec/unit/plugins/openbsd/hostname_spec.rb +0 -43
  121. data/spec/unit/plugins/openbsd/kernel_spec.rb +0 -36
  122. data/spec/unit/plugins/openbsd/platform_spec.rb +0 -33
  123. data/spec/unit/plugins/openstack_spec.rb +0 -311
  124. data/spec/unit/plugins/os_spec.rb +0 -115
  125. data/spec/unit/plugins/packages_spec.rb +0 -353
  126. data/spec/unit/plugins/passwd_spec.rb +0 -65
  127. data/spec/unit/plugins/perl_spec.rb +0 -62
  128. data/spec/unit/plugins/php_spec.rb +0 -97
  129. data/spec/unit/plugins/platform_spec.rb +0 -65
  130. data/spec/unit/plugins/powershell_spec.rb +0 -71
  131. data/spec/unit/plugins/python_spec.rb +0 -51
  132. data/spec/unit/plugins/rackspace_spec.rb +0 -350
  133. data/spec/unit/plugins/root_group_spec.rb +0 -90
  134. data/spec/unit/plugins/ruby_spec.rb +0 -60
  135. data/spec/unit/plugins/rust_spec.rb +0 -43
  136. data/spec/unit/plugins/scala_spec.rb +0 -58
  137. data/spec/unit/plugins/scaleway_spec.rb +0 -93
  138. data/spec/unit/plugins/scsi_spec.rb +0 -69
  139. data/spec/unit/plugins/shard_spec.rb +0 -121
  140. data/spec/unit/plugins/shells_spec.rb +0 -56
  141. data/spec/unit/plugins/softlayer_spec.rb +0 -60
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +0 -2926
  143. data/spec/unit/plugins/solaris2/dmi_spec.rb +0 -153
  144. data/spec/unit/plugins/solaris2/filesystem.rb +0 -407
  145. data/spec/unit/plugins/solaris2/hostname_spec.rb +0 -37
  146. data/spec/unit/plugins/solaris2/kernel_spec.rb +0 -183
  147. data/spec/unit/plugins/solaris2/memory_spec.rb +0 -43
  148. data/spec/unit/plugins/solaris2/network_spec.rb +0 -201
  149. data/spec/unit/plugins/solaris2/platform_spec.rb +0 -108
  150. data/spec/unit/plugins/solaris2/virtualization_spec.rb +0 -97
  151. data/spec/unit/plugins/ssh_host_keys_spec.rb +0 -116
  152. data/spec/unit/plugins/sysconf_spec.rb +0 -680
  153. data/spec/unit/plugins/timezone_spec.rb +0 -30
  154. data/spec/unit/plugins/vbox_host_spec.rb +0 -14
  155. data/spec/unit/plugins/virtualbox_spec.rb +0 -375
  156. data/spec/unit/plugins/vmware_spec.rb +0 -81
  157. data/spec/unit/plugins/windows/cpu_spec.rb +0 -118
  158. data/spec/unit/plugins/windows/filesystem_spec.rb +0 -226
  159. data/spec/unit/plugins/windows/fips_spec.rb +0 -60
  160. data/spec/unit/plugins/windows/kernel_spec.rb +0 -79
  161. data/spec/unit/plugins/windows/memory_spec.rb +0 -52
  162. data/spec/unit/plugins/windows/network_spec.rb +0 -137
  163. data/spec/unit/plugins/windows/system_enclosure_spec.rb +0 -45
  164. data/spec/unit/plugins/windows/uptime_spec.rb +0 -38
  165. data/spec/unit/plugins/windows/virtualization_spec.rb +0 -63
  166. data/spec/unit/plugins/zpools_spec.rb +0 -244
  167. data/spec/unit/provides_map_spec.rb +0 -208
  168. data/spec/unit/runner_spec.rb +0 -422
  169. data/spec/unit/system_spec.rb +0 -416
  170. data/spec/unit/util/file_helper_spec.rb +0 -47
  171. data/spec/unit/util/ip_helper_spec.rb +0 -128
@@ -1,60 +0,0 @@
1
- #
2
- # Author:: Matt Wrock (<matt@mattwrock.com>)
3
- # Copyright:: Copyright (c) 2016-2018 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
- require "openssl"
21
-
22
- describe Ohai::System, "plugin fips" do
23
- subject do
24
- plugin.run
25
- plugin["fips"]["kernel"]["enabled"]
26
- end
27
-
28
- let(:enabled) { "0" }
29
- let(:plugin) { get_plugin("linux/fips") }
30
- let(:openssl_test_mode) { false }
31
-
32
- before do
33
- allow(plugin).to receive(:collect_os).and_return(:linux)
34
- end
35
-
36
- around do |ex|
37
-
38
- $FIPS_TEST_MODE = openssl_test_mode
39
- ex.run
40
- ensure
41
- $FIPS_TEST_MODE = false
42
-
43
- end
44
-
45
- context "with OpenSSL.fips_mode == false" do
46
- before { allow(OpenSSL).to receive(:fips_mode).and_return(false) }
47
-
48
- it "does not set fips plugin" do
49
- expect(subject).to be(false)
50
- end
51
- end
52
-
53
- context "with OpenSSL.fips_mode == true" do
54
- before { allow(OpenSSL).to receive(:fips_mode).and_return(true) }
55
-
56
- it "sets fips plugin" do
57
- expect(subject).to be(true)
58
- end
59
- end
60
- end
@@ -1,52 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
-
21
- describe Ohai::System, "Linux hostname plugin" do
22
- before do
23
- @plugin = get_plugin("hostname")
24
- allow(@plugin).to receive(:collect_os).and_return(:linux)
25
- allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(mock_shell_out(0, "katie", ""))
26
- allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(mock_shell_out(0, "katie.bethell", ""))
27
- allow(@plugin).to receive(:shell_out).with("hostname").and_return(mock_shell_out(0, "katie.local", ""))
28
- end
29
-
30
- it_should_check_from("linux::hostname", "hostname", "hostname -s", "katie")
31
-
32
- it_should_check_from("linux::hostname", "fqdn", "hostname --fqdn", "katie.bethell")
33
-
34
- it_should_check_from("linux::hostname", "machinename", "hostname", "katie.local")
35
-
36
- describe "when domain name is unset" do
37
- before do
38
- expect(@plugin).to receive(:shell_out).with("hostname --fqdn").and_raise("Ohai::Exception::Exec")
39
- end
40
-
41
- it "does not raise an error" do
42
- expect { @plugin.run }.not_to raise_error
43
- end
44
-
45
- it "does not set fqdn" do
46
- @plugin.run
47
- expect(@plugin.fqdn).to eq(nil)
48
- end
49
-
50
- end
51
-
52
- end
@@ -1,59 +0,0 @@
1
- #
2
- # Author:: Davide Cavalca <dcavalca@fb.com>
3
- # Copyright:: Copyright (c) 2016 Facebook
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
-
21
- describe Ohai::System, "Linux hostnamectl plugin" do
22
- let(:plugin) { get_plugin("linux/hostnamectl") }
23
-
24
- before do
25
- allow(plugin).to receive(:collect_os).and_return(:linux)
26
- end
27
-
28
- it "populates hostnamectl if hostnamectl is available" do
29
- hostnamectl_out = <<-HOSTNAMECTL_OUT
30
- Static hostname: foo
31
- Icon name: computer-laptop
32
- Chassis: laptop
33
- Machine ID: 6f702523e2fc7499eb1dc68e5314dacf
34
- Boot ID: e085ae9e65e245a8a7b62912adeebe97
35
- Operating System: Debian GNU/Linux 8 (jessie)
36
- Kernel: Linux 4.3.0-0.bpo.1-amd64
37
- Architecture: x86-64
38
- HOSTNAMECTL_OUT
39
-
40
- allow(plugin).to receive(:which).with("hostnamectl").and_return("/bin/hostnamectl")
41
- allow(plugin).to receive(:shell_out).with("/bin/hostnamectl").and_return(mock_shell_out(0, hostnamectl_out, ""))
42
- plugin.run
43
- expect(plugin[:hostnamectl].to_hash).to eq({
44
- "static_hostname" => "foo",
45
- "icon_name" => "computer-laptop",
46
- "chassis" => "laptop",
47
- "machine_id" => "6f702523e2fc7499eb1dc68e5314dacf",
48
- "boot_id" => "e085ae9e65e245a8a7b62912adeebe97",
49
- "operating_system" => "Debian GNU/Linux 8 (jessie)",
50
- "kernel" => "Linux 4.3.0-0.bpo.1-amd64",
51
- "architecture" => "x86-64",
52
- })
53
- end
54
-
55
- it "does not populate hostnamectl if hostnamectl is not available" do
56
- allow(plugin).to receive(:which).with("hostnamectl").and_return(false)
57
- expect(plugin[:hostnamectl]).to eq(nil)
58
- end
59
- end
@@ -1,71 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Author:: Theodore Nordsieck (<theo@chef.io>)
4
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
5
- # License:: Apache License, Version 2.0
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
- #
19
-
20
- require "spec_helper"
21
-
22
- describe Ohai::System, "Linux kernel plugin" do
23
- before do
24
- @env_lsmod = <<~ENV_LSMOD
25
- Module Size Used by
26
- dm_crypt 22321 0
27
- psmouse 81038 0
28
- acpiphp 23314 0
29
- microcode 18286 0
30
- serio_raw 13031 0
31
- virtio_balloon 13168 0
32
- floppy 55441 0
33
- ENV_LSMOD
34
- @version_module = {
35
- dm_crypt: "",
36
- psmouse: "",
37
- acpiphp: "",
38
- microcode: "1.2.3",
39
- serio_raw: "",
40
- virtio_balloon: "",
41
- floppy: "",
42
- }
43
-
44
- @expected_result = {
45
- "dm_crypt" => { "size" => "22321", "refcount" => "0" },
46
- "psmouse" => { "size" => "81038", "refcount" => "0" },
47
- "acpiphp" => { "size" => "23314", "refcount" => "0" },
48
- "microcode" => { "size" => "18286", "refcount" => "0", "version" => "1.2.3" },
49
- "serio_raw" => { "size" => "13031", "refcount" => "0" },
50
- "virtio_balloon" => { "size" => "13168", "refcount" => "0" },
51
- "floppy" => { "size" => "55441", "refcount" => "0" },
52
- }
53
- @plugin = get_plugin("kernel")
54
- allow(@plugin).to receive(:collect_os).and_return(:linux)
55
- allow(@plugin).to receive(:init_kernel).and_return({})
56
- allow(@plugin).to receive(:shell_out).with("uname -o").and_return(mock_shell_out(0, "Linux", ""))
57
- allow(@plugin).to receive(:shell_out).with("env lsmod").and_return(mock_shell_out(0, @env_lsmod, ""))
58
- @version_module.each do |mod, vers|
59
- allow(File).to receive(:exist?).with("/sys/module/#{mod}/version").and_return(true)
60
- allow(File).to receive(:read).with("/sys/module/#{mod}/version").and_return(vers)
61
- end
62
- expect(@plugin).to receive(:shell_out).with("env lsmod").at_least(1).times
63
- @plugin.run
64
- end
65
-
66
- it_should_check_from_deep_mash("linux::kernel", "kernel", "os", "uname -o", [0, "Linux", ""])
67
-
68
- it "collects linux::kernel::modules" do
69
- expect(@plugin.data["kernel"]["modules"]).to eq(@expected_result)
70
- end
71
- end
@@ -1,147 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
-
21
- # We do not alter case for lsb attributes and consume them as provided
22
-
23
- describe Ohai::System, "Linux lsb plugin" do
24
- before do
25
- @plugin = get_plugin("linux/lsb")
26
- allow(@plugin).to receive(:collect_os).and_return(:linux)
27
- end
28
-
29
- describe "on systems with /etc/lsb-release" do
30
- before do
31
- @double_file = double("/etc/lsb-release")
32
- allow(@double_file).to receive(:each)
33
- .and_yield("DISTRIB_ID=Ubuntu")
34
- .and_yield("DISTRIB_RELEASE=8.04")
35
- .and_yield("DISTRIB_CODENAME=hardy")
36
- .and_yield('DISTRIB_DESCRIPTION="Ubuntu 8.04"')
37
- allow(File).to receive(:open).with("/etc/lsb-release").and_return(@double_file)
38
- allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(false)
39
- allow(File).to receive(:exist?).with("/etc/lsb-release").and_return(true)
40
- end
41
-
42
- it "sets lsb[:id]" do
43
- @plugin.run
44
- expect(@plugin[:lsb][:id]).to eq("Ubuntu")
45
- end
46
-
47
- it "sets lsb[:release]" do
48
- @plugin.run
49
- expect(@plugin[:lsb][:release]).to eq("8.04")
50
- end
51
-
52
- it "sets lsb[:codename]" do
53
- @plugin.run
54
- expect(@plugin[:lsb][:codename]).to eq("hardy")
55
- end
56
-
57
- it "sets lsb[:description]" do
58
- @plugin.run
59
- expect(@plugin[:lsb][:description]).to eq("Ubuntu 8.04")
60
- end
61
- end
62
-
63
- describe "on systems with /usr/bin/lsb_release" do
64
- before do
65
- allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(true)
66
-
67
- @stdin = double("STDIN", { close: true })
68
- @pid = 10
69
- @stderr = double("STDERR")
70
- @stdout = double("STDOUT")
71
- @status = 0
72
-
73
- end
74
-
75
- describe "on Centos 5.4 correctly" do
76
- before do
77
- @stdout = <<~LSB_RELEASE
78
- LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
79
- Distributor ID: CentOS
80
- Description: CentOS release 5.4 (Final)
81
- Release: 5.4
82
- Codename: Final
83
- LSB_RELEASE
84
- allow(@plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
85
- end
86
-
87
- it "sets lsb[:id]" do
88
- @plugin.run
89
- expect(@plugin[:lsb][:id]).to eq("CentOS")
90
- end
91
-
92
- it "sets lsb[:release]" do
93
- @plugin.run
94
- expect(@plugin[:lsb][:release]).to eq("5.4")
95
- end
96
-
97
- it "sets lsb[:codename]" do
98
- @plugin.run
99
- expect(@plugin[:lsb][:codename]).to eq("Final")
100
- end
101
-
102
- it "sets lsb[:description]" do
103
- @plugin.run
104
- expect(@plugin[:lsb][:description]).to eq("CentOS release 5.4 (Final)")
105
- end
106
- end
107
-
108
- describe "on Fedora 14 correctly" do
109
- before do
110
- @stdout = <<~LSB_RELEASE
111
- LSB Version: :core-4.0-ia32:core-4.0-noarch
112
- Distributor ID: Fedora
113
- Description: Fedora release 14 (Laughlin)
114
- Release: 14
115
- Codename: Laughlin
116
- LSB_RELEASE
117
- allow(@plugin).to receive(:shell_out).with("lsb_release -a").and_return(mock_shell_out(0, @stdout, ""))
118
- end
119
-
120
- it "sets lsb[:id]" do
121
- @plugin.run
122
- expect(@plugin[:lsb][:id]).to eq("Fedora")
123
- end
124
-
125
- it "sets lsb[:release]" do
126
- @plugin.run
127
- expect(@plugin[:lsb][:release]).to eq("14")
128
- end
129
-
130
- it "sets lsb[:codename]" do
131
- @plugin.run
132
- expect(@plugin[:lsb][:codename]).to eq("Laughlin")
133
- end
134
-
135
- it "sets lsb[:description]" do
136
- @plugin.run
137
- expect(@plugin[:lsb][:description]).to eq("Fedora release 14 (Laughlin)")
138
- end
139
- end
140
- end
141
-
142
- it "does not set any lsb values if /etc/lsb-release or /usr/bin/lsb_release do not exist " do
143
- allow(File).to receive(:exist?).with("/etc/lsb-release").and_return(false)
144
- allow(File).to receive(:exist?).with("/usr/bin/lsb_release").and_return(false)
145
- expect(@plugin.attribute?(:lsb)).to be(false)
146
- end
147
- end
@@ -1,133 +0,0 @@
1
- #
2
- # Author:: Phil Dibowitz <phil@ipom.com>
3
- # Copyright:: Copyright (c) 2017 Facebook, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require "spec_helper"
20
-
21
- describe Ohai::System, "Linux lspci plugin" do
22
- let(:plugin) { get_plugin("linux/lspci") }
23
-
24
- before do
25
- allow(plugin).to receive(:collect_os).and_return(:linux)
26
- @stdout = <<~LSPCI
27
- Device: 00:1f.3
28
- Class: Audio device [0403]
29
- Vendor: Intel Corporation [8086]
30
- Device: Sunrise Point-LP HD Audio [9d71]
31
- SVendor: Lenovo [17aa]
32
- SDevice: Sunrise Point-LP HD Audio [224e]
33
- Rev: 21
34
- Driver: snd_hda_intel
35
- Module: snd_hda_intel
36
- Module: snd_soc_skl
37
-
38
- Device: 00:1f.4
39
- Class: SMBus [0c05]
40
- Vendor: Intel Corporation [8086]
41
- Device: Sunrise Point-LP SMBus [9d23]
42
- SVendor: Lenovo [17aa]
43
- SDevice: Sunrise Point-LP SMBus [224e]
44
- Rev: 21
45
- Driver: i801_smbus
46
- Module: i2c_i801
47
-
48
- Device: 00:1f.6
49
- Class: Ethernet controller [0200]
50
- Vendor: Intel Corporation [8086]
51
- Device: Ethernet Connection (4) I219-LM [15d7]
52
- SVendor: Lenovo [17aa]
53
- SDevice: Ethernet Connection (4) I219-LM [224e]
54
- Rev: 21
55
- Driver: e1000e
56
- Module: e1000e
57
-
58
- Device: 02:00.0
59
- Class: Unassigned class [ff00]
60
- Vendor: Realtek Semiconductor Co., Ltd. [10ec]
61
- Device: RTS525A PCI Express Card Reader [525a]
62
- SVendor: Lenovo [17aa]
63
- SDevice: RTS525A PCI Express Card Reader [224e]
64
- Rev: 01
65
- Driver: rtsx_pci
66
- Module: rtsx_pci
67
-
68
- Device: 04:00.0
69
- Class: Network controller [0280]
70
- Vendor: Intel Corporation [8086]
71
- Device: Wireless 8265 / 8275 [24fd]
72
- SVendor: Intel Corporation [8086]
73
- SDevice: Wireless 8265 / 8275 [0130]
74
- Rev: 88
75
- Driver: iwlwifi
76
- Module: iwlwifi
77
-
78
- Device: 05:00.0
79
- Class: Non-Volatile memory controller [0108]
80
- Vendor: Toshiba America Info Systems [1179]
81
- Device: Device [0115]
82
- SVendor: Toshiba America Info Systems [1179]
83
- SDevice: Device [0001]
84
- Rev: 01
85
- ProgIf: 02
86
- Driver: nvme
87
- Module: nvme
88
- NUMANode: 0
89
- LSPCI
90
- allow(plugin).to receive(:shell_out).with("lspci -vnnmk").and_return(
91
- mock_shell_out(0, @stdout, "")
92
- )
93
- end
94
-
95
- describe "when gathering data from lspci" do
96
- it "lists all devices" do
97
- plugin.run
98
- expect(plugin[:pci].keys).to eq(
99
- ["00:1f.3", "00:1f.4", "00:1f.6", "02:00.0", "04:00.0", "05:00.0"]
100
- )
101
- end
102
-
103
- it "parses out device name vs id" do
104
- plugin.run
105
- expect(plugin[:pci]["04:00.0"]["device_name"]).to eq("Wireless 8265 / 8275")
106
- expect(plugin[:pci]["04:00.0"]["device_id"]).to eq("24fd")
107
- end
108
-
109
- it "parses out sdevice name vs id" do
110
- plugin.run
111
- expect(plugin[:pci]["04:00.0"]["sdevice_name"]).to eq("Wireless 8265 / 8275")
112
- expect(plugin[:pci]["04:00.0"]["sdevice_id"]).to eq("0130")
113
- end
114
-
115
- it "parses out class name vs id" do
116
- plugin.run
117
- expect(plugin[:pci]["04:00.0"]["class_name"]).to eq("Network controller")
118
- expect(plugin[:pci]["04:00.0"]["class_id"]).to eq("0280")
119
- end
120
-
121
- it "parses out vendor name vs id" do
122
- plugin.run
123
- expect(plugin[:pci]["04:00.0"]["vendor_name"]).to eq("Intel Corporation")
124
- expect(plugin[:pci]["04:00.0"]["vendor_id"]).to eq("8086")
125
- end
126
-
127
- it "provides drivers and modules" do
128
- plugin.run
129
- expect(plugin[:pci]["04:00.0"]["driver"]).to eq(["iwlwifi"])
130
- expect(plugin[:pci]["04:00.0"]["module"]).to eq(["iwlwifi"])
131
- end
132
- end
133
- end