ohai 8.10.0 → 8.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (256) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -2
  3. data/Rakefile +13 -4
  4. data/bin/ohai +3 -4
  5. data/lib/ohai.rb +4 -4
  6. data/lib/ohai/application.rb +7 -6
  7. data/lib/ohai/common/dmi.rb +56 -56
  8. data/lib/ohai/config.rb +12 -8
  9. data/lib/ohai/dsl.rb +3 -3
  10. data/lib/ohai/dsl/plugin.rb +5 -5
  11. data/lib/ohai/dsl/plugin/versionvi.rb +0 -1
  12. data/lib/ohai/dsl/plugin/versionvii.rb +1 -0
  13. data/lib/ohai/hints.rb +1 -1
  14. data/lib/ohai/loader.rb +7 -7
  15. data/lib/ohai/log.rb +1 -1
  16. data/lib/ohai/mash.rb +3 -2
  17. data/lib/ohai/mixin/command.rb +25 -23
  18. data/lib/ohai/mixin/dmi_decode.rb +10 -10
  19. data/lib/ohai/mixin/ec2_metadata.rb +40 -39
  20. data/lib/ohai/mixin/gce_metadata.rb +9 -9
  21. data/lib/ohai/mixin/network_constants.rb +1 -1
  22. data/lib/ohai/mixin/os.rb +3 -3
  23. data/lib/ohai/mixin/seconds_to_human.rb +0 -2
  24. data/lib/ohai/mixin/softlayer_metadata.rb +10 -10
  25. data/lib/ohai/mixin/string.rb +2 -2
  26. data/lib/ohai/plugin_config.rb +1 -1
  27. data/lib/ohai/plugins/aix/cpu.rb +2 -2
  28. data/lib/ohai/plugins/aix/filesystem.rb +2 -2
  29. data/lib/ohai/plugins/aix/memory.rb +2 -2
  30. data/lib/ohai/plugins/aix/network.rb +9 -10
  31. data/lib/ohai/plugins/aix/os.rb +2 -2
  32. data/lib/ohai/plugins/aix/uptime.rb +3 -3
  33. data/lib/ohai/plugins/aix/virtualization.rb +23 -23
  34. data/lib/ohai/plugins/azure.rb +32 -5
  35. data/lib/ohai/plugins/bsd/virtualization.rb +22 -22
  36. data/lib/ohai/plugins/c.rb +3 -3
  37. data/lib/ohai/plugins/chef.rb +1 -1
  38. data/lib/ohai/plugins/cloud.rb +59 -60
  39. data/lib/ohai/plugins/cloud_v2.rb +37 -39
  40. data/lib/ohai/plugins/darwin/cpu.rb +1 -1
  41. data/lib/ohai/plugins/darwin/filesystem2.rb +5 -5
  42. data/lib/ohai/plugins/darwin/memory.rb +5 -6
  43. data/lib/ohai/plugins/darwin/network.rb +7 -7
  44. data/lib/ohai/plugins/darwin/system_profiler.rb +32 -33
  45. data/lib/ohai/plugins/darwin/virtualization.rb +9 -9
  46. data/lib/ohai/plugins/digital_ocean.rb +16 -16
  47. data/lib/ohai/plugins/dmi.rb +6 -6
  48. data/lib/ohai/plugins/dragonflybsd/cpu.rb +2 -2
  49. data/lib/ohai/plugins/dragonflybsd/memory.rb +0 -1
  50. data/lib/ohai/plugins/dragonflybsd/network.rb +4 -4
  51. data/lib/ohai/plugins/dragonflybsd/os.rb +1 -1
  52. data/lib/ohai/plugins/ec2.rb +39 -15
  53. data/lib/ohai/plugins/elixir.rb +1 -1
  54. data/lib/ohai/plugins/erlang.rb +3 -3
  55. data/lib/ohai/plugins/eucalyptus.rb +16 -12
  56. data/lib/ohai/plugins/freebsd/cpu.rb +2 -2
  57. data/lib/ohai/plugins/freebsd/memory.rb +0 -1
  58. data/lib/ohai/plugins/freebsd/network.rb +4 -4
  59. data/lib/ohai/plugins/freebsd/os.rb +1 -1
  60. data/lib/ohai/plugins/gce.rb +6 -6
  61. data/lib/ohai/plugins/hostname.rb +7 -7
  62. data/lib/ohai/plugins/init_package.rb +1 -1
  63. data/lib/ohai/plugins/ip_scopes.rb +9 -9
  64. data/lib/ohai/plugins/java.rb +1 -1
  65. data/lib/ohai/plugins/joyent.rb +7 -7
  66. data/lib/ohai/plugins/kernel.rb +8 -8
  67. data/lib/ohai/plugins/linode.rb +7 -4
  68. data/lib/ohai/plugins/linux/cpu.rb +5 -5
  69. data/lib/ohai/plugins/linux/filesystem.rb +16 -16
  70. data/lib/ohai/plugins/linux/filesystem2.rb +15 -15
  71. data/lib/ohai/plugins/linux/mdadm.rb +3 -3
  72. data/lib/ohai/plugins/linux/network.rb +85 -51
  73. data/lib/ohai/plugins/linux/platform.rb +24 -24
  74. data/lib/ohai/plugins/linux/virtualization.rb +8 -8
  75. data/lib/ohai/plugins/mono.rb +1 -1
  76. data/lib/ohai/plugins/netbsd/cpu.rb +1 -1
  77. data/lib/ohai/plugins/netbsd/network.rb +2 -2
  78. data/lib/ohai/plugins/network.rb +11 -11
  79. data/lib/ohai/plugins/network_listeners.rb +30 -26
  80. data/lib/ohai/plugins/ohai.rb +3 -3
  81. data/lib/ohai/plugins/openbsd/cpu.rb +4 -4
  82. data/lib/ohai/plugins/openbsd/memory.rb +4 -4
  83. data/lib/ohai/plugins/openbsd/network.rb +3 -3
  84. data/lib/ohai/plugins/openstack.rb +12 -12
  85. data/lib/ohai/plugins/os.rb +2 -2
  86. data/lib/ohai/plugins/packages.rb +22 -22
  87. data/lib/ohai/plugins/passwd.rb +4 -4
  88. data/lib/ohai/plugins/powershell.rb +9 -9
  89. data/lib/ohai/plugins/ps.rb +2 -2
  90. data/lib/ohai/plugins/python.rb +1 -1
  91. data/lib/ohai/plugins/rackspace.rb +13 -13
  92. data/lib/ohai/plugins/root_group.rb +4 -4
  93. data/lib/ohai/plugins/ruby.rb +6 -6
  94. data/lib/ohai/plugins/rust.rb +1 -1
  95. data/lib/ohai/plugins/sigar/cpu.rb +1 -1
  96. data/lib/ohai/plugins/sigar/filesystem.rb +1 -1
  97. data/lib/ohai/plugins/sigar/network.rb +13 -13
  98. data/lib/ohai/plugins/sigar/network_route.rb +34 -29
  99. data/lib/ohai/plugins/softlayer.rb +8 -7
  100. data/lib/ohai/plugins/solaris2/cpu.rb +19 -19
  101. data/lib/ohai/plugins/solaris2/dmi.rb +63 -63
  102. data/lib/ohai/plugins/solaris2/filesystem.rb +13 -13
  103. data/lib/ohai/plugins/solaris2/memory.rb +2 -2
  104. data/lib/ohai/plugins/solaris2/network.rb +5 -5
  105. data/lib/ohai/plugins/solaris2/virtualization.rb +18 -18
  106. data/lib/ohai/plugins/solaris2/zpools.rb +1 -1
  107. data/lib/ohai/plugins/ssh_host_key.rb +2 -2
  108. data/lib/ohai/plugins/uptime.rb +4 -5
  109. data/lib/ohai/plugins/virtualbox.rb +2 -2
  110. data/lib/ohai/plugins/virtualization.rb +17 -17
  111. data/lib/ohai/plugins/vmware.rb +2 -2
  112. data/lib/ohai/plugins/windows/cpu.rb +14 -14
  113. data/lib/ohai/plugins/windows/drivers.rb +8 -8
  114. data/lib/ohai/plugins/windows/filesystem.rb +4 -4
  115. data/lib/ohai/plugins/windows/memory.rb +1 -1
  116. data/lib/ohai/plugins/windows/network.rb +10 -10
  117. data/lib/ohai/plugins/windows/platform.rb +1 -2
  118. data/lib/ohai/plugins/windows/virtualization.rb +17 -17
  119. data/lib/ohai/provides_map.rb +7 -7
  120. data/lib/ohai/runner.rb +3 -3
  121. data/lib/ohai/system.rb +21 -20
  122. data/lib/ohai/util/file_helper.rb +1 -2
  123. data/lib/ohai/util/ip_helper.rb +4 -4
  124. data/lib/ohai/util/win32.rb +5 -5
  125. data/lib/ohai/util/win32/group_helper.rb +4 -5
  126. data/lib/ohai/version.rb +1 -1
  127. data/ohai.gemspec +7 -5
  128. data/spec/functional/application_spec.rb +23 -23
  129. data/spec/functional/loader_spec.rb +1 -1
  130. data/spec/functional/plugins/powershell_spec.rb +13 -13
  131. data/spec/functional/plugins/root_group_spec.rb +5 -5
  132. data/spec/ohai_spec.rb +1 -1
  133. data/spec/spec_helper.rb +9 -9
  134. data/spec/support/integration_helper.rb +7 -7
  135. data/spec/support/platform_helpers.rb +1 -1
  136. data/spec/unit/application_spec.rb +17 -17
  137. data/spec/unit/config_spec.rb +2 -2
  138. data/spec/unit/dsl/plugin_spec.rb +28 -28
  139. data/spec/unit/hints_spec.rb +3 -3
  140. data/spec/unit/loader_spec.rb +9 -9
  141. data/spec/unit/mixin/command_spec.rb +5 -5
  142. data/spec/unit/mixin/ec2_metadata_spec.rb +6 -6
  143. data/spec/unit/mixin/softlayer_metadata_spec.rb +19 -23
  144. data/spec/unit/plugin_config_spec.rb +5 -5
  145. data/spec/unit/plugins/abort_spec.rb +3 -3
  146. data/spec/unit/plugins/aix/cpu_spec.rb +1 -1
  147. data/spec/unit/plugins/aix/filesystem_spec.rb +25 -25
  148. data/spec/unit/plugins/aix/hostname_spec.rb +1 -2
  149. data/spec/unit/plugins/aix/kernel_spec.rb +3 -3
  150. data/spec/unit/plugins/aix/memory_spec.rb +8 -8
  151. data/spec/unit/plugins/aix/network_spec.rb +38 -38
  152. data/spec/unit/plugins/aix/os_spec.rb +1 -2
  153. data/spec/unit/plugins/aix/platform_spec.rb +1 -1
  154. data/spec/unit/plugins/aix/uptime_spec.rb +1 -1
  155. data/spec/unit/plugins/aix/virtualization_spec.rb +11 -11
  156. data/spec/unit/plugins/azure_spec.rb +118 -20
  157. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  158. data/spec/unit/plugins/bsd/virtualization_spec.rb +4 -4
  159. data/spec/unit/plugins/c_spec.rb +12 -12
  160. data/spec/unit/plugins/chef_spec.rb +2 -2
  161. data/spec/unit/plugins/cloud_spec.rb +37 -37
  162. data/spec/unit/plugins/cloud_v2_spec.rb +64 -65
  163. data/spec/unit/plugins/darwin/cpu_spec.rb +1 -2
  164. data/spec/unit/plugins/darwin/filesystem2_spec.rb +7 -7
  165. data/spec/unit/plugins/darwin/filesystem_spec.rb +5 -5
  166. data/spec/unit/plugins/darwin/hostname_spec.rb +1 -4
  167. data/spec/unit/plugins/darwin/kernel_spec.rb +6 -10
  168. data/spec/unit/plugins/darwin/memory_spec.rb +5 -5
  169. data/spec/unit/plugins/darwin/network_spec.rb +352 -353
  170. data/spec/unit/plugins/darwin/platform_spec.rb +1 -2
  171. data/spec/unit/plugins/darwin/system_profiler_spec.rb +3 -3
  172. data/spec/unit/plugins/darwin/virtualization_spec.rb +6 -6
  173. data/spec/unit/plugins/digital_ocean_spec.rb +38 -37
  174. data/spec/unit/plugins/dmi_spec.rb +3 -3
  175. data/spec/unit/plugins/ec2_spec.rb +97 -88
  176. data/spec/unit/plugins/elixir_spec.rb +1 -2
  177. data/spec/unit/plugins/erlang_spec.rb +2 -2
  178. data/spec/unit/plugins/eucalyptus_spec.rb +19 -19
  179. data/spec/unit/plugins/fail_spec.rb +2 -2
  180. data/spec/unit/plugins/freebsd/cpu_spec.rb +14 -14
  181. data/spec/unit/plugins/freebsd/hostname_spec.rb +1 -2
  182. data/spec/unit/plugins/freebsd/kernel_spec.rb +2 -3
  183. data/spec/unit/plugins/freebsd/os_spec.rb +4 -5
  184. data/spec/unit/plugins/freebsd/platform_spec.rb +1 -2
  185. data/spec/unit/plugins/gce_spec.rb +9 -9
  186. data/spec/unit/plugins/go_spec.rb +1 -1
  187. data/spec/unit/plugins/groovy_spec.rb +1 -2
  188. data/spec/unit/plugins/hostname_spec.rb +1 -2
  189. data/spec/unit/plugins/init_package_spec.rb +1 -1
  190. data/spec/unit/plugins/ip_scopes_spec.rb +38 -38
  191. data/spec/unit/plugins/java_spec.rb +52 -1
  192. data/spec/unit/plugins/joyent_spec.rb +9 -11
  193. data/spec/unit/plugins/kernel_spec.rb +11 -12
  194. data/spec/unit/plugins/linode_spec.rb +29 -29
  195. data/spec/unit/plugins/linux/block_device_spec.rb +21 -21
  196. data/spec/unit/plugins/linux/cpu_spec.rb +3 -3
  197. data/spec/unit/plugins/linux/filesystem2_spec.rb +7 -7
  198. data/spec/unit/plugins/linux/filesystem_spec.rb +85 -86
  199. data/spec/unit/plugins/linux/hostname_spec.rb +1 -3
  200. data/spec/unit/plugins/linux/kernel_spec.rb +1 -1
  201. data/spec/unit/plugins/linux/lsb_spec.rb +1 -2
  202. data/spec/unit/plugins/linux/mdadm_spec.rb +4 -4
  203. data/spec/unit/plugins/linux/memory_spec.rb +29 -33
  204. data/spec/unit/plugins/linux/network_spec.rb +463 -245
  205. data/spec/unit/plugins/linux/platform_spec.rb +64 -65
  206. data/spec/unit/plugins/linux/uptime_spec.rb +1 -2
  207. data/spec/unit/plugins/linux/virtualization_spec.rb +42 -42
  208. data/spec/unit/plugins/lua_spec.rb +1 -2
  209. data/spec/unit/plugins/mono_spec.rb +1 -2
  210. data/spec/unit/plugins/netbsd/hostname_spec.rb +1 -2
  211. data/spec/unit/plugins/netbsd/kernel_spec.rb +1 -2
  212. data/spec/unit/plugins/netbsd/platform_spec.rb +1 -1
  213. data/spec/unit/plugins/network_spec.rb +118 -118
  214. data/spec/unit/plugins/nodejs_spec.rb +1 -1
  215. data/spec/unit/plugins/ohai_spec.rb +1 -1
  216. data/spec/unit/plugins/ohai_time_spec.rb +1 -2
  217. data/spec/unit/plugins/openbsd/hostname_spec.rb +1 -2
  218. data/spec/unit/plugins/openbsd/kernel_spec.rb +1 -2
  219. data/spec/unit/plugins/openbsd/platform_spec.rb +1 -2
  220. data/spec/unit/plugins/openstack_spec.rb +35 -37
  221. data/spec/unit/plugins/os_spec.rb +7 -8
  222. data/spec/unit/plugins/packages_spec.rb +118 -118
  223. data/spec/unit/plugins/passwd_spec.rb +18 -18
  224. data/spec/unit/plugins/perl_spec.rb +1 -1
  225. data/spec/unit/plugins/php_spec.rb +4 -4
  226. data/spec/unit/plugins/platform_spec.rb +8 -9
  227. data/spec/unit/plugins/powershell_spec.rb +3 -3
  228. data/spec/unit/plugins/python_spec.rb +1 -1
  229. data/spec/unit/plugins/rackspace_spec.rb +66 -68
  230. data/spec/unit/plugins/root_group_spec.rb +26 -26
  231. data/spec/unit/plugins/ruby_spec.rb +14 -15
  232. data/spec/unit/plugins/rust_spec.rb +2 -2
  233. data/spec/unit/plugins/sigar/network_route_spec.rb +36 -36
  234. data/spec/unit/plugins/softlayer_spec.rb +10 -10
  235. data/spec/unit/plugins/solaris2/cpu_spec.rb +20 -21
  236. data/spec/unit/plugins/solaris2/dmi_spec.rb +5 -6
  237. data/spec/unit/plugins/solaris2/filesystem.rb +5 -5
  238. data/spec/unit/plugins/solaris2/hostname_spec.rb +1 -1
  239. data/spec/unit/plugins/solaris2/kernel_spec.rb +3 -3
  240. data/spec/unit/plugins/solaris2/memory_spec.rb +5 -5
  241. data/spec/unit/plugins/solaris2/network_spec.rb +7 -8
  242. data/spec/unit/plugins/solaris2/platform_spec.rb +1 -1
  243. data/spec/unit/plugins/solaris2/virtualization_spec.rb +3 -5
  244. data/spec/unit/plugins/solaris2/zpools_spec.rb +6 -6
  245. data/spec/unit/plugins/ssh_host_keys_spec.rb +1 -1
  246. data/spec/unit/plugins/virtualbox_spec.rb +19 -19
  247. data/spec/unit/plugins/vmware_spec.rb +28 -28
  248. data/spec/unit/plugins/windows/cpu_spec.rb +46 -48
  249. data/spec/unit/plugins/windows/memory_spec.rb +5 -5
  250. data/spec/unit/plugins/windows/virtualization_spec.rb +163 -163
  251. data/spec/unit/provides_map_spec.rb +10 -10
  252. data/spec/unit/runner_spec.rb +10 -10
  253. data/spec/unit/system_spec.rb +19 -19
  254. data/spec/unit/util/file_helper_spec.rb +5 -6
  255. data/spec/unit/util/ip_helper_spec.rb +39 -39
  256. metadata +31 -4
@@ -16,8 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
-
20
- require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
19
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
21
20
 
22
21
  describe Ohai::System, "Darwin plugin platform" do
23
22
  before(:each) do
@@ -16,11 +16,11 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
19
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
20
  require File.expand_path("#{File.dirname(__FILE__)}/system_profiler_output.rb")
21
21
 
22
22
  begin
23
- require 'plist'
23
+ require "plist"
24
24
  rescue LoadError => e
25
25
  puts "The darwin systemprofile plugin spec tests will fail without the 'plist' library/gem.\n\n"
26
26
  raise e
@@ -42,6 +42,6 @@ describe Ohai::System, "Darwin system_profiler plugin", :unix_only do
42
42
  allow(@plugin).to receive(:shell_out).with(full_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Full, ""))
43
43
  allow(@plugin).to receive(:shell_out).with(mini_cmd).and_return(mock_shell_out(0, SystemProfilerOutput::Mini, ""))
44
44
  @plugin.run
45
- expect(@plugin['system_profile'][18]["_items"][0]["serial_number"]).to eq('ABCDEFG12345')
45
+ expect(@plugin["system_profile"][18]["_items"][0]["serial_number"]).to eq("ABCDEFG12345")
46
46
  end
47
47
  end
@@ -16,10 +16,10 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper.rb')
19
+ require File.expand_path(File.dirname(__FILE__) + "/../../../spec_helper.rb")
20
20
 
21
21
  describe Ohai::System, "Darwin virtualization platform" do
22
- let(:plugin) { get_plugin("darwin/virtualization")}
22
+ let(:plugin) { get_plugin("darwin/virtualization") }
23
23
 
24
24
  before(:each) do
25
25
  allow(plugin).to receive(:collect_os).and_return(:darwin)
@@ -38,12 +38,12 @@ describe Ohai::System, "Darwin virtualization platform" do
38
38
  it "should not set parallels host if /usr/bin/prlctl not exist" do
39
39
  allow(plugin).to receive(:prlctl_exists?).and_return(false)
40
40
  plugin.run
41
- expect(plugin[:virtualization]).to eq({'systems' => {}})
41
+ expect(plugin[:virtualization]).to eq({ "systems" => {} })
42
42
  end
43
43
 
44
44
  it "should set parallels guest if /usr/sbin/ioreg exists and it's output contains pci1ab8,4000" do
45
45
  allow(plugin).to receive(:ioreg_exists?).and_return(true)
46
- ioreg=<<-IOREG
46
+ ioreg = <<-IOREG
47
47
  | | +-o pci1ab8,4000@3 <class IOPCIDevice, id 0x1000001d1, registered, matched, active, busy 0 (40 ms), retain 9>
48
48
  | | | | {
49
49
  | | | | "compatible" = <"pci1ab8,400","pci1ab8,4000","pciclass,ff0000">
@@ -77,7 +77,7 @@ describe Ohai::System, "Darwin virtualization platform" do
77
77
 
78
78
  it "should not set parallels guest if /usr/sbin/ioreg exists and it's output not contain pci1ab8,4000" do
79
79
  allow(plugin).to receive(:ioreg_exists?).and_return(true)
80
- ioreg=<<-IOREG
80
+ ioreg = <<-IOREG
81
81
  | | +-o pci8086,2445@1F,4 <class IOPCIDevice, id 0x1000001d4, registered, matched, active, busy 0 (974 ms), retain 11>
82
82
  | | | {
83
83
  | | | "compatible" = <"pci1ab8,400","pci8086,2445","pciclass,040100">
@@ -103,7 +103,7 @@ describe Ohai::System, "Darwin virtualization platform" do
103
103
  allow(shellout).to receive(:stdout).and_return(ioreg)
104
104
  allow(plugin).to receive(:shell_out).with("ioreg -l").and_return(shellout)
105
105
  plugin.run
106
- expect(plugin[:virtualization]).to eq({'systems' => {}})
106
+ expect(plugin[:virtualization]).to eq({ "systems" => {} })
107
107
  end
108
108
  end
109
109
  end
@@ -15,13 +15,13 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require 'ipaddress'
19
- require 'spec_helper'
18
+ require "ipaddress"
19
+ require "spec_helper"
20
20
 
21
21
  describe Ohai::System, "plugin digital_ocean" do
22
- let(:hint_path_nix) { '/etc/chef/ohai/hints/digital_ocean.json' }
22
+ let(:hint_path_nix) { "/etc/chef/ohai/hints/digital_ocean.json" }
23
23
  let(:hint_path_win) { 'C:\chef\ohai\hints/digital_ocean.json' }
24
- let(:digitalocean_path) { '/etc/digitalocean' }
24
+ let(:digitalocean_path) { "/etc/digitalocean" }
25
25
  let(:hint) {
26
26
  '{
27
27
  "droplet_id": 12345678,
@@ -39,13 +39,16 @@ describe Ohai::System, "plugin digital_ocean" do
39
39
  before do
40
40
  @plugin = get_plugin("digital_ocean")
41
41
  @plugin[:network] = {
42
- "interfaces"=> {
43
- "eth0"=> {
44
- "addresses"=> {
45
- "1.2.3.4"=> {
46
- "netmask"=> "255.255.255.0"
42
+ "interfaces" => {
43
+ "eth0" => {
44
+ "addresses" => {
45
+ "00:D3:AD:B3:3F:00" => {
46
+ "family" => "lladdr"
47
47
  },
48
- "2400:6180:0000:00d0:0000:0000:0009:7001"=> {}
48
+ "1.2.3.4" => {
49
+ "netmask" => "255.255.255.0"
50
+ },
51
+ "2400:6180:0000:00d0:0000:0000:0009:7001" => {},
49
52
  }
50
53
  }
51
54
  }
@@ -57,8 +60,7 @@ describe Ohai::System, "plugin digital_ocean" do
57
60
  allow(File).to receive(:read).with(hint_path_win).and_return(hint)
58
61
  end
59
62
 
60
-
61
- shared_examples_for "!digital_ocean" do
63
+ shared_examples_for "!digital_ocean" do
62
64
  before(:each) do
63
65
  @plugin.run
64
66
  end
@@ -74,12 +76,12 @@ describe Ohai::System, "plugin digital_ocean" do
74
76
  end
75
77
 
76
78
  it "pulls ip addresses from the network interfaces" do
77
- expect(@plugin[:digital_ocean][:networks][:v4]).to eq([{"ip_address" => "1.2.3.4",
78
- "type" => "public",
79
- "netmask" => "255.255.255.0"}])
80
- expect(@plugin[:digital_ocean][:networks][:v6]).to eq([{"ip_address"=>"2400:6180:0000:00d0:0000:0000:0009:7001",
81
- "type"=>"public",
82
- "cidr"=>128}])
79
+ expect(@plugin[:digital_ocean][:networks][:v4]).to eq([{ "ip_address" => "1.2.3.4",
80
+ "type" => "public",
81
+ "netmask" => "255.255.255.0" }])
82
+ expect(@plugin[:digital_ocean][:networks][:v6]).to eq([{ "ip_address" => "2400:6180:0000:00d0:0000:0000:0009:7001",
83
+ "type" => "public",
84
+ "cidr" => 128 }])
83
85
  end
84
86
  end
85
87
 
@@ -112,7 +114,7 @@ describe Ohai::System, "plugin digital_ocean" do
112
114
  expect(@plugin[:digital_ocean][:region_id]).to eq(4)
113
115
  end
114
116
 
115
- include_examples 'digital_ocean_networking'
117
+ include_examples "digital_ocean_networking"
116
118
  end
117
119
 
118
120
  describe "with digital_ocean hint file" do
@@ -128,11 +130,11 @@ describe Ohai::System, "plugin digital_ocean" do
128
130
  context "with private networking enabled" do
129
131
  before do
130
132
  @plugin[:network][:interfaces][:eth1] = {
131
- "addresses"=> {
133
+ "addresses" => {
132
134
  "10.128.142.89" => {
133
135
  "netmask" => "255.255.255.0"
134
136
  },
135
- "fdf8:f53b:82e4:0000:0000:0000:0000:0053" => {}
137
+ "fdf8:f53b:82e4:0000:0000:0000:0000:0053" => {},
136
138
  }
137
139
  }
138
140
 
@@ -140,18 +142,18 @@ describe Ohai::System, "plugin digital_ocean" do
140
142
  end
141
143
 
142
144
  it "should extract the private networking ips" do
143
- expect(@plugin[:digital_ocean][:networks][:v4]).to eq([{"ip_address" => "1.2.3.4",
144
- "type" => "public",
145
- "netmask" => "255.255.255.0"},
146
- {"ip_address" => "10.128.142.89",
147
- "type" => "private",
148
- "netmask" => "255.255.255.0"}])
149
- expect(@plugin[:digital_ocean][:networks][:v6]).to eq([{"ip_address"=>"2400:6180:0000:00d0:0000:0000:0009:7001",
150
- "type"=>"public",
151
- "cidr"=>128},
152
- {"ip_address"=>"fdf8:f53b:82e4:0000:0000:0000:0000:0053",
153
- "type"=>"private",
154
- "cidr"=>128}])
145
+ expect(@plugin[:digital_ocean][:networks][:v4]).to eq([{ "ip_address" => "1.2.3.4",
146
+ "type" => "public",
147
+ "netmask" => "255.255.255.0" },
148
+ { "ip_address" => "10.128.142.89",
149
+ "type" => "private",
150
+ "netmask" => "255.255.255.0" }])
151
+ expect(@plugin[:digital_ocean][:networks][:v6]).to eq([{ "ip_address" => "2400:6180:0000:00d0:0000:0000:0009:7001",
152
+ "type" => "public",
153
+ "cidr" => 128 },
154
+ { "ip_address" => "fdf8:f53b:82e4:0000:0000:0000:0000:0053",
155
+ "type" => "private",
156
+ "cidr" => 128 }])
155
157
  end
156
158
  end
157
159
  end
@@ -162,7 +164,6 @@ describe Ohai::System, "plugin digital_ocean" do
162
164
  allow(File).to receive(:exist?).with(hint_path_win).and_return(false)
163
165
  end
164
166
 
165
-
166
167
  describe "with the /etc/digitalocean file" do
167
168
  before do
168
169
  allow(File).to receive(:exist?).with(digitalocean_path).and_return(true)
@@ -180,7 +181,7 @@ describe Ohai::System, "plugin digital_ocean" do
180
181
  end
181
182
 
182
183
  context "with ec2 hint file" do
183
- let(:ec2_hint_path_nix) { '/etc/chef/ohai/hints/ec2.json' }
184
+ let(:ec2_hint_path_nix) { "/etc/chef/ohai/hints/ec2.json" }
184
185
  let(:ec2_hint_path_win) { 'C:\chef\ohai\hints/ec2.json' }
185
186
 
186
187
  before do
@@ -188,9 +189,9 @@ describe Ohai::System, "plugin digital_ocean" do
188
189
  allow(File).to receive(:exist?).with(hint_path_win).and_return(false)
189
190
 
190
191
  allow(File).to receive(:exist?).with(ec2_hint_path_nix).and_return(true)
191
- allow(File).to receive(:read).with(ec2_hint_path_nix).and_return('')
192
+ allow(File).to receive(:read).with(ec2_hint_path_nix).and_return("")
192
193
  allow(File).to receive(:exist?).with(ec2_hint_path_win).and_return(true)
193
- allow(File).to receive(:read).with(ec2_hint_path_win).and_return('')
194
+ allow(File).to receive(:read).with(ec2_hint_path_win).and_return("")
194
195
  end
195
196
 
196
197
  describe "with the /etc/digitalocean file" do
@@ -6,9 +6,9 @@
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
8
8
  # You may obtain a copy of the License at
9
- #
9
+ #
10
10
  # http://www.apache.org/licenses/LICENSE-2.0
11
- #
11
+ #
12
12
  # Unless required by applicable law or agreed to in writing, software
13
13
  # distributed under the License is distributed on an "AS IS" BASIS,
14
14
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
19
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
20
20
 
21
21
  # NOTE: These data lines must be prefixed with one or two tabs, not spaces.
22
22
  DMI_OUT = <<-EOS
@@ -17,21 +17,24 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
21
- require 'open-uri'
22
- require 'base64'
20
+ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
21
+ require "open-uri"
22
+ require "base64"
23
23
 
24
24
  describe Ohai::System, "plugin ec2" do
25
25
  before(:each) do
26
26
  @plugin = get_plugin("ec2")
27
- @plugin[:network] = {:interfaces => {:eth0 => {} } }
28
- allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
27
+ @plugin[:network] = { :interfaces => { :eth0 => {} } }
28
+ allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(false)
29
29
  allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
30
+ allow(File).to receive(:exist?).with("/usr/bin/ec2metadata").and_return(false)
31
+ allow(File).to receive(:exist?).with("/usr/bin/rackspace-monitoring-agent").and_return(false)
30
32
  end
31
33
 
32
34
  shared_examples_for "!ec2" do
33
- it "should NOT attempt to fetch the ec2 metadata" do
35
+ it "should NOT attempt to fetch the ec2 metadata or set ec2 attribute" do
34
36
  expect(@plugin).not_to receive(:http_client)
37
+ expect(@plugin[:ec2]).to be_nil
35
38
  @plugin.run
36
39
  end
37
40
  end
@@ -40,61 +43,61 @@ describe Ohai::System, "plugin ec2" do
40
43
  before(:each) do
41
44
  @http_client = double("Net::HTTP client")
42
45
  allow(@plugin).to receive(:http_client).and_return(@http_client)
43
- allow(IO).to receive(:select).and_return([[],[1],[]])
46
+ allow(IO).to receive(:select).and_return([[], [1], []])
44
47
  t = double("connection")
45
48
  allow(t).to receive(:connect_nonblock).and_raise(Errno::EINPROGRESS)
46
49
  allow(Socket).to receive(:new).and_return(t)
47
50
  expect(@http_client).to receive(:get).
48
51
  with("/").twice.
49
52
  and_return(double("Net::HTTP Response", :body => "2012-01-12", :code => "200"))
50
- allow(File).to receive(:exist?).and_return(false)
51
53
  end
52
54
 
53
- context "with common metadata paths" do
54
- let(:paths) do
55
- { "meta-data/" => "instance_type\nami_id\nsecurity-groups",
56
- "meta-data/instance_type" => "c1.medium",
57
- "meta-data/ami_id" => "ami-5d2dc934",
58
- "meta-data/security-groups" => "group1\ngroup2"
59
- }
60
- end
61
- it "recursively fetches all the ec2 metadata" do
62
- paths.each do |name,body|
63
- expect(@http_client).to receive(:get).
64
- with("/2012-01-12/#{name}").
65
- and_return(double("Net::HTTP Response", :body => body, :code => "200"))
55
+ context "with common metadata paths" do
56
+ let(:paths) do
57
+ { "meta-data/" => "instance_type\nami_id\nsecurity-groups",
58
+ "meta-data/instance_type" => "c1.medium",
59
+ "meta-data/ami_id" => "ami-5d2dc934",
60
+ "meta-data/security-groups" => "group1\ngroup2",
61
+ }
66
62
  end
67
- expect(@http_client).to receive(:get).
68
- with("/2012-01-12/user-data/").
69
- and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
70
63
 
71
- @plugin.run
64
+ it "recursively fetches all the ec2 metadata" do
65
+ paths.each do |name, body|
66
+ expect(@http_client).to receive(:get).
67
+ with("/2012-01-12/#{name}").
68
+ and_return(double("Net::HTTP Response", :body => body, :code => "200"))
69
+ end
70
+ expect(@http_client).to receive(:get).
71
+ with("/2012-01-12/user-data/").
72
+ and_return(double("Net::HTTP Response", :body => "By the pricking of my thumb...", :code => "200"))
72
73
 
73
- expect(@plugin[:ec2]).not_to be_nil
74
- expect(@plugin[:ec2]['instance_type']).to eq("c1.medium")
75
- expect(@plugin[:ec2]['ami_id']).to eq("ami-5d2dc934")
76
- expect(@plugin[:ec2]['security_groups']).to eql ['group1', 'group2']
77
- end
74
+ @plugin.run
78
75
 
79
- it "fetches binary userdata opaquely" do
80
- paths.each do |name,body|
81
- expect(@http_client).to receive(:get).
82
- with("/2012-01-12/#{name}").
83
- and_return(double("Net::HTTP Response", :body => body, :code => "200"))
76
+ expect(@plugin[:ec2]).not_to be_nil
77
+ expect(@plugin[:ec2]["instance_type"]).to eq("c1.medium")
78
+ expect(@plugin[:ec2]["ami_id"]).to eq("ami-5d2dc934")
79
+ expect(@plugin[:ec2]["security_groups"]).to eql %w{group1 group2}
84
80
  end
85
- expect(@http_client).to receive(:get).
86
- with("/2012-01-12/user-data/").
87
- and_return(double("Net::HTTP Response", :body => "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", :code => "200"))
88
81
 
89
- @plugin.run
82
+ it "fetches binary userdata opaquely" do
83
+ paths.each do |name, body|
84
+ expect(@http_client).to receive(:get).
85
+ with("/2012-01-12/#{name}").
86
+ and_return(double("Net::HTTP Response", :body => body, :code => "200"))
87
+ end
88
+ expect(@http_client).to receive(:get).
89
+ with("/2012-01-12/user-data/").
90
+ and_return(double("Net::HTTP Response", :body => "^_<8B>^H^H<C7>U^@^Csomething^@KT<C8><C9>,)<C9>IU(I-.I<CB><CC>I<E5>^B^@^Qz<BF><B0>^R^@^@^@", :code => "200"))
90
91
 
91
- expect(@plugin[:ec2]).not_to be_nil
92
- expect(@plugin[:ec2]['instance_type']).to eq("c1.medium")
93
- expect(@plugin[:ec2]['ami_id']).to eq("ami-5d2dc934")
94
- expect(@plugin[:ec2]['security_groups']).to eql ['group1', 'group2']
95
- expect(@plugin[:ec2]['userdata']).to eq(Base64.decode64("Xl88OEI+XkheSDxDNz5VXkBeQ3NvbWV0aGluZ15AS1Q8Qzg+PEM5PiwpPEM5\nPklVKEktLkk8Q0I+PENDPkk8RTU+XkJeQF5RejxCRj48QjA+XlJeQF5AXkA="))
92
+ @plugin.run
93
+
94
+ expect(@plugin[:ec2]).not_to be_nil
95
+ expect(@plugin[:ec2]["instance_type"]).to eq("c1.medium")
96
+ expect(@plugin[:ec2]["ami_id"]).to eq("ami-5d2dc934")
97
+ expect(@plugin[:ec2]["security_groups"]).to eql %w{group1 group2}
98
+ expect(@plugin[:ec2]["userdata"]).to eq(Base64.decode64("Xl88OEI+XkheSDxDNz5VXkBeQ3NvbWV0aGluZ15AS1Q8Qzg+PEM5PiwpPEM5\nPklVKEktLkk8Q0I+PENDPkk8RTU+XkJeQF5RejxCRj48QjA+XlJeQF5AXkA="))
99
+ end
96
100
  end
97
- end
98
101
 
99
102
  it "should parse ec2 network/ directory as a multi-level hash" do
100
103
  expect(@http_client).to receive(:get).
@@ -122,17 +125,17 @@ end
122
125
  @plugin.run
123
126
 
124
127
  expect(@plugin[:ec2]).not_to be_nil
125
- expect(@plugin[:ec2]['network_interfaces_macs']['12:34:56:78:9a:bc']['public_hostname']).to eql('server17.opscode.com')
126
- end
128
+ expect(@plugin[:ec2]["network_interfaces_macs"]["12:34:56:78:9a:bc"]["public_hostname"]).to eql("server17.opscode.com")
129
+ end # context with common metadata paths
127
130
 
128
- context "with ec2_iam cloud file" do
131
+ context "with ec2_iam hint file" do
129
132
  before do
130
133
  if windows?
131
134
  allow(File).to receive(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(true)
132
- allow(File).to receive(:read).with('C:\chef\ohai\hints/iam.json').and_return('')
135
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/iam.json').and_return("")
133
136
  else
134
- allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(true)
135
- allow(File).to receive(:read).with('/etc/chef/ohai/hints/iam.json').and_return('')
137
+ allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/iam.json").and_return(true)
138
+ allow(File).to receive(:read).with("/etc/chef/ohai/hints/iam.json").and_return("")
136
139
  end
137
140
  end
138
141
 
@@ -156,17 +159,17 @@ end
156
159
  @plugin.run
157
160
 
158
161
  expect(@plugin[:ec2]).not_to be_nil
159
- expect(@plugin[:ec2]['iam']['security-credentials']['MyRole']['Code']).to eql 'Success'
160
- expect(@plugin[:ec2]['iam']['security-credentials']['MyRole']['Token']).to eql '12345678'
162
+ expect(@plugin[:ec2]["iam"]["security-credentials"]["MyRole"]["Code"]).to eql "Success"
163
+ expect(@plugin[:ec2]["iam"]["security-credentials"]["MyRole"]["Token"]).to eql "12345678"
161
164
  end
162
165
  end
163
166
 
164
- context "without ec2_iam cloud file" do
167
+ context "without ec2_iam hint file" do
165
168
  before do
166
169
  if windows?
167
170
  allow(File).to receive(:exist?).with('C:\chef\ohai\hints/iam.json').and_return(false)
168
171
  else
169
- allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/iam.json').and_return(false)
172
+ allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/iam.json").and_return(false)
170
173
  end
171
174
  end
172
175
 
@@ -190,7 +193,7 @@ end
190
193
  @plugin.run
191
194
 
192
195
  expect(@plugin[:ec2]).not_to be_nil
193
- expect(@plugin[:ec2]['iam']).to be_nil
196
+ expect(@plugin[:ec2]["iam"]).to be_nil
194
197
  end
195
198
  end
196
199
 
@@ -248,78 +251,84 @@ end
248
251
  @plugin.run
249
252
 
250
253
  expect(@plugin[:ec2]).not_to be_nil
251
- expect(@plugin[:ec2]['metrics']).to be_nil
252
- expect(@plugin[:ec2]['metrics_vhostmd']).to be_nil
254
+ expect(@plugin[:ec2]["metrics"]).to be_nil
255
+ expect(@plugin[:ec2]["metrics_vhostmd"]).to be_nil
253
256
  end
254
- end
255
-
256
- describe "with ec2 mac and metadata address connected" do
257
- it_should_behave_like "ec2"
257
+ end # shared examples for ec2
258
258
 
259
+ describe "without dmi or ec2metadata binary, with xen mac, and metadata address connected" do
259
260
  before(:each) do
260
- allow(IO).to receive(:select).and_return([[],[1],[]])
261
- @plugin[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"fe:ff:ff:ff:ff:ff"}
261
+ allow(IO).to receive(:select).and_return([[], [1], []])
262
+ @plugin[:network][:interfaces][:eth0][:arp] = { "169.254.1.0" => "fe:ff:ff:ff:ff:ff" }
262
263
  end
263
- end
264
264
 
265
- describe "without ec2 mac and metadata address connected" do
266
- it_should_behave_like "!ec2"
265
+ it_should_behave_like "ec2"
267
266
 
268
- before(:each) do
269
- @plugin[:network][:interfaces][:eth0][:arp] = {"169.254.1.0"=>"00:50:56:c0:00:08"}
267
+ it "warns that the arp table method is deprecated" do
268
+ expect(Ohai::Log).to receive(:warn).with(/will be removed/)
269
+ @plugin.has_xen_mac?
270
270
  end
271
271
  end
272
272
 
273
- describe "with ec2 dmi data" do
273
+ describe "with ec2metadata binary" do
274
274
  it_should_behave_like "ec2"
275
275
 
276
276
  before(:each) do
277
- @plugin[:dmi] = { :bios => { :all_records => [ { :Version => "4.2.amazon" } ] } }
277
+ allow(File).to receive(:exist?).with("/usr/bin/ec2metadata").and_return(true)
278
278
  end
279
279
  end
280
280
 
281
- describe "without ec2 dmi data" do
282
- it_should_behave_like "!ec2"
281
+ describe "with ec2 dmi data" do
282
+ it_should_behave_like "ec2"
283
283
 
284
284
  before(:each) do
285
- @plugin[:dmi] = nil
285
+ @plugin[:dmi] = { :bios => { :all_records => [ { :Version => "4.2.amazon" } ] } }
286
286
  end
287
287
  end
288
288
 
289
- describe "with ec2 cloud file" do
289
+ describe "with ec2 hint file" do
290
290
  it_should_behave_like "ec2"
291
291
 
292
292
  before(:each) do
293
293
  if windows?
294
294
  expect(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(true)
295
- allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return('')
295
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/ec2.json').and_return("")
296
296
  else
297
- expect(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(true)
298
- allow(File).to receive(:read).with('/etc/chef/ohai/hints/ec2.json').and_return('')
297
+ expect(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(true)
298
+ allow(File).to receive(:read).with("/etc/chef/ohai/hints/ec2.json").and_return("")
299
299
  end
300
300
  end
301
301
  end
302
302
 
303
- describe "without cloud file" do
303
+ describe "with rackspace hint file" do
304
304
  it_should_behave_like "!ec2"
305
305
 
306
306
  before(:each) do
307
- allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
308
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
307
+ allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/rackspace.json").and_return(true)
308
+ allow(File).to receive(:read).with("/etc/chef/ohai/hints/rackspace.json").and_return("")
309
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
310
+ allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return("")
309
311
  end
310
312
  end
311
313
 
312
- describe "with rackspace cloud file" do
314
+ describe "with ec2metadata, but with rackspace-monitoring-agent" do
313
315
  it_should_behave_like "!ec2"
314
316
 
315
317
  before(:each) do
316
- allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/ec2.json').and_return(false)
317
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
318
+ allow(File).to receive(:exist?).with("/usr/bin/ec2metadata").and_return(true)
319
+ allow(File).to receive(:exist?).with("/usr/bin/rackspace-monitoring-agent").and_return(true)
320
+ end
321
+ end
318
322
 
319
- allow(File).to receive(:exist?).with('/etc/chef/ohai/hints/rackspace.json').and_return(true)
320
- allow(File).to receive(:read).with('/etc/chef/ohai/hints/rackspace.json').and_return('')
321
- allow(File).to receive(:exist?).with('C:\chef\ohai\hints/rackspace.json').and_return(true)
322
- allow(File).to receive(:read).with('C:\chef\ohai\hints/rackspace.json').and_return('')
323
+ describe "without any hints that it is an ec2 system" do
324
+ it_should_behave_like "!ec2"
325
+
326
+ before(:each) do
327
+ allow(File).to receive(:exist?).with("/etc/chef/ohai/hints/ec2.json").and_return(false)
328
+ allow(File).to receive(:exist?).with('C:\chef\ohai\hints/ec2.json').and_return(false)
329
+ allow(File).to receive(:exist?).with("/usr/bin/ec2metadata").and_return(false)
330
+ @plugin[:dmi] = nil
331
+ @plugin[:network][:interfaces][:eth0][:arp] = { "169.254.1.0" => "00:50:56:c0:00:08" }
323
332
  end
324
333
  end
325
334