ohai 14.15.0 → 15.0.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/lib/ohai/application.rb +0 -4
  4. data/lib/ohai/common/dmi.rb +43 -43
  5. data/lib/ohai/config.rb +1 -1
  6. data/lib/ohai/loader.rb +32 -47
  7. data/lib/ohai/mixin/dmi_decode.rb +29 -32
  8. data/lib/ohai/mixin/os.rb +0 -2
  9. data/lib/ohai/mixin/softlayer_metadata.rb +5 -5
  10. data/lib/ohai/plugins/aix/virtualization.rb +4 -4
  11. data/lib/ohai/plugins/bsd/virtualization.rb +10 -12
  12. data/lib/ohai/plugins/c.rb +0 -20
  13. data/lib/ohai/plugins/elixir.rb +13 -13
  14. data/lib/ohai/plugins/filesystem.rb +10 -10
  15. data/lib/ohai/plugins/gce.rb +42 -8
  16. data/lib/ohai/plugins/go.rb +11 -11
  17. data/lib/ohai/plugins/groovy.rb +12 -12
  18. data/lib/ohai/plugins/hostname.rb +9 -2
  19. data/lib/ohai/plugins/linux/fips.rb +2 -9
  20. data/lib/ohai/plugins/linux/memory.rb +5 -0
  21. data/lib/ohai/plugins/linux/network.rb +1 -1
  22. data/lib/ohai/plugins/linux/platform.rb +84 -83
  23. data/lib/ohai/plugins/linux/systemd_paths.rb +0 -3
  24. data/lib/ohai/plugins/linux/virtualization.rb +10 -20
  25. data/lib/ohai/plugins/lua.rb +13 -13
  26. data/lib/ohai/plugins/mono.rb +23 -23
  27. data/lib/ohai/plugins/nodejs.rb +13 -13
  28. data/lib/ohai/plugins/openstack.rb +1 -1
  29. data/lib/ohai/plugins/packages.rb +1 -28
  30. data/lib/ohai/plugins/perl.rb +17 -17
  31. data/lib/ohai/plugins/php.rb +22 -22
  32. data/lib/ohai/plugins/powershell.rb +30 -30
  33. data/lib/ohai/plugins/ps.rb +1 -1
  34. data/lib/ohai/plugins/python.rb +15 -15
  35. data/lib/ohai/plugins/rust.rb +11 -11
  36. data/lib/ohai/plugins/solaris2/dmi.rb +48 -48
  37. data/lib/ohai/plugins/solaris2/virtualization.rb +8 -10
  38. data/lib/ohai/plugins/virtualbox.rb +21 -21
  39. data/lib/ohai/plugins/windows/filesystem.rb +2 -2
  40. data/lib/ohai/plugins/windows/fips.rb +2 -21
  41. data/lib/ohai/plugins/windows/virtualization.rb +9 -35
  42. data/lib/ohai/runner.rb +2 -2
  43. data/lib/ohai/system.rb +0 -17
  44. data/lib/ohai/version.rb +1 -1
  45. data/ohai.gemspec +2 -2
  46. data/spec/data/plugins/rpmquery.output +0 -2
  47. data/spec/functional/application_spec.rb +1 -1
  48. data/spec/functional/loader_spec.rb +2 -2
  49. data/spec/functional/plugins/powershell_spec.rb +2 -2
  50. data/spec/functional/plugins/root_group_spec.rb +1 -1
  51. data/spec/functional/plugins/windows/uptime_spec.rb +2 -2
  52. data/spec/ohai_spec.rb +1 -1
  53. data/spec/unit/application_spec.rb +1 -1
  54. data/spec/unit/config_spec.rb +1 -1
  55. data/spec/unit/dsl/plugin_spec.rb +1 -1
  56. data/spec/unit/hints_spec.rb +2 -2
  57. data/spec/unit/loader_spec.rb +12 -12
  58. data/spec/unit/mixin/azure_metadata_spec.rb +1 -1
  59. data/spec/unit/mixin/command_spec.rb +1 -1
  60. data/spec/unit/mixin/dmi_decode.rb +68 -0
  61. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  62. data/spec/unit/mixin/softlayer_metadata_spec.rb +1 -1
  63. data/spec/unit/plugin_config_spec.rb +1 -1
  64. data/spec/unit/plugins/abort_spec.rb +9 -9
  65. data/spec/unit/plugins/aix/cpu_spec.rb +4 -4
  66. data/spec/unit/plugins/aix/filesystem_spec.rb +5 -5
  67. data/spec/unit/plugins/aix/hostname_spec.rb +1 -1
  68. data/spec/unit/plugins/aix/kernel_spec.rb +1 -1
  69. data/spec/unit/plugins/aix/memory_spec.rb +1 -1
  70. data/spec/unit/plugins/aix/network_spec.rb +6 -6
  71. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  72. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  73. data/spec/unit/plugins/aix/virtualization_spec.rb +2 -2
  74. data/spec/unit/plugins/azure_spec.rb +1 -1
  75. data/spec/unit/plugins/bsd/filesystem_spec.rb +4 -4
  76. data/spec/unit/plugins/bsd/virtualization_spec.rb +3 -3
  77. data/spec/unit/plugins/c_spec.rb +1 -53
  78. data/spec/unit/plugins/chef_spec.rb +1 -1
  79. data/spec/unit/plugins/cloud_spec.rb +1 -1
  80. data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
  81. data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
  82. data/spec/unit/plugins/darwin/hardware_spec.rb +2 -2
  83. data/spec/unit/plugins/darwin/hardware_system_profiler_output.rb +3 -3
  84. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -1
  85. data/spec/unit/plugins/darwin/kernel_spec.rb +1 -1
  86. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  87. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  88. data/spec/unit/plugins/darwin/platform_spec.rb +1 -1
  89. data/spec/unit/plugins/darwin/virtualization_spec.rb +1 -1
  90. data/spec/unit/plugins/dmi_spec.rb +1 -1
  91. data/spec/unit/plugins/docker_spec.rb +1 -1
  92. data/spec/unit/plugins/ec2_spec.rb +1 -1
  93. data/spec/unit/plugins/elixir_spec.rb +1 -1
  94. data/spec/unit/plugins/erlang_spec.rb +1 -1
  95. data/spec/unit/plugins/eucalyptus_spec.rb +1 -1
  96. data/spec/unit/plugins/fail_spec.rb +28 -28
  97. data/spec/unit/plugins/freebsd/cpu_spec.rb +1 -1
  98. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -1
  99. data/spec/unit/plugins/freebsd/kernel_spec.rb +1 -1
  100. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -1
  101. data/spec/unit/plugins/gce_spec.rb +1 -1
  102. data/spec/unit/plugins/go_spec.rb +1 -1
  103. data/spec/unit/plugins/groovy_spec.rb +1 -1
  104. data/spec/unit/plugins/haskell_spec.rb +1 -1
  105. data/spec/unit/plugins/hostname_spec.rb +68 -1
  106. data/spec/unit/plugins/init_package_spec.rb +1 -1
  107. data/spec/unit/plugins/java_spec.rb +1 -1
  108. data/spec/unit/plugins/joyent_spec.rb +3 -3
  109. data/spec/unit/plugins/kernel_spec.rb +1 -1
  110. data/spec/unit/plugins/linode_spec.rb +1 -1
  111. data/spec/unit/plugins/linux/block_device_spec.rb +1 -1
  112. data/spec/unit/plugins/linux/cpu_spec.rb +6 -6
  113. data/spec/unit/plugins/linux/filesystem_spec.rb +21 -21
  114. data/spec/unit/plugins/linux/fips_spec.rb +13 -45
  115. data/spec/unit/plugins/linux/hostname_spec.rb +1 -1
  116. data/spec/unit/plugins/linux/hostnamectl_spec.rb +2 -2
  117. data/spec/unit/plugins/linux/kernel_spec.rb +8 -8
  118. data/spec/unit/plugins/linux/lsb_spec.rb +3 -3
  119. data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
  120. data/spec/unit/plugins/linux/machineid_spec.rb +1 -1
  121. data/spec/unit/plugins/linux/mdadm_spec.rb +2 -2
  122. data/spec/unit/plugins/linux/memory_spec.rb +26 -1
  123. data/spec/unit/plugins/linux/network_spec.rb +37 -37
  124. data/spec/unit/plugins/linux/platform_spec.rb +580 -837
  125. data/spec/unit/plugins/linux/sessions_spec.rb +2 -2
  126. data/spec/unit/plugins/linux/systemd_paths_spec.rb +1 -1
  127. data/spec/unit/plugins/linux/uptime_spec.rb +1 -1
  128. data/spec/unit/plugins/linux/virtualization_spec.rb +28 -227
  129. data/spec/unit/plugins/lua_spec.rb +1 -1
  130. data/spec/unit/plugins/mono_spec.rb +2 -2
  131. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -1
  132. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -1
  133. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  134. data/spec/unit/plugins/network_spec.rb +11 -11
  135. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  136. data/spec/unit/plugins/ohai_spec.rb +1 -1
  137. data/spec/unit/plugins/ohai_time_spec.rb +1 -1
  138. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -1
  139. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -1
  140. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -1
  141. data/spec/unit/plugins/openstack_spec.rb +8 -4
  142. data/spec/unit/plugins/os_spec.rb +1 -1
  143. data/spec/unit/plugins/packages_spec.rb +1 -21
  144. data/spec/unit/plugins/passwd_spec.rb +1 -1
  145. data/spec/unit/plugins/perl_spec.rb +1 -1
  146. data/spec/unit/plugins/php_spec.rb +6 -6
  147. data/spec/unit/plugins/platform_spec.rb +1 -1
  148. data/spec/unit/plugins/powershell_spec.rb +3 -3
  149. data/spec/unit/plugins/python_spec.rb +1 -1
  150. data/spec/unit/plugins/rackspace_spec.rb +2 -2
  151. data/spec/unit/plugins/root_group_spec.rb +1 -11
  152. data/spec/unit/plugins/ruby_spec.rb +1 -1
  153. data/spec/unit/plugins/rust_spec.rb +1 -1
  154. data/spec/unit/plugins/scala_spec.rb +1 -1
  155. data/spec/unit/plugins/scsi_spec.rb +2 -2
  156. data/spec/unit/plugins/shard_spec.rb +1 -1
  157. data/spec/unit/plugins/shells_spec.rb +1 -1
  158. data/spec/unit/plugins/softlayer_spec.rb +1 -1
  159. data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
  160. data/spec/unit/plugins/solaris2/dmi_spec.rb +1 -1
  161. data/spec/unit/plugins/solaris2/filesystem.rb +4 -4
  162. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  163. data/spec/unit/plugins/solaris2/kernel_spec.rb +1 -1
  164. data/spec/unit/plugins/solaris2/memory_spec.rb +1 -1
  165. data/spec/unit/plugins/solaris2/network_spec.rb +6 -6
  166. data/spec/unit/plugins/solaris2/platform_spec.rb +3 -3
  167. data/spec/unit/plugins/solaris2/virtualization_spec.rb +41 -69
  168. data/spec/unit/plugins/ssh_host_keys_spec.rb +3 -3
  169. data/spec/unit/plugins/sysconf_spec.rb +2 -2
  170. data/spec/unit/plugins/timezone_spec.rb +1 -1
  171. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  172. data/spec/unit/plugins/vmware_spec.rb +1 -1
  173. data/spec/unit/plugins/windows/cpu_spec.rb +1 -2
  174. data/spec/unit/plugins/windows/filesystem_spec.rb +2 -2
  175. data/spec/unit/plugins/windows/fips_spec.rb +17 -77
  176. data/spec/unit/plugins/windows/kernel_spec.rb +1 -1
  177. data/spec/unit/plugins/windows/memory_spec.rb +2 -2
  178. data/spec/unit/plugins/windows/network_spec.rb +1 -1
  179. data/spec/unit/plugins/windows/system_enclosure_spec.rb +1 -1
  180. data/spec/unit/plugins/windows/uptime_spec.rb +1 -1
  181. data/spec/unit/plugins/windows/virtualization_spec.rb +20 -238
  182. data/spec/unit/plugins/zpools_spec.rb +7 -7
  183. data/spec/unit/provides_map_spec.rb +1 -1
  184. data/spec/unit/runner_spec.rb +1 -1
  185. data/spec/unit/system_spec.rb +10 -77
  186. data/spec/unit/util/file_helper_spec.rb +1 -1
  187. data/spec/unit/util/ip_helper_spec.rb +1 -1
  188. metadata +6 -9
  189. data/lib/ohai/plugins/darwin/system_profiler.rb +0 -72
  190. data/lib/ohai/util/win32/group_helper.rb +0 -76
  191. data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -79524
  192. data/spec/unit/plugins/darwin/system_profiler_spec.rb +0 -40
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  SOLARIS_DMI_OUT = <<~EOS.freeze
22
22
  ID SIZE TYPE
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require_relative "../../../spec_helper"
18
+ require_relative "spec_helper"
19
19
 
20
20
  describe Ohai::System, "Solaris2.X filesystem plugin" do
21
21
  let(:plugin) { get_plugin("filesystem") }
@@ -60,7 +60,7 @@ describe Ohai::System, "Solaris2.X filesystem plugin" do
60
60
  -hosts 0 0 0 0% /net
61
61
  auto_home 0 0 0 0% /home
62
62
  -fedfs 0 0 0 0% /nfs4
63
- DF_PKA
63
+ DF_PKA
64
64
 
65
65
  @mount = <<~MOUNT
66
66
  / on rpool/ROOT/solaris-0 read/write/setuid/nodevices/rstchown/nonbmand/exec/xattr/atime/mountpoint=/zones/servername.chef.internal.dns/root//zone=servername.chef.internal.dns/nozonemod/sharezone=151/dev=4bd0b7e on Fri Feb 2 16:27:36 2018
@@ -82,7 +82,7 @@ DF_PKA
82
82
  /var/share/pkg/repositories on rpool/VARSHARE/pkg/repositories read/write/setuid/nodevices/rstchown/nonbmand/exec/xattr/atime/zone=servername.chef.internal.dns/sharezone=151/dev=4bd0b85 on Fri Feb 2 16:28:12 2018
83
83
  /export/home/<usernameredacted> on rpool/export/home/<usernameredacted> read/write/setuid/nodevices/rstchown/nonbmand/exec/xattr/atime/zone=servername.chef.internal.dns/sharezone=151/dev=4bd0b8a on Fri Feb 2 16:39:15 2018
84
84
  /export/home/<usernameredacted> on rpool/export/home/<usernameredacted> read/write/setuid/nodevices/rstchown/nonbmand/exec/xattr/atime/zone=servername.chef.internal.dns/sharezone=151/dev=4bd0b8b on Fri Feb 2 16:39:16 2018
85
- MOUNT
85
+ MOUNT
86
86
 
87
87
  @zfs_get = <<~ZFS_GET
88
88
  data0 type filesystem -
@@ -323,7 +323,7 @@ MOUNT
323
323
  data0/Movies relatime off default
324
324
  data0/Movies redundant_metadata all default
325
325
  data0/Movies overlay off default:
326
- ZFS_GET
326
+ ZFS_GET
327
327
  end
328
328
 
329
329
  after(:each) do
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "Solaris2.X hostname plugin" do
22
22
  before(:each) do
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "Solaris2.X kernel plugin" do
22
22
  # NOTE: Solaris will report the same module loaded multiple times
@@ -14,7 +14,7 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require_relative "../../../spec_helper.rb"
17
+ require "spec_helper"
18
18
 
19
19
  describe Ohai::System, "Solaris2.X memory plugin" do
20
20
  before(:each) do
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "Solaris2.X network plugin" do
22
22
 
@@ -41,7 +41,7 @@ describe Ohai::System, "Solaris2.X network plugin" do
41
41
  rtls0 172.31.4.82 255.255.255.255 52:54:00:2d:93:0c
42
42
  rtls0 172.31.4.81 255.255.255.255 02:08:20:37:80:87
43
43
  rtls0 224.0.0.0 240.0.0.0 SM 01:00:5e:00:00:00
44
- ARP_RN
44
+ ARP_RN
45
45
 
46
46
  @solaris_ifconfig = <<~ENDIFCONFIG
47
47
  lo0:3: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
@@ -80,7 +80,7 @@ ARP_RN
80
80
  vni0: flags=2002210041<UP,RUNNING,NOXMIT,NONUD,IPv6,VIRTUAL> mtu 1460 index 5
81
81
  srcof qfe1
82
82
  inet6 fe80::203:baff:fe17:4444/128
83
- ENDIFCONFIG
83
+ ENDIFCONFIG
84
84
 
85
85
  @solaris_netstat_rn = <<~NETSTAT_RN
86
86
  Routing Table: IPv4
@@ -95,7 +95,7 @@ ENDIFCONFIG
95
95
  --------------------------- --------------------------- ----- --- ------- -----
96
96
  fe80::/10 fe80::250:56ff:fe13:3757 U 1 0 e1000g0
97
97
  ::1 ::1 UH 1 0 lo0
98
- NETSTAT_RN
98
+ NETSTAT_RN
99
99
 
100
100
  @solaris_route_get = <<~ROUTE_GET
101
101
  route to: default
@@ -106,7 +106,7 @@ NETSTAT_RN
106
106
  flags: <UP,GATEWAY,DONE,STATIC>
107
107
  recvpipe sendpipe ssthresh rtt,ms rttvar,ms hopcount mtu expire
108
108
  0 0 0 0 0 0 1500 0
109
- ROUTE_GET
109
+ ROUTE_GET
110
110
 
111
111
  @solaris11_route_get = <<~ROUTE_GET
112
112
  route to: default
@@ -117,7 +117,7 @@ ROUTE_GET
117
117
  flags: <UP,GATEWAY,DONE,STATIC>
118
118
  recvpipe sendpipe ssthresh rtt,ms rttvar,ms hopcount mtu expire
119
119
  0 0 0 0 0 0 1500 0
120
- ROUTE_GET
120
+ ROUTE_GET
121
121
 
122
122
  @ifconfig_lines = @solaris_ifconfig.split("\n")
123
123
 
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "Solaris plugin platform" do
22
22
  before(:each) do
@@ -39,7 +39,7 @@ describe Ohai::System, "Solaris plugin platform" do
39
39
  OEM# = 0
40
40
  Origin# = 1
41
41
  NumCPU = 16
42
- UNAME_X
42
+ UNAME_X
43
43
 
44
44
  allow(File).to receive(:exist?).with("/sbin/uname").and_return(true)
45
45
  allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
@@ -79,7 +79,7 @@ UNAME_X
79
79
  OEM# = 0
80
80
  Origin# = 1
81
81
  NumCPU = 1
82
- UNAME_X
82
+ UNAME_X
83
83
 
84
84
  allow(File).to receive(:exist?).with("/sbin/uname").and_return(true)
85
85
  allow(@plugin).to receive(:shell_out).with("/sbin/uname -X").and_return(mock_shell_out(0, @uname_x, ""))
@@ -16,25 +16,26 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "Solaris virtualization platform" do
22
+ let(:plugin) { get_plugin("solaris2/virtualization") }
23
+
22
24
  before(:each) do
23
25
  @psrinfo_pv = <<~PSRINFO_PV
24
26
  The physical processor has 1 virtual processor (0)
25
27
  x86 (GenuineIntel family 6 model 2 step 3 clock 2667 MHz)
26
28
  Intel Pentium(r) Pro
27
- PSRINFO_PV
29
+ PSRINFO_PV
28
30
 
29
- @plugin = get_plugin("solaris2/virtualization")
30
- allow(@plugin).to receive(:collect_os).and_return(:solaris2)
31
+ allow(plugin).to receive(:collect_os).and_return(:solaris2)
31
32
 
32
33
  # default to all requested Files not existing
33
34
  allow(File).to receive(:exist?).with("/usr/sbin/psrinfo").and_return(false)
34
35
  allow(File).to receive(:exist?).with("/usr/sbin/smbios").and_return(false)
35
36
  allow(File).to receive(:exist?).with("/usr/sbin/zoneadm").and_return(false)
36
- allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, "", ""))
37
- allow(@plugin).to receive(:shell_out).with("#{Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", ""))
37
+ allow(plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, "", ""))
38
+ allow(plugin).to receive(:shell_out).with("#{Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "", ""))
38
39
  end
39
40
 
40
41
  describe "when we are checking for kvm" do
@@ -43,83 +44,54 @@ PSRINFO_PV
43
44
  end
44
45
 
45
46
  it "should run psrinfo -pv" do
46
- expect(@plugin).to receive(:shell_out).with("#{Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv")
47
- @plugin.run
47
+ expect(plugin).to receive(:shell_out).with("#{Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv")
48
+ plugin.run
48
49
  end
49
50
 
50
51
  it "Should set kvm guest if psrinfo -pv contains QEMU Virtual CPU" do
51
- allow(@plugin).to receive(:shell_out).with("#{Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "QEMU Virtual CPU", ""))
52
- @plugin.run
53
- expect(@plugin[:virtualization][:system]).to eq("kvm")
54
- expect(@plugin[:virtualization][:role]).to eq("guest")
55
- expect(@plugin[:virtualization][:systems][:kvm]).to eq("guest")
52
+ allow(plugin).to receive(:shell_out).with("#{Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, "QEMU Virtual CPU", ""))
53
+ plugin.run
54
+ expect(plugin[:virtualization][:system]).to eq("kvm")
55
+ expect(plugin[:virtualization][:role]).to eq("guest")
56
+ expect(plugin[:virtualization][:systems][:kvm]).to eq("guest")
56
57
  end
57
58
 
58
59
  it "should not set virtualization if kvm isn't there" do
59
- expect(@plugin).to receive(:shell_out).with("#{Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, ""))
60
- @plugin.run
61
- expect(@plugin[:virtualization][:systems]).to eq({})
60
+ expect(plugin).to receive(:shell_out).with("#{Ohai.abs_path( "/usr/sbin/psrinfo" )} -pv").and_return(mock_shell_out(0, @psrinfo_pv, ""))
61
+ plugin.run
62
+ expect(plugin[:virtualization][:systems]).to eq({})
62
63
  end
63
64
  end
64
65
 
65
- describe "when we are parsing smbios" do
66
- before(:each) do
67
- expect(File).to receive(:exist?).with("/usr/sbin/smbios").and_return(true)
68
- end
69
-
70
- it "should run smbios" do
71
- expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios")
72
- @plugin.run
73
- end
74
-
75
- it "should set virtualpc guest if smbios detects Microsoft Virtual Machine" do
76
- ms_vpc_smbios = <<~MSVPC
77
- ID SIZE TYPE
78
- 1 72 SMB_TYPE_SYSTEM (system information)
79
-
80
- Manufacturer: Microsoft Corporation
81
- Product: Virtual Machine
82
- Version: VS2005R2
83
- Serial Number: 1688-7189-5337-7903-2297-1012-52
84
-
85
- UUID: D29974A4-BE51-044C-BDC6-EFBC4B87A8E9
86
- Wake-Up Event: 0x6 (power switch)
87
- MSVPC
88
- allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, ms_vpc_smbios, ""))
89
- @plugin.run
90
- expect(@plugin[:virtualization][:system]).to eq("virtualpc")
91
- expect(@plugin[:virtualization][:role]).to eq("guest")
92
- end
93
-
94
- it "should set vmware guest if smbios detects VMware Virtual Platform" do
95
- vmware_smbios = <<~VMWARE
96
- ID SIZE TYPE
97
- 1 72 SMB_TYPE_SYSTEM (system information)
98
-
99
- Manufacturer: VMware, Inc.
100
- Product: VMware Virtual Platform
101
- Version: None
102
- Serial Number: VMware-50 3f f7 14 42 d1 f1 da-3b 46 27 d0 29 b4 74 1d
103
-
104
- UUID: a86cc405-e1b9-447b-ad05-6f8db39d876a
105
- Wake-Up Event: 0x6 (power switch)
106
- VMWARE
107
- allow(@plugin).to receive(:shell_out).with("/usr/sbin/smbios").and_return(mock_shell_out(0, vmware_smbios, ""))
108
- @plugin.run
109
- expect(@plugin[:virtualization][:system]).to eq("vmware")
110
- expect(@plugin[:virtualization][:role]).to eq("guest")
111
- expect(@plugin[:virtualization][:systems][:vmware]).to eq("guest")
66
+ describe "when we are parsing DMI data" do
67
+
68
+ it "sets virtualization attributes if the appropriate DMI data is present" do
69
+ plugin[:dmi] = { system: {
70
+ manufacturer: "Amazon EC2",
71
+ product: "c5n.large",
72
+ version: nil,
73
+ },
74
+ }
75
+ plugin.run
76
+ expect(plugin[:virtualization][:system]).to eq("amazonec2")
77
+ expect(plugin[:virtualization][:role]).to eq("guest")
78
+ expect(plugin[:virtualization][:systems][:amazonec2]).to eq("guest")
112
79
  end
113
80
 
114
- it "should run smbios and not set virtualization if nothing is detected" do
115
- expect(@plugin).to receive(:shell_out).with("/usr/sbin/smbios")
116
- @plugin.run
117
- expect(@plugin[:virtualization][:systems]).to eq({})
81
+ it "sets empty virtualization attributes if nothing is detected" do
82
+ plugin[:dmi] = { system: {
83
+ manufacturer: "Supermicro",
84
+ product: "X10SLH-N6-ST031",
85
+ version: "0123456789",
86
+ },
87
+ }
88
+ plugin.run
89
+ expect(plugin[:virtualization]).to eq({ "systems" => {} })
118
90
  end
119
91
  end
120
92
 
121
93
  it "should not set virtualization if no tests match" do
122
- @plugin.run
123
- expect(@plugin[:virtualization][:systems]).to eq({})
94
+ plugin.run
95
+ expect(plugin[:virtualization][:systems]).to eq({})
124
96
  end
125
97
  end
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "ssh_host_key plugin" do
22
22
 
@@ -81,7 +81,7 @@ describe Ohai::System, "ssh_host_key plugin" do
81
81
  HostKey /etc/ssh/ssh_host_dsa_key
82
82
  HostKey /etc/ssh/ssh_host_ecdsa_key
83
83
  HostKey /etc/ssh/ssh_host_ed25519_key
84
- EOS
84
+ EOS
85
85
  end
86
86
  it_behaves_like "loads keys"
87
87
  end
@@ -94,7 +94,7 @@ EOS
94
94
  #HostKey /etc/ssh/ssh_host_dsa_key
95
95
  #HostKey /etc/ssh/ssh_host_ecdsa_key
96
96
  #HostKey /etc/ssh/ssh_host_ed25519_key
97
- EOS
97
+ EOS
98
98
  end
99
99
  it_behaves_like "loads keys"
100
100
  end
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "sysconf plugin", :unix_only do
22
22
  let(:plugin) { get_plugin("sysconf") }
@@ -343,7 +343,7 @@ describe Ohai::System, "sysconf plugin", :unix_only do
343
343
  RAW_SOCKETS 200809
344
344
  _POSIX_IPV6 200809
345
345
  _POSIX_RAW_SOCKETS 200809
346
- GETCONF_OUT
346
+ GETCONF_OUT
347
347
  allow(plugin).to receive(:which).with("getconf").and_return("/usr/bin/getconf")
348
348
  allow(plugin).to receive(:shell_out).with("/usr/bin/getconf -a").and_return(mock_shell_out(0, getconf_out, ""))
349
349
  allow(plugin).to receive(:collect_os).and_return(:linux)
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require_relative "../../spec_helper.rb"
18
+ require "spec_helper"
19
19
 
20
20
  describe Ohai::System, "timezone plugin" do
21
21
  before(:each) do
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require_relative "../../spec_helper.rb"
18
+ require "spec_helper"
19
19
 
20
20
  vbox_output = <<~EOF
21
21
  Oracle VM VirtualBox Guest Additions Command Line Management Interface Version 5.0.2
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require_relative "../../spec_helper.rb"
18
+ require "spec_helper"
19
19
 
20
20
  describe Ohai::System, "plugin vmware" do
21
21
  let(:plugin) { get_plugin("vmware") }
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
 
21
21
  shared_examples "a cpu" do |cpu_no|
22
22
  describe "cpu #{cpu_no}" do
@@ -65,7 +65,6 @@ describe Ohai::System, "Windows cpu plugin" do
65
65
  @plugin = get_plugin("cpu")
66
66
  allow(@plugin).to receive(:collect_os).and_return(:windows)
67
67
 
68
- @double_wmi = double(WmiLite::Wmi)
69
68
  @double_wmi_instance = instance_double(WmiLite::Wmi)
70
69
 
71
70
  @processors = [{ "description" => "Intel64 Family 6 Model 70 Stepping 1",
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
  require "wmi-lite/wmi"
21
21
 
22
22
  describe Ohai::System, "Windows Filesystem Plugin", :windows_only do
@@ -41,7 +41,7 @@ describe Ohai::System, "Windows Filesystem Plugin", :windows_only do
41
41
  "size" => "10000000",
42
42
  "filesystem" => "FAT32",
43
43
  "freespace" => "100000",
44
- "name" => "D:"
44
+ "name" => "D:",
45
45
  # Lets not pass "volumename" for this drive
46
46
  }
47
47
  ]
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Matt Wrock (<matt@mattwrock.com>)
3
- # Copyright:: Copyright (c) 2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2016-2018 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +16,13 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require_relative "../../../spec_helper.rb"
19
+ require "spec_helper"
20
20
  require "openssl"
21
21
 
22
- describe Ohai::System, "plugin fips", :windows_only do
22
+ describe Ohai::System, "plugin fips" do
23
23
  let(:enabled) { 0 }
24
24
  let(:plugin) { get_plugin("windows/fips") }
25
- let(:fips_key) { 'System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy' }
26
- let(:win_reg_entry) { { "Enabled" => enabled } }
27
- let(:openssl_test_mode) { true }
25
+ let(:openssl_test_mode) { false }
28
26
 
29
27
  subject do
30
28
  plugin.run
@@ -33,86 +31,28 @@ describe Ohai::System, "plugin fips", :windows_only do
33
31
 
34
32
  before(:each) do
35
33
  allow(plugin).to receive(:collect_os).and_return(:windows)
36
- allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).with(fips_key, arch).and_yield(win_reg_entry)
37
34
  end
38
35
 
39
36
  around do |ex|
40
- begin
41
- $FIPS_TEST_MODE = openssl_test_mode
42
- ex.run
43
- ensure
44
- $FIPS_TEST_MODE = false
45
- end
46
- end
47
-
48
- shared_examples "fips_plugin" do
49
- context "fips enabled key is set to 1" do
50
- let(:enabled) { 1 }
51
-
52
- it "sets fips plugin" do
53
- expect(subject).to be(true)
54
- end
55
- end
56
-
57
- context "fips enabled key is set to 0" do
58
- let(:enabled) { 0 }
59
37
 
60
- it "does not set fips plugin" do
61
- expect(subject).to be(false)
62
- end
63
- end
64
-
65
- context "fips key does not exist" do
66
- before do
67
- allow(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open).and_raise(Win32::Registry::Error, 50)
68
- end
38
+ $FIPS_TEST_MODE = openssl_test_mode
39
+ ex.run
40
+ ensure
41
+ $FIPS_TEST_MODE = false
69
42
 
70
- it "does not set fips plugin" do
71
- expect(subject).to be(false)
72
- end
73
- end
74
43
  end
75
44
 
76
- context "on 32 bit ruby" do
77
- let(:arch) { Win32::Registry::KEY_READ | 0x100 }
78
-
79
- before { stub_const("::RbConfig::CONFIG", { "target_cpu" => "i386" } ) }
80
-
81
- it_behaves_like "fips_plugin"
82
- end
83
-
84
- context "on 64 bit ruby" do
85
- let(:arch) { Win32::Registry::KEY_READ | 0x200 }
86
-
87
- before { stub_const("::RbConfig::CONFIG", { "target_cpu" => "x86_64" } ) }
88
-
89
- it_behaves_like "fips_plugin"
90
- end
91
-
92
- context "on unknown ruby" do
93
- let(:arch) { Win32::Registry::KEY_READ }
94
-
95
- before { stub_const("::RbConfig::CONFIG", { "target_cpu" => nil } ) }
96
-
97
- it_behaves_like "fips_plugin"
98
- end
99
-
100
- context "with Ruby 2.5 or newer", if: defined?(OpenSSL.fips_mode) do
101
- let(:arch) { Win32::Registry::KEY_READ }
102
- let(:openssl_test_mode) { false }
103
-
104
- context "with OpenSSL.fips_mode == false" do
105
- before { allow(OpenSSL).to receive(:fips_mode).and_return(false) }
106
- it "does not set fips plugin" do
107
- expect(subject).to be(false)
108
- end
45
+ context "with OpenSSL.fips_mode == false" do
46
+ before { allow(OpenSSL).to receive(:fips_mode).and_return(false) }
47
+ it "does not set fips plugin" do
48
+ expect(subject).to be(false)
109
49
  end
50
+ end
110
51
 
111
- context "with OpenSSL.fips_mode == true" do
112
- before { allow(OpenSSL).to receive(:fips_mode).and_return(true) }
113
- it "sets fips plugin" do
114
- expect(subject).to be(true)
115
- end
52
+ context "with OpenSSL.fips_mode == true" do
53
+ before { allow(OpenSSL).to receive(:fips_mode).and_return(true) }
54
+ it "sets fips plugin" do
55
+ expect(subject).to be(true)
116
56
  end
117
57
  end
118
58
  end