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
@@ -23,7 +23,7 @@ class String
23
23
  # This should implement the same functionality as underscore method in
24
24
  # ActiveSupport::CoreExtensions::String::Inflections
25
25
  def wmi_underscore
26
- self.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
27
- gsub(/([a-z\d])([A-Z])/,'\1_\2').tr("-", "_").downcase
26
+ self.gsub(/::/, "/").gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
27
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').tr("-", "_").downcase
28
28
  end
29
29
  end
@@ -15,7 +15,7 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
- require 'ohai/exception'
18
+ require "ohai/exception"
19
19
 
20
20
  module Ohai
21
21
  class PluginConfig < Hash
@@ -27,7 +27,7 @@ Ohai.plugin(:CPU) do
27
27
  cpu[:total] = shell_out("pmcycles -m").stdout.lines.length
28
28
 
29
29
  # The below is only relevent on an LPAR
30
- if shell_out('uname -W').stdout.strip == "0"
30
+ if shell_out("uname -W").stdout.strip == "0"
31
31
 
32
32
  # At least one CPU will be available, but we'll wait to increment this later.
33
33
  cpu[:available] = 0
@@ -36,7 +36,7 @@ Ohai.plugin(:CPU) do
36
36
  #from http://www-01.ibm.com/software/passportadvantage/pvu_terminology_for_customers.html
37
37
  #on AIX number of cores and processors are considered same
38
38
  cpu[:real] = cpu[:cores] = cpudevs.length
39
- cpudevs.each.with_index do |c,i|
39
+ cpudevs.each.with_index do |c, i|
40
40
  name, status, location = c.split
41
41
  index = i.to_s
42
42
  cpu[index] = Mash.new
@@ -54,14 +54,14 @@ Ohai.plugin(:Filesystem) do
54
54
  oldie[key] ||= Mash.new
55
55
  oldie[key][:mount] = fields[1]
56
56
  oldie[key][:fs_type] = fields[2]
57
- oldie[key][:mount_options] = fields[6].split(',')
57
+ oldie[key][:mount_options] = fields[6].split(",")
58
58
  # entries occupying the 'Node' column parsed here
59
59
  else
60
60
  key = fields[0] + ":" + fields[1]
61
61
  oldie[key] ||= Mash.new
62
62
  oldie[key][:mount] = fields[1]
63
63
  oldie[key][:fs_type] = fields[3]
64
- oldie[key][:mount_options] = fields[7].split(',')
64
+ oldie[key][:mount_options] = fields[7].split(",")
65
65
  end
66
66
  end
67
67
  oldie
@@ -30,7 +30,7 @@ Ohai.plugin(:Memory) do
30
30
  memory[:free] = "#{free_in_mb.to_i * 1024}kB"
31
31
 
32
32
  swapinfo = shell_out("swap -s").stdout.split #returns swap info in 4K blocks
33
- memory[:swap]['total'] = "#{(swapinfo[2].to_i) * 4}kB"
34
- memory[:swap]['free'] = "#{(swapinfo[10].to_i) * 4}kB"
33
+ memory[:swap]["total"] = "#{(swapinfo[2].to_i) * 4}kB"
34
+ memory[:swap]["free"] = "#{(swapinfo[10].to_i) * 4}kB"
35
35
  end
36
36
  end
@@ -19,7 +19,7 @@
19
19
  #
20
20
 
21
21
  Ohai.plugin(:Network) do
22
- require 'ipaddr'
22
+ require "ipaddr"
23
23
 
24
24
  provides "network", "counters/network", "macaddress"
25
25
 
@@ -27,7 +27,7 @@ Ohai.plugin(:Network) do
27
27
  def hex_to_dec_netmask(netmask)
28
28
  # example '0xffff0000' -> '255.255.0.0'
29
29
  dec = netmask[2..3].to_i(16).to_s(10)
30
- [4,6,8].each { |n| dec = dec + "." + netmask[n..n+1].to_i(16).to_s(10) }
30
+ [4, 6, 8].each { |n| dec = dec + "." + netmask[n..n + 1].to_i(16).to_s(10) }
31
31
  dec
32
32
  end
33
33
 
@@ -53,7 +53,7 @@ Ohai.plugin(:Network) do
53
53
  # :default_interface, :default_gateway - route -n get 0
54
54
  so = shell_out("netstat -rn |grep default")
55
55
  so.stdout.lines.each do |line|
56
- items = line.split(' ')
56
+ items = line.split(" ")
57
57
  if items[0] == "default"
58
58
  network[:default_gateway] = items[1]
59
59
  network[:default_interface] = items[5]
@@ -68,12 +68,12 @@ Ohai.plugin(:Network) do
68
68
  interface = splat[0]
69
69
  line = splat[1..-1][0]
70
70
  iface[interface] = Mash.new
71
- iface[interface][:state] = (line.include?("<UP,") ? 'up' : 'down')
71
+ iface[interface][:state] = (line.include?("<UP,") ? "up" : "down")
72
72
 
73
73
  intraface.lines.each do |lin|
74
74
  case lin
75
75
  when /flags=\S+<(\S+)>/
76
- iface[interface][:flags] = $1.split(',')
76
+ iface[interface][:flags] = $1.split(",")
77
77
  iface[interface][:metric] = $1 if lin =~ /metric\s(\S+)/
78
78
  else
79
79
  # We have key value pairs.
@@ -103,9 +103,9 @@ Ohai.plugin(:Network) do
103
103
  else
104
104
  # load all key-values, example "tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1"
105
105
  properties = lin.split
106
- n = properties.length/2 - 1
106
+ n = properties.length / 2 - 1
107
107
  (0..n).each do |i|
108
- iface[interface][properties[i*2]] = properties[(i*2+1)]
108
+ iface[interface][properties[i * 2]] = properties[(i * 2 + 1)]
109
109
  end
110
110
  end
111
111
  end
@@ -120,7 +120,7 @@ Ohai.plugin(:Network) do
120
120
  macaddress $1.upcase unless shell_out("uname -W").stdout.to_i > 0
121
121
  end
122
122
  end
123
- end #ifconfig stdout
123
+ end #ifconfig stdout
124
124
 
125
125
  # Query routes information
126
126
  %w{inet inet6}.each do |family|
@@ -130,7 +130,7 @@ Ohai.plugin(:Network) do
130
130
  interface = $6
131
131
  iface[interface][:routes] = Array.new unless iface[interface][:routes]
132
132
  iface[interface][:routes] << Mash.new( :destination => $1, :family => family,
133
- :via => $2, :flags => $3)
133
+ :via => $2, :flags => $3)
134
134
  end
135
135
  end
136
136
  end
@@ -151,4 +151,3 @@ Ohai.plugin(:Network) do
151
151
  network["interfaces"] = iface
152
152
  end
153
153
  end
154
-
@@ -17,11 +17,11 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'ohai/mixin/os'
20
+ require "ohai/mixin/os"
21
21
 
22
22
  Ohai.plugin(:OS) do
23
23
  provides "os", "os_version"
24
- depends 'kernel'
24
+ depends "kernel"
25
25
 
26
26
  collect_data(:aix) do
27
27
  os collect_os
@@ -21,14 +21,14 @@ Ohai.plugin(:Uptime) do
21
21
  provides "uptime", "uptime_seconds"
22
22
 
23
23
  collect_data(:aix) do
24
- require 'date'
24
+ require "date"
25
25
  # Example output:
26
26
  # $ who -b
27
27
  # . system boot Jul 9 17:51
28
- so = shell_out('who -b')
28
+ so = shell_out("who -b")
29
29
  so.stdout.lines.each do |line|
30
30
  if line =~ /.* boot (.+)/
31
- uptime_seconds Time.now.to_i - DateTime.parse($1 + " #{Time.now.zone}").strftime('%s').to_i
31
+ uptime_seconds Time.now.to_i - DateTime.parse($1 + " #{Time.now.zone}").strftime("%s").to_i
32
32
  uptime seconds_to_human(uptime_seconds)
33
33
  break
34
34
  end
@@ -56,63 +56,63 @@ Ohai.plugin(:Virtualization) do
56
56
 
57
57
  sections.each do |line|
58
58
  case title
59
- when 'network'
59
+ when "network"
60
60
  next if line =~ /^Interface|^---/
61
61
  splat = line.strip.split
62
62
  key = splat[0].downcase
63
63
  value = {
64
- 'address' => splat[1],
65
- 'netmask' => splat[2],
66
- 'broadcast' => splat[3],
64
+ "address" => splat[1],
65
+ "netmask" => splat[2],
66
+ "broadcast" => splat[3],
67
67
  }
68
68
  wpars[wpar_name][title][key] = value
69
- when 'user-specified routes'
69
+ when "user-specified routes"
70
70
  next if line =~ /^Type|^---/
71
71
  splat = line.strip.split
72
72
  key = splat[2].downcase
73
73
  value = {
74
- 'destination' => splat[0],
75
- 'gateway' => splat[1],
74
+ "destination" => splat[0],
75
+ "gateway" => splat[1],
76
76
  }
77
77
  wpars[wpar_name][title][key] = value
78
- when 'file systems'
78
+ when "file systems"
79
79
  next if line =~ /^MountPoint|^---/
80
80
  splat = line.strip.split
81
81
  key = splat[1].downcase
82
82
  value = {
83
- 'mountpoint' => splat[0],
84
- 'device' => splat[1],
85
- 'vfs' => splat[2],
86
- 'options' => splat[3].split(','),
83
+ "mountpoint" => splat[0],
84
+ "device" => splat[1],
85
+ "vfs" => splat[2],
86
+ "options" => splat[3].split(","),
87
87
  }
88
88
  wpars[wpar_name][title][key] = value
89
- when 'security settings'
90
- privileges ||= ''
91
- wpars[wpar_name][title]['Privileges'] ||= []
89
+ when "security settings"
90
+ privileges ||= ""
91
+ wpars[wpar_name][title]["Privileges"] ||= []
92
92
 
93
93
  if line =~ /^Privileges/
94
- privileges << line.split(':')[1].strip
94
+ privileges << line.split(":")[1].strip
95
95
  else
96
96
  privileges << line.strip
97
97
  end
98
98
 
99
- wpars[wpar_name][title]['Privileges'] += privileges.split(',')
100
- when 'device exports'
99
+ wpars[wpar_name][title]["Privileges"] += privileges.split(",")
100
+ when "device exports"
101
101
  next if line =~ /^Name|^---/
102
102
  splat = line.strip.split
103
103
  key = splat[0].downcase
104
104
  value = {
105
- 'type' => splat[1],
106
- 'status' => splat[2],
105
+ "type" => splat[1],
106
+ "status" => splat[2],
107
107
  }
108
108
  wpars[wpar_name][title][key] = value
109
109
  else
110
110
  # key-value pairs are handled here
111
111
  # such as GENERAL and RESOURCE-
112
112
  # CONTROL
113
- splat = line.strip.split(':')
113
+ splat = line.strip.split(":")
114
114
  key = splat[0].downcase
115
- value = splat[1..-1].join(', ').strip
115
+ value = splat[1..-1].join(", ").strip
116
116
  value = value.empty? ? nil : value
117
117
  case value
118
118
  when "yes"
@@ -136,7 +136,7 @@ Ohai.plugin(:Virtualization) do
136
136
 
137
137
  top_level.each do |attribute|
138
138
  evalstr = "wpars['#{wpar_name}']"
139
- breadcrumb = attribute.split('.')
139
+ breadcrumb = attribute.split(".")
140
140
  breadcrumb.each do |node|
141
141
  evalstr << "[\'#{node}\']"
142
142
  end
@@ -19,17 +19,44 @@ Ohai.plugin(:Azure) do
19
19
 
20
20
  collect_data do
21
21
  # The azure hints are populated by the knife plugin for Azure.
22
- # The project is located at https://github.com/opscode/knife-azure
22
+ # The project is located at https://github.com/chef/knife-azure
23
23
  # Please see the lib/chef/knife/azure_server_create.rb file in that
24
24
  # project for details
25
- azure_metadata_from_hints = hint?('azure')
25
+ azure_metadata_from_hints = hint?("azure")
26
26
  if azure_metadata_from_hints
27
- Ohai::Log.debug("azure_metadata_from_hints is present.")
27
+ Ohai::Log.debug("azure plugin: azure_metadata_from_hints is present.")
28
+ azure Mash.new
29
+ azure_metadata_from_hints.each { |k, v| azure[k] = v }
30
+ elsif has_waagent? || has_dhcp_option_245?
31
+ Ohai::Log.debug("azure plugin: No hints present, but system appears to be on azure.")
28
32
  azure Mash.new
29
- azure_metadata_from_hints.each {|k, v| azure[k] = v }
30
33
  else
31
- Ohai::Log.debug("No hints present for azure.")
34
+ Ohai::Log.debug("azure plugin: No hints present for azure and doesn't appear to be azure.")
32
35
  false
33
36
  end
34
37
  end
38
+
39
+ # check for either the waagent or the unknown-245 DHCP option that Azure uses
40
+ # http://blog.mszcool.com/index.php/2015/04/detecting-if-a-virtual-machine-runs-in-microsoft-azure-linux-windows-to-protect-your-software-when-distributed-via-the-azure-marketplace/
41
+ def has_waagent?
42
+ if File.exist?("/usr/sbin/waagent") || Dir.exist?('C:\WindowsAzure')
43
+ Ohai::Log.debug("azure plugin: Found waagent used by MS Azure.")
44
+ return true
45
+ end
46
+ end
47
+
48
+ def has_dhcp_option_245?
49
+ has_245 = false
50
+ if File.exist?("/var/lib/dhcp/dhclient.eth0.leases")
51
+ File.open("/var/lib/dhcp/dhclient.eth0.leases").each do |line|
52
+ if line =~ /unknown-245/
53
+ Ohai::Log.debug("azure plugin: Found unknown-245 DHCP option used by MS Azure.")
54
+ has_245 = true
55
+ break
56
+ end
57
+ end
58
+ end
59
+ return has_245
60
+ end
61
+
35
62
  end
@@ -16,12 +16,12 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'ohai/mixin/dmi_decode'
19
+ require "ohai/mixin/dmi_decode"
20
20
 
21
21
  include Ohai::Mixin::DmiDecode
22
22
 
23
23
  Ohai.plugin(:Virtualization) do
24
- provides 'virtualization'
24
+ provides "virtualization"
25
25
 
26
26
  collect_data(:freebsd, :openbsd, :netbsd, :dragonflybsd) do
27
27
 
@@ -33,14 +33,14 @@ Ohai.plugin(:Virtualization) do
33
33
  if so.stdout.split($/)[0].to_i == 1
34
34
  virtualization[:system] = "jail"
35
35
  virtualization[:role] = "guest"
36
- virtualization[:systems][:jail] = 'guest'
36
+ virtualization[:systems][:jail] = "guest"
37
37
  end
38
38
 
39
- so = shell_out('jls -n')
40
- if (so.stdout || '').lines.count >= 1
41
- virtualization[:system] = 'jail'
42
- virtualization[:role] = 'host'
43
- virtualization[:systems][:jail] = 'host'
39
+ so = shell_out("jls -n")
40
+ if (so.stdout || "").lines.count >= 1
41
+ virtualization[:system] = "jail"
42
+ virtualization[:role] = "host"
43
+ virtualization[:systems][:jail] = "host"
44
44
  end
45
45
 
46
46
  # detect from modules
@@ -48,32 +48,32 @@ Ohai.plugin(:Virtualization) do
48
48
  so.stdout.lines do |line|
49
49
  case line
50
50
  when /vboxdrv/
51
- virtualization[:system] = 'vbox'
52
- virtualization[:role] = 'host'
53
- virtualization[:systems][:vbox] = 'host'
51
+ virtualization[:system] = "vbox"
52
+ virtualization[:role] = "host"
53
+ virtualization[:systems][:vbox] = "host"
54
54
  when /vboxguest/
55
- virtualization[:system] = 'vbox'
56
- virtualization[:role] = 'guest'
57
- virtualization[:systems][:vbox] = 'guest'
55
+ virtualization[:system] = "vbox"
56
+ virtualization[:role] = "guest"
57
+ virtualization[:systems][:vbox] = "guest"
58
58
  end
59
59
  end
60
60
 
61
61
  # Detect KVM/QEMU from cpu, report as KVM
62
62
  # hw.model: QEMU Virtual CPU version 0.9.1
63
- so = shell_out('sysctl -n hw.model')
63
+ so = shell_out("sysctl -n hw.model")
64
64
  if so.stdout.split($/)[0] =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
65
- virtualization[:system] = 'kvm'
66
- virtualization[:role] = 'guest'
67
- virtualization[:systems][:kvm] = 'guest'
65
+ virtualization[:system] = "kvm"
66
+ virtualization[:role] = "guest"
67
+ virtualization[:systems][:kvm] = "guest"
68
68
  end
69
69
 
70
70
  # parse dmidecode to discover various virtualization guests
71
- if File.exist?('/usr/local/sbin/dmidecode') || File.exist?('/usr/pkg/sbin/dmidecode')
72
- guest = guest_from_dmi(shell_out('dmidecode').stdout)
71
+ if File.exist?("/usr/local/sbin/dmidecode") || File.exist?("/usr/pkg/sbin/dmidecode")
72
+ guest = guest_from_dmi(shell_out("dmidecode").stdout)
73
73
  if guest
74
74
  virtualization[:system] = guest
75
- virtualization[:role] = 'guest'
76
- virtualization[:systems][guest.to_sym] = 'guest'
75
+ virtualization[:role] = "guest"
76
+ virtualization[:systems][guest.to_sym] = "guest"
77
77
  end
78
78
  end
79
79
  end
@@ -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 'rbconfig'
19
+ require "rbconfig"
20
20
 
21
21
  Ohai.plugin(:C) do
22
22
  provides "languages/c"
@@ -21,7 +21,7 @@ Ohai.plugin(:Chef) do
21
21
 
22
22
  collect_data do
23
23
  begin
24
- require 'chef/version'
24
+ require "chef/version"
25
25
  rescue Gem::LoadError
26
26
  # this catches when you've done a major version bump of ohai, but
27
27
  # your chef gem is incompatible, so we can't load it in the same VM
@@ -52,22 +52,22 @@ Ohai.plugin(:Cloud) do
52
52
  cloud[:public_ipv4] = []
53
53
  cloud[:local_ipv4] = []
54
54
 
55
- public_ips = gce['instance']["networkInterfaces"].collect do |interface|
56
- if interface.has_key?('accessConfigs')
57
- interface['accessConfigs'].collect{|ac| ac['externalIp']}
55
+ public_ips = gce["instance"]["networkInterfaces"].collect do |interface|
56
+ if interface.has_key?("accessConfigs")
57
+ interface["accessConfigs"].collect { |ac| ac["externalIp"] }
58
58
  end
59
59
  end.flatten.compact
60
60
 
61
- private_ips = gce['instance']["networkInterfaces"].collect do |interface|
62
- interface['ip']
61
+ private_ips = gce["instance"]["networkInterfaces"].collect do |interface|
62
+ interface["ip"]
63
63
  end.compact
64
64
 
65
65
  cloud[:public_ips] += public_ips
66
66
  cloud[:private_ips] += private_ips
67
- cloud[:public_ipv4] += public_ips
67
+ cloud[:public_ipv4] += public_ips
68
68
  cloud[:public_hostname] = nil
69
69
  cloud[:local_ipv4] += private_ips
70
- cloud[:local_hostname] = gce['instance']['hostname']
70
+ cloud[:local_hostname] = gce["instance"]["hostname"]
71
71
  cloud[:provider] = "gce"
72
72
  end
73
73
 
@@ -86,12 +86,12 @@ Ohai.plugin(:Cloud) do
86
86
 
87
87
  # Fill cloud hash with ec2 values
88
88
  def get_ec2_values
89
- cloud[:public_ips] << ec2['public_ipv4']
90
- cloud[:private_ips] << ec2['local_ipv4']
91
- cloud[:public_ipv4] = ec2['public_ipv4']
92
- cloud[:public_hostname] = ec2['public_hostname']
93
- cloud[:local_ipv4] = ec2['local_ipv4']
94
- cloud[:local_hostname] = ec2['local_hostname']
89
+ cloud[:public_ips] << ec2["public_ipv4"]
90
+ cloud[:private_ips] << ec2["local_ipv4"]
91
+ cloud[:public_ipv4] = ec2["public_ipv4"]
92
+ cloud[:public_hostname] = ec2["public_hostname"]
93
+ cloud[:local_ipv4] = ec2["local_ipv4"]
94
+ cloud[:local_hostname] = ec2["local_hostname"]
95
95
  cloud[:provider] = "ec2"
96
96
  end
97
97
 
@@ -110,14 +110,14 @@ Ohai.plugin(:Cloud) do
110
110
 
111
111
  # Fill cloud hash with rackspace values
112
112
  def get_rackspace_values
113
- cloud[:public_ips] << rackspace['public_ipv4'] if rackspace['public_ipv4']
114
- cloud[:private_ips] << rackspace['local_ipv4'] if rackspace['local_ipv4']
115
- cloud[:public_ipv4] = rackspace['public_ipv4']
116
- cloud[:public_ipv6] = rackspace['public_ipv6']
117
- cloud[:public_hostname] = rackspace['public_hostname']
118
- cloud[:local_ipv4] = rackspace['local_ipv4']
119
- cloud[:local_ipv6] = rackspace['local_ipv6']
120
- cloud[:local_hostname] = rackspace['local_hostname']
113
+ cloud[:public_ips] << rackspace["public_ipv4"] if rackspace["public_ipv4"]
114
+ cloud[:private_ips] << rackspace["local_ipv4"] if rackspace["local_ipv4"]
115
+ cloud[:public_ipv4] = rackspace["public_ipv4"]
116
+ cloud[:public_ipv6] = rackspace["public_ipv6"]
117
+ cloud[:public_hostname] = rackspace["public_hostname"]
118
+ cloud[:local_ipv4] = rackspace["local_ipv4"]
119
+ cloud[:local_ipv6] = rackspace["local_ipv6"]
120
+ cloud[:local_hostname] = rackspace["local_hostname"]
121
121
  cloud[:provider] = "rackspace"
122
122
  end
123
123
 
@@ -136,12 +136,12 @@ Ohai.plugin(:Cloud) do
136
136
 
137
137
  # Fill cloud hash with linode values
138
138
  def get_linode_values
139
- cloud[:public_ips] << linode['public_ip']
140
- cloud[:private_ips] << linode['private_ip']
141
- cloud[:public_ipv4] = linode['public_ipv4']
142
- cloud[:public_hostname] = linode['public_hostname']
143
- cloud[:local_ipv4] = linode['local_ipv4']
144
- cloud[:local_hostname] = linode['local_hostname']
139
+ cloud[:public_ips] << linode["public_ip"]
140
+ cloud[:private_ips] << linode["private_ip"]
141
+ cloud[:public_ipv4] = linode["public_ipv4"]
142
+ cloud[:public_hostname] = linode["public_hostname"]
143
+ cloud[:local_ipv4] = linode["local_ipv4"]
144
+ cloud[:local_hostname] = linode["local_hostname"]
145
145
  cloud[:provider] = "linode"
146
146
  end
147
147
 
@@ -159,12 +159,12 @@ Ohai.plugin(:Cloud) do
159
159
  end
160
160
 
161
161
  def get_eucalyptus_values
162
- cloud[:public_ips] << eucalyptus['public_ipv4']
163
- cloud[:private_ips] << eucalyptus['local_ipv4']
164
- cloud[:public_ipv4] = eucalyptus['public_ipv4']
165
- cloud[:public_hostname] = eucalyptus['public_hostname']
166
- cloud[:local_ipv4] = eucalyptus['local_ipv4']
167
- cloud[:local_hostname] = eucalyptus['local_hostname']
162
+ cloud[:public_ips] << eucalyptus["public_ipv4"]
163
+ cloud[:private_ips] << eucalyptus["local_ipv4"]
164
+ cloud[:public_ipv4] = eucalyptus["public_ipv4"]
165
+ cloud[:public_hostname] = eucalyptus["public_hostname"]
166
+ cloud[:local_ipv4] = eucalyptus["local_ipv4"]
167
+ cloud[:local_hostname] = eucalyptus["local_hostname"]
168
168
  cloud[:provider] = "eucalyptus"
169
169
  end
170
170
 
@@ -183,13 +183,13 @@ Ohai.plugin(:Cloud) do
183
183
 
184
184
  # Fill cloud hash with openstack values
185
185
  def get_openstack_values
186
- cloud[:public_ips] << openstack['public_ipv4']
187
- cloud[:private_ips] << openstack['local_ipv4']
188
- cloud[:public_ipv4] = openstack['public_ipv4']
189
- cloud[:public_hostname] = openstack['public_hostname']
190
- cloud[:local_ipv4] = openstack['local_ipv4']
191
- cloud[:local_hostname] = openstack['local_hostname']
192
- cloud[:provider] = openstack['provider']
186
+ cloud[:public_ips] << openstack["public_ipv4"]
187
+ cloud[:private_ips] << openstack["local_ipv4"]
188
+ cloud[:public_ipv4] = openstack["public_ipv4"]
189
+ cloud[:public_hostname] = openstack["public_hostname"]
190
+ cloud[:local_ipv4] = openstack["local_ipv4"]
191
+ cloud[:local_hostname] = openstack["local_hostname"]
192
+ cloud[:provider] = openstack["provider"]
193
193
  end
194
194
 
195
195
  # ----------------------------------------
@@ -208,12 +208,12 @@ Ohai.plugin(:Cloud) do
208
208
  # Fill cloud hash with azure values
209
209
  def get_azure_values
210
210
  cloud[:vm_name] = azure["vm_name"]
211
- cloud[:public_ips] << azure['public_ip']
212
- cloud[:public_ipv4] = azure['public_ip']
213
- cloud[:public_fqdn] = azure['public_fqdn']
214
- cloud[:public_hostname] = azure['public_fqdn']
215
- cloud[:public_ssh_port] = azure['public_ssh_port'] if azure['public_ssh_port']
216
- cloud[:public_winrm_port] = azure['public_winrm_port'] if azure['public_winrm_port']
211
+ cloud[:public_ips] << azure["public_ip"]
212
+ cloud[:public_ipv4] = azure["public_ip"]
213
+ cloud[:public_fqdn] = azure["public_fqdn"]
214
+ cloud[:public_hostname] = azure["public_fqdn"]
215
+ cloud[:public_ssh_port] = azure["public_ssh_port"] if azure["public_ssh_port"]
216
+ cloud[:public_winrm_port] = azure["public_winrm_port"] if azure["public_winrm_port"]
217
217
  cloud[:provider] = "azure"
218
218
  end
219
219
 
@@ -232,17 +232,17 @@ Ohai.plugin(:Cloud) do
232
232
 
233
233
  # Fill cloud hash with linode values
234
234
  def get_digital_ocean_values
235
- public_ipv4 = digital_ocean['networks']['v4'].select {|address| address['type'] == 'public'}
236
- private_ipv4 = digital_ocean['networks']['v4'].select {|address| address['type'] == 'private'}
237
- public_ipv6 = digital_ocean['networks']['v6'].select {|address| address['type'] == 'public'}
238
- private_ipv6 = digital_ocean['networks']['v6'].select {|address| address['type'] == 'private'}
239
- cloud[:public_ips].concat public_ipv4+public_ipv6
240
- cloud[:private_ips].concat private_ipv4+private_ipv6
235
+ public_ipv4 = digital_ocean["networks"]["v4"].select { |address| address["type"] == "public" }
236
+ private_ipv4 = digital_ocean["networks"]["v4"].select { |address| address["type"] == "private" }
237
+ public_ipv6 = digital_ocean["networks"]["v6"].select { |address| address["type"] == "public" }
238
+ private_ipv6 = digital_ocean["networks"]["v6"].select { |address| address["type"] == "private" }
239
+ cloud[:public_ips].concat public_ipv4 + public_ipv6
240
+ cloud[:private_ips].concat private_ipv4 + private_ipv6
241
241
  cloud[:public_ipv4] = public_ipv4.first
242
242
  cloud[:public_ipv6] = public_ipv6.first
243
243
  cloud[:local_ipv4] = private_ipv4.first
244
244
  cloud[:local_ipv6] = private_ipv6.first
245
- cloud[:public_hostname] = digital_ocean['name']
245
+ cloud[:public_hostname] = digital_ocean["name"]
246
246
  cloud[:provider] = "digital_ocean"
247
247
  end
248
248
 
@@ -261,15 +261,14 @@ Ohai.plugin(:Cloud) do
261
261
 
262
262
  # Fill cloud hash with softlayer values
263
263
  def get_softlayer_values
264
- cloud[:public_ipv4] = softlayer['public_ipv4']
265
- cloud[:local_ipv4] = softlayer['local_ipv4']
266
- cloud[:public_ips] << softlayer['public_ipv4'] if softlayer['public_ipv4']
267
- cloud[:private_ips] << softlayer['local_ipv4'] if softlayer['local_ipv4']
268
- cloud[:public_hostname] = softlayer['public_fqdn']
269
- cloud[:provider] = 'softlayer'
264
+ cloud[:public_ipv4] = softlayer["public_ipv4"]
265
+ cloud[:local_ipv4] = softlayer["local_ipv4"]
266
+ cloud[:public_ips] << softlayer["public_ipv4"] if softlayer["public_ipv4"]
267
+ cloud[:private_ips] << softlayer["local_ipv4"] if softlayer["local_ipv4"]
268
+ cloud[:public_hostname] = softlayer["public_fqdn"]
269
+ cloud[:provider] = "softlayer"
270
270
  end
271
271
 
272
-
273
272
  collect_data do
274
273
  # setup gce cloud
275
274
  if on_gce?