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,71 +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, "Darwin plugin platform" do
22
- before do
23
- @plugin = get_plugin("darwin/platform")
24
- allow(@plugin).to receive(:collect_os).and_return(:darwin)
25
- @stdout = "ProductName: Mac OS X\nProductVersion: 10.5.5\nBuildVersion: 9F33"
26
- allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
27
- end
28
-
29
- it "runs sw_vers" do
30
- expect(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
31
- @plugin.run
32
- end
33
-
34
- it "sets platform to ProductName, downcased with _ for \\s" do
35
- @plugin.run
36
- expect(@plugin[:platform]).to eq("mac_os_x")
37
- end
38
-
39
- it "sets platform_version to ProductVersion" do
40
- @plugin.run
41
- expect(@plugin[:platform_version]).to eq("10.5.5")
42
- end
43
-
44
- it "sets platform_build to BuildVersion" do
45
- @plugin.run
46
- expect(@plugin[:platform_build]).to eq("9F33")
47
- end
48
-
49
- it "sets platform_family to mac_os_x" do
50
- @plugin.run
51
- expect(@plugin[:platform_family]).to eq("mac_os_x")
52
- end
53
-
54
- describe "on os x server" do
55
- before do
56
- @plugin[:os] = "darwin"
57
- @stdout = "ProductName: Mac OS X Server\nProductVersion: 10.6.8\nBuildVersion: 10K549"
58
- allow(@plugin).to receive(:shell_out).with("/usr/bin/sw_vers").and_return(mock_shell_out(0, @stdout, ""))
59
- end
60
-
61
- it "sets platform to mac_os_x_server" do
62
- @plugin.run
63
- expect(@plugin[:platform]).to eq("mac_os_x_server")
64
- end
65
-
66
- it "sets platform_family to mac_os_x" do
67
- @plugin.run
68
- expect(@plugin[:platform_family]).to eq("mac_os_x")
69
- end
70
- end
71
- end
@@ -1,156 +0,0 @@
1
- #
2
- # Author:: Pavel Yudin (<pyudin@parallels.com>)
3
- # Author:: Tim Smith (<tsmith@chef.io>)
4
- # Copyright:: Copyright (c) 2015 Pavel Yudin
5
- # Copyright:: Copyright (c) 2016 Chef Software, Inc.
6
- # License:: Apache License, Version 2.0
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
- #
20
-
21
- require "spec_helper"
22
-
23
- describe Ohai::System, "Darwin virtualization platform" do
24
- let(:plugin) { get_plugin("darwin/virtualization") }
25
-
26
- before do
27
- allow(plugin).to receive(:collect_os).and_return(:darwin)
28
- allow(plugin).to receive(:prlctl_exists?).and_return(false)
29
- allow(plugin).to receive(:ioreg_exists?).and_return(false)
30
- allow(plugin).to receive(:vboxmanage_exists?).and_return(false)
31
- allow(plugin).to receive(:fusion_exists?).and_return(false)
32
- allow(plugin).to receive(:docker_exists?).and_return(false)
33
- plugin[:hardware] = Mash.new
34
- plugin[:hardware][:boot_rom_version] = "not_a_vm"
35
- end
36
-
37
- describe "when detecting OS X virtualization" do
38
- it "does not set virtualization keys if no binaries are found" do
39
- plugin.run
40
- expect(plugin[:virtualization]).to eq({ "systems" => {} })
41
- end
42
-
43
- it "sets docker host if docker exists" do
44
- allow(plugin).to receive(:docker_exists?).and_return(true)
45
- plugin.run
46
- expect(plugin[:virtualization][:system]).to eq("docker")
47
- expect(plugin[:virtualization][:role]).to eq("host")
48
- expect(plugin[:virtualization][:systems][:docker]).to eq("host")
49
- end
50
-
51
- it "sets vmware host if /Applications/VMware\ Fusion.app exists" do
52
- allow(plugin).to receive(:fusion_exists?).and_return(true)
53
- plugin.run
54
- expect(plugin[:virtualization][:system]).to eq("vmware")
55
- expect(plugin[:virtualization][:role]).to eq("host")
56
- expect(plugin[:virtualization][:systems][:vmware]).to eq("host")
57
- end
58
-
59
- it "sets vmware guest if hardware attributes mention vmware" do
60
- plugin[:hardware][:boot_rom_version] = "VMW71.00V.6997262.B64.1710270607"
61
- plugin.run
62
- expect(plugin[:virtualization][:system]).to eq("vmware")
63
- expect(plugin[:virtualization][:role]).to eq("guest")
64
- expect(plugin[:virtualization][:systems][:vmware]).to eq("guest")
65
- end
66
-
67
- it "sets vbox host if /usr/local/bin/VBoxManage exists" do
68
- allow(plugin).to receive(:vboxmanage_exists?).and_return("/usr/local/bin/VBoxManage")
69
- plugin.run
70
- expect(plugin[:virtualization][:system]).to eq("vbox")
71
- expect(plugin[:virtualization][:role]).to eq("host")
72
- expect(plugin[:virtualization][:systems][:vbox]).to eq("host")
73
- end
74
-
75
- it "sets vbox guest if hardware attributes mention virtualbox" do
76
- plugin[:hardware][:boot_rom_version] = "VirtualBox"
77
- plugin.run
78
- expect(plugin[:virtualization][:system]).to eq("vbox")
79
- expect(plugin[:virtualization][:role]).to eq("guest")
80
- expect(plugin[:virtualization][:systems][:vbox]).to eq("guest")
81
- end
82
-
83
- it "sets parallels host if /usr/bin/prlctl exists" do
84
- allow(plugin).to receive(:prlctl_exists?).and_return("/usr/bin/prlctl")
85
- plugin.run
86
- expect(plugin[:virtualization][:system]).to eq("parallels")
87
- expect(plugin[:virtualization][:role]).to eq("host")
88
- expect(plugin[:virtualization][:systems][:parallels]).to eq("host")
89
- end
90
-
91
- it "sets parallels guest if /usr/sbin/ioreg exists and its output contains pci1ab8,4000" do
92
- allow(plugin).to receive(:ioreg_exists?).and_return(true)
93
- ioreg = <<-IOREG
94
- | | +-o pci1ab8,4000@3 <class IOPCIDevice, id 0x1000001d1, registered, matched, active, busy 0 (40 ms), retain 9>
95
- | | | | {
96
- | | | | "compatible" = <"pci1ab8,400","pci1ab8,4000","pciclass,ff0000">
97
- | | | | "subsystem-vendor-id" = <b81a0000>
98
- | | | | "IOName" = "pci1ab8,4000"
99
- | | | | "reg" = <00180000000000000000000000000000000000001018000100000000000000000000000020000000>
100
- | | | | "device-id" = <00400000>
101
- | | | | "assigned-addresses" = <101800810000000040d200000000000020000000>
102
- | | | | "IOPowerManagement" = {"MaxPowerState"=3,"ChildProxyPowerState"=2,"CurrentPowerState"=2}
103
- | | | | "IOPCIResourced" = Yes
104
- | | | | "IODeviceMemory" = ("IOSubMemoryDescriptor is not serializable")
105
- | | | | "revision-id" = <00000000>
106
- | | | | "IOInterruptControllers" = ("IOPCIMessagedInterruptController")
107
- | | | | "vendor-id" = <b81a0000>
108
- | | | | "pcidebug" = "0:3:0"
109
- | | | | "class-code" = <0000ff00>
110
- | | | | "IOInterruptSpecifiers" = (<0000000000000100>)
111
- | | | | "IOPCIMSIMode" = Yes
112
- | | | | "subsystem-id" = <00040000>
113
- | | | | "name" = <"pci1ab8,4000">
114
- | | | | }
115
- IOREG
116
- shellout = double("shellout")
117
- allow(shellout).to receive(:stdout).and_return(ioreg)
118
- allow(plugin).to receive(:shell_out).with("ioreg -l").and_return(shellout)
119
- plugin.run
120
- expect(plugin[:virtualization][:system]).to eq("parallels")
121
- expect(plugin[:virtualization][:role]).to eq("guest")
122
- expect(plugin[:virtualization][:systems][:parallels]).to eq("guest")
123
- end
124
-
125
- it "does not set parallels guest if /usr/sbin/ioreg exists and its output not contain pci1ab8,4000" do
126
- allow(plugin).to receive(:ioreg_exists?).and_return(true)
127
- ioreg = <<-IOREG
128
- | | +-o pci8086,2445@1F,4 <class IOPCIDevice, id 0x1000001d4, registered, matched, active, busy 0 (974 ms), retain 11>
129
- | | | {
130
- | | | "compatible" = <"pci1ab8,400","pci8086,2445","pciclass,040100">
131
- | | | "subsystem-vendor-id" = <b81a0000>
132
- | | | "IOName" = "pci8086,2445"
133
- | | | "reg" = <00fc00000000000000000000000000000000000010fc00010000000000000000000000000001000014fc000100000000000000000000000000010000>
134
- | | | "device-id" = <45240000>
135
- | | | "assigned-addresses" = <10fc00810000000000d10000000000000001000014fc00810000000000d000000000000000010000>
136
- | | | "IOPowerManagement" = {"ChildrenPowerState"=2,"CurrentPowerState"=2,"ChildProxyPowerState"=2,"MaxPowerState"=3}
137
- | | | "IOPCIResourced" = Yes
138
- | | | "IODeviceMemory" = ("IOSubMemoryDescriptor is not serializable","IOSubMemoryDescriptor is not serializable")
139
- | | | "revision-id" = <02000000>
140
- | | | "IOInterruptControllers" = ("io-apic-0")
141
- | | | "vendor-id" = <86800000>
142
- | | | "pcidebug" = "0:31:4"
143
- | | | "class-code" = <00010400>
144
- | | | "IOInterruptSpecifiers" = (<1100000007000000>)
145
- | | | "subsystem-id" = <00040000>
146
- | | | "name" = <"pci8086,2445">
147
- | | | }
148
- IOREG
149
- shellout = double("shellout")
150
- allow(shellout).to receive(:stdout).and_return(ioreg)
151
- allow(plugin).to receive(:shell_out).with("ioreg -l").and_return(shellout)
152
- plugin.run
153
- expect(plugin[:virtualization]).to eq({ "systems" => {} })
154
- end
155
- end
156
- end
@@ -1,106 +0,0 @@
1
- #
2
- # Author:: Dylan Page (<dpage@digitalocean.com>)
3
- # Author:: Stafford Brunk (<stafford.brunk@gmail.com>)
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, "plugin digital_ocean" do
22
- let(:plugin) { get_plugin("digital_ocean") }
23
- let(:hint) do
24
- {
25
- "droplet_id" => 12345678,
26
- "name" => "example.com",
27
- "image_id" => 3240036,
28
- "size_id" => 66,
29
- "region_id" => 4,
30
- "ip_addresses" => {
31
- "public" => "1.2.3.4",
32
- "private" => "5.6.7.8",
33
- },
34
- }
35
- end
36
-
37
- before do
38
- allow(plugin).to receive(:hint?).with("digital_ocean").and_return(false)
39
- end
40
-
41
- shared_examples_for "!digital_ocean" do
42
- it "does not attempt to fetch the digital_ocean metadata" do
43
- expect(plugin).not_to receive(:http_client)
44
- expect(plugin[:digital_ocean]).to be_nil
45
- plugin.run
46
- end
47
- end
48
-
49
- shared_examples_for "digital_ocean" do
50
- before do
51
- @http_client = double("Net::HTTP client")
52
- allow(plugin).to receive(:http_client).and_return(@http_client)
53
- allow(IO).to receive(:select).and_return([[], [1], []])
54
- t = double("connection")
55
- allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
56
- allow(Socket).to receive(:new).and_return(t)
57
- allow(Socket).to receive(:pack_sockaddr_in).and_return(nil)
58
- end
59
-
60
- let(:body) do
61
- '{"droplet_id":2756924,"hostname":"sample-droplet","vendor_data":"#cloud-config\ndisable_root: false\nmanage_etc_hosts: true\n\n# The modules that run in the \'init\' stage\ncloud_init_modules:\n - migrator\n - ubuntu-init-switch\n - seed_random\n - bootcmd\n - write-files\n - growpart\n - resizefs\n - set_hostname\n - update_hostname\n - [ update_etc_hosts, once-per-instance ]\n - ca-certs\n - rsyslog\n - users-groups\n - ssh\n\n# The modules that run in the \'config\' stage\ncloud_config_modules:\n - disk_setup\n - mounts\n - ssh-import-id\n - locale\n - set-passwords\n - grub-dpkg\n - apt-pipelining\n - apt-configure\n - package-update-upgrade-install\n - landscape\n - timezone\n - puppet\n - chef\n - salt-minion\n - mcollective\n - disable-ec2-metadata\n - runcmd\n - byobu\n\n# The modules that run in the \'final\' stage\ncloud_final_modules:\n - rightscale_userdata\n - scripts-vendor\n - scripts-per-once\n - scripts-per-boot\n - scripts-per-instance\n - scripts-user\n - ssh-authkey-fingerprints\n - keys-to-console\n - phone-home\n - final-message\n - power-state-change\n","public_keys":["ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDAkMD3PYKHaH0KbDiXrRE6KCBo/OKcFqhM+fmnnb0+LUh4RalJWX4edeJmnT5bxLeqmLV/Yggjlpfq73R+Dy7JB4pbBLuM959mSM9ohBCSnByAGoT2iUPev4aZFZZ/ahUzTCylNxXrhZV/bopD399CvYREt7Q+FlauBv0O8MMuMGR8aC69Z3jNL+r+fGWNq98JVHGFO/UgoNL15wGCaidMhzfRqkt1u+m1nY77SFM5qWJz2R0CEC4fMlOiCg8mWBklnryV4yDEPgiXp2I8Rli1Eu2GHwuY1YX9elMeQS7n3Pzq7l6aIQmSgvcEWx6TgMD2V7nQUWpfcud/8dpp/t7z9UyfzLmNwnULHNmUeEp52sejcH5lYzISnkkWa1LzlKSeIrhF3y45m9AyxIfjEqyh/mlKQtUaW3NVXXLPwrNitxHtMIZPU5b16BODn0wb8bqPxpDNpUYrQd/BS7mWDxNpICP2ObLPhd9LW9KIYRNTzryE+uKwxm9NkMlhRku2fu415fH0G0+7aURsHviNN9SO4zct3Pj6QE5rnbVHqxt3biplUTOScdWxSk2Nv3V2dGdt/lBfu6iRPAV9IAS31s7Po3qK1t2jpEPCJwstaCBOM80kmoi3zAgotiAW50X8CelaWsHNrq5jBBgeHUZWgn/c8BkcI61pUE9l34Q6gsiEMQ== tsmith84@gmail.com"],"region":"nyc3","interfaces":{"public":[{"ipv4":{"ip_address":"159.203.92.161","netmask":"255.255.240.0","gateway":"159.203.80.1"},"ipv6":{"ip_address":"2604:A880:0800:00A1:0000:0000:0201:0001","cidr":64,"gateway":"2604:A880:0800:00A1:0000:0000:0000:0001"},"anchor_ipv4":{"ip_address":"10.17.0.5","netmask":"255.255.0.0","gateway":"10.17.0.1"},"mac":"04:01:e5:14:03:01","type":"public"}]},"floating_ip":{"ipv4":{"active":false}},"dns":{"nameservers":["2001:4860:4860::8844","2001:4860:4860::8888","8.8.8.8"]}}'
62
- end
63
-
64
- it "fetches and properly parse json metadata" do
65
- expect(@http_client).to receive(:get)
66
- .with("/metadata/v1.json")
67
- .and_return(double("Net::HTTP Response", body: body, code: "200"))
68
- plugin.run
69
-
70
- expect(plugin[:digital_ocean]).not_to be_nil
71
- expect(plugin[:digital_ocean]["droplet_id"]).to eq(2756924)
72
- expect(plugin[:digital_ocean]["hostname"]).to eq("sample-droplet")
73
- end
74
-
75
- it "completes the run despite unavailable metadata" do
76
- expect(@http_client).to receive(:get)
77
- .with("/metadata/v1.json")
78
- .and_return(double("Net::HTTP Response", body: "", code: "404"))
79
- plugin.run
80
-
81
- expect(plugin[:digitalocean]).to be_nil
82
- end
83
- end
84
-
85
- describe "without hint or dmi data" do
86
- it_behaves_like "!digital_ocean"
87
- end
88
-
89
- describe "with digital_ocean hint file" do
90
- before do
91
- allow(plugin).to receive(:hint?).with("digital_ocean").and_return(true)
92
- end
93
-
94
- it_behaves_like "digital_ocean"
95
-
96
- end
97
-
98
- describe "with digital_ocean DMI data" do
99
- before do
100
- plugin[:dmi] = { bios: { all_records: [ { Vendor: "DigitalOcean" } ] } }
101
- end
102
-
103
- it_behaves_like "digital_ocean"
104
-
105
- end
106
- end
@@ -1,156 +0,0 @@
1
- #
2
- # Author:: Bryan McLellan (<btm@loftninjas.org>)
3
- # Copyright:: Copyright (c) 2009 Bryan McLellan
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
- # NOTE: These data lines must be prefixed with one or two tabs, not spaces.
22
- DMI_OUT = <<~EOS.freeze
23
- # dmidecode 2.9
24
- SMBIOS 2.4 present.
25
- 98 structures occupying 3699 bytes.
26
- Table at 0x000E0010.
27
-
28
- Handle 0x0000, DMI type 0, 24 bytes
29
- BIOS Information
30
- Vendor: Phoenix Technologies LTD
31
- Version: 6.00
32
- Release Date: 12/31/2009
33
- Address: 0xEA2E0
34
- Runtime Size: 89376 bytes
35
- ROM Size: 64 kB
36
- Characteristics:
37
- ISA is supported
38
- PCI is supported
39
- PC Card (PCMCIA) is supported
40
- PNP is supported
41
- APM is supported
42
- BIOS is upgradeable
43
- BIOS shadowing is allowed
44
- ESCD support is available
45
- USB legacy is supported
46
- Smart battery is supported
47
- BIOS boot specification is supported
48
- Targeted content distribution is supported
49
- BIOS Revision: 4.6
50
- Firmware Revision: 0.0
51
-
52
- Handle 0x0001, DMI type 1, 27 bytes
53
- System Information
54
- Manufacturer: VMware, Inc.
55
- Product Name: VMware Virtual Platform
56
- Version: None
57
- Serial Number: VMware-56 4d 71 d1 65 70 83 a8-df c8 14 12 19 41 71 45
58
- UUID: 564D71D1-6570-83A8-DFC8-141219417145
59
- Wake-up Type: Power Switch
60
- SKU Number: Not Specified
61
- Family: Not Specified
62
-
63
- Handle 0x0002, DMI type 2, 15 bytes
64
- Base Board Information
65
- Manufacturer: Intel Corporation
66
- Product Name: 440BX Desktop Reference Platform
67
- Version: None
68
- Serial Number: None
69
- Asset Tag: Not Specified
70
- Features: None
71
- Location In Chassis: Not Specified
72
- Chassis Handle: 0x0000
73
- Type: Unknown
74
- Contained Object Handles: 0
75
-
76
- Handle 0x1000, DMI type 16, 15 bytes
77
- Physical Memory Array
78
- Location: Other
79
- Use: System Memory
80
- Error Correction Type: Multi-bit ECC
81
- Maximum Capacity: 2 GB
82
- Error Information Handle: Not Provided
83
- Number Of Devices: 1
84
-
85
- Handle 0x0003, DMI type 3, 21 bytes
86
- Chassis Information
87
- Manufacturer: No Enclosure
88
- Type: Other
89
- Lock: Not Present
90
- Version: N/A
91
- Serial Number: None
92
- Asset Tag: No Asset Tag
93
- Boot-up State: Safe
94
- Power Supply State: Safe
95
- Thermal State: Safe
96
- Security Status: None
97
- OEM Information: 0x00001234
98
- Height: Unspecified
99
- Number Of Power Cords: Unspecified
100
- Contained Elements: 0
101
- EOS
102
-
103
- describe Ohai::System, "plugin dmi" do
104
- let(:plugin) { get_plugin("dmi") }
105
- let(:stdout) { DMI_OUT }
106
-
107
- before do
108
- allow(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, ""))
109
- end
110
-
111
- it "runs dmidecode" do
112
- expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, ""))
113
- plugin.run
114
- end
115
-
116
- # Test some simple sample data
117
- {
118
- bios: {
119
- vendor: "Phoenix Technologies LTD",
120
- release_date: "12/31/2009",
121
- },
122
- system: {
123
- manufacturer: "VMware, Inc.",
124
- product_name: "VMware Virtual Platform",
125
- },
126
- chassis: {
127
- lock: "Not Present",
128
- asset_tag: "No Asset Tag",
129
- },
130
- }.each do |id, data|
131
- data.each do |attribute, value|
132
- it "attribute [:dmi][:#{id}][:#{attribute}] is set" do
133
- plugin.run
134
- expect(plugin[:dmi][id][attribute]).to eql(value)
135
- end
136
- it "attribute [:dmi][:#{id}][:#{attribute}] set for windows output" do
137
- stdout = convert_windows_output(DMI_OUT)
138
- expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, ""))
139
- plugin.run
140
- expect(plugin[:dmi][id][attribute]).to eql(value)
141
- end
142
- end
143
- end
144
-
145
- it "allows capturing additional DMI data" do
146
- Ohai.config[:additional_dmi_ids] = [ 16 ]
147
- plugin.run
148
- expect(plugin[:dmi]).to have_key(:physical_memory_array)
149
- end
150
-
151
- it "correctly ignores data in excluded DMI IDs" do
152
- expect(plugin).to receive(:shell_out).with("dmidecode").and_return(mock_shell_out(0, stdout, ""))
153
- plugin.run
154
- expect(plugin[:dmi]).not_to have_key(:physical_memory_array)
155
- end
156
- end