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
@@ -22,9 +22,9 @@ Ohai.plugin(:Virtualization) do
22
22
  provides "virtualization"
23
23
 
24
24
  def collect_solaris_guestid
25
- command = '/usr/sbin/zoneadm list -p'
25
+ command = "/usr/sbin/zoneadm list -p"
26
26
  so = shell_out(command)
27
- so.stdout.split(':').first
27
+ so.stdout.split(":").first
28
28
  end
29
29
 
30
30
  collect_data(:solaris2) do
@@ -41,7 +41,7 @@ Ohai.plugin(:Virtualization) do
41
41
  end
42
42
 
43
43
  # http://www.dmo.ca/blog/detecting-virtualization-on-linux
44
- smbios_path= Ohai.abs_path( "/usr/sbin/smbios" )
44
+ smbios_path = Ohai.abs_path( "/usr/sbin/smbios" )
45
45
  if File.exists?(smbios_path)
46
46
  so = shell_out(smbios_path)
47
47
  case so.stdout
@@ -60,32 +60,32 @@ Ohai.plugin(:Virtualization) do
60
60
  end
61
61
  end
62
62
 
63
- if File.executable?('/usr/sbin/zoneadm')
63
+ if File.executable?("/usr/sbin/zoneadm")
64
64
  zones = Mash.new
65
65
  so = shell_out("zoneadm list -pc")
66
66
  so.stdout.lines do |line|
67
67
  info = line.chomp.split(/:/)
68
68
  zones[info[1]] = {
69
- 'id' => info[0],
70
- 'state' => info[2],
71
- 'root' => info[3],
72
- 'uuid' => info[4],
73
- 'brand' => info[5],
74
- 'ip' => info[6],
69
+ "id" => info[0],
70
+ "state" => info[2],
71
+ "root" => info[3],
72
+ "uuid" => info[4],
73
+ "brand" => info[5],
74
+ "ip" => info[6],
75
75
  }
76
76
  end
77
77
 
78
- if (zones.length == 1)
78
+ if zones.length == 1
79
79
  first_zone = zones.keys[0]
80
- unless( first_zone == 'global')
81
- virtualization[:system] = 'zone'
82
- virtualization[:role] = 'guest'
83
- virtualization[:guest_uuid] = zones[first_zone]['uuid']
80
+ unless( first_zone == "global")
81
+ virtualization[:system] = "zone"
82
+ virtualization[:role] = "guest"
83
+ virtualization[:guest_uuid] = zones[first_zone]["uuid"]
84
84
  virtualization[:guest_id] = collect_solaris_guestid
85
85
  end
86
- elsif (zones.length > 1)
87
- virtualization[:system] = 'zone'
88
- virtualization[:role] = 'host'
86
+ elsif zones.length > 1
87
+ virtualization[:system] = "zone"
88
+ virtualization[:role] = "host"
89
89
  virtualization[:guests] = zones
90
90
  end
91
91
  end
@@ -39,7 +39,7 @@ Ohai.plugin(:Zpools) do
39
39
  end
40
40
 
41
41
  # Grab individual health for devices in the zpools
42
- for pool in pools.keys
42
+ pools.keys.each do |pool|
43
43
  pools[pool][:devices] = Mash.new
44
44
  # Run "zpool status" as non-root user (adm) so that
45
45
  # the command won't try to open() each device which can
@@ -28,8 +28,8 @@ Ohai.plugin(:SSHHostKey) do
28
28
  [ "rsa", nil ]
29
29
  when /^ecdsa/
30
30
  [ "ecdsa", content[0] ]
31
- when 'ssh-ed25519'
32
- [ 'ed25519', nil ]
31
+ when "ssh-ed25519"
32
+ [ "ed25519", nil ]
33
33
  else
34
34
  [ nil, nil ]
35
35
  end
@@ -24,7 +24,7 @@
24
24
  # limitations under the License.
25
25
  #
26
26
 
27
- require 'ohai/mixin/seconds_to_human'
27
+ require "ohai/mixin/seconds_to_human"
28
28
 
29
29
  Ohai.plugin(:Uptime) do
30
30
  provides "uptime", "uptime_seconds"
@@ -43,7 +43,7 @@ Ohai.plugin(:Uptime) do
43
43
  end
44
44
 
45
45
  collect_data(:hpux, :default) do
46
- require 'sigar'
46
+ require "sigar"
47
47
 
48
48
  sigar = Sigar.new
49
49
  uptime = sigar.uptime.uptime
@@ -94,11 +94,10 @@ Ohai.plugin(:Uptime) do
94
94
  end
95
95
 
96
96
  collect_data(:windows) do
97
- require 'wmi-lite/wmi'
97
+ require "wmi-lite/wmi"
98
98
  wmi = WmiLite::Wmi.new
99
- uptime_seconds wmi.first_of('Win32_PerfFormattedData_PerfOS_System')['systemuptime'].to_i
99
+ uptime_seconds wmi.first_of("Win32_PerfFormattedData_PerfOS_System")["systemuptime"].to_i
100
100
  uptime seconds_to_human(uptime_seconds)
101
101
  end
102
102
 
103
103
  end
104
-
@@ -17,10 +17,10 @@
17
17
  #
18
18
 
19
19
  Ohai.plugin(:Virtualbox) do
20
- provides 'virtualbox'
20
+ provides "virtualbox"
21
21
 
22
22
  collect_data do
23
- so = shell_out('VBoxControl guestproperty enumerate')
23
+ so = shell_out("VBoxControl guestproperty enumerate")
24
24
  if so.exitstatus == 0
25
25
  virtualbox Mash.new
26
26
  virtualbox[:host] = Mash.new
@@ -24,31 +24,31 @@ Ohai.plugin(:VirtualizationInfo) do
24
24
  collect_data do
25
25
  unless virtualization.nil? || !(virtualization[:role].eql?("host"))
26
26
  begin
27
- require 'libvirt'
28
- require 'hpricot'
27
+ require "libvirt"
28
+ require "hpricot"
29
29
 
30
- emu = (virtualization[:system].eql?('kvm') ? 'qemu' : virtualization[:system])
31
- virtualization[:libvirt_version] = Libvirt::version(emu)[0].to_s
30
+ emu = (virtualization[:system].eql?("kvm") ? "qemu" : virtualization[:system])
31
+ virtualization[:libvirt_version] = Libvirt.version(emu)[0].to_s
32
32
 
33
- virtconn = Libvirt::open_read_only("#{emu}:///system")
33
+ virtconn = Libvirt.open_read_only("#{emu}:///system")
34
34
 
35
35
  virtualization[:uri] = virtconn.uri
36
36
  virtualization[:capabilities] = Mash.new
37
- virtualization[:capabilities][:xml_desc] = (virtconn.capabilities.split("\n").collect {|line| line.strip}).join
37
+ virtualization[:capabilities][:xml_desc] = (virtconn.capabilities.split("\n").collect { |line| line.strip }).join
38
38
  #xdoc = Hpricot virtualization[:capabilities][:xml_desc]
39
39
 
40
40
  virtualization[:nodeinfo] = Mash.new
41
41
  ni = virtconn.node_get_info
42
- ['cores','cpus','memory','mhz','model','nodes','sockets','threads'].each {|a| virtualization[:nodeinfo][a] = ni.send(a)}
42
+ %w{cores cpus memory mhz model nodes sockets threads}.each { |a| virtualization[:nodeinfo][a] = ni.send(a) }
43
43
 
44
44
  virtualization[:domains] = Mash.new
45
45
  virtconn.list_domains.each do |d|
46
46
  dv = virtconn.lookup_domain_by_id d
47
47
  virtualization[:domains][dv.name] = Mash.new
48
48
  virtualization[:domains][dv.name][:id] = d
49
- virtualization[:domains][dv.name][:xml_desc] = (dv.xml_desc.split("\n").collect {|line| line.strip}).join
50
- ['os_type','uuid'].each {|a| virtualization[:domains][dv.name][a] = dv.send(a)}
51
- ['cpu_time','max_mem','memory','nr_virt_cpu','state'].each {|a| virtualization[:domains][dv.name][a] = dv.info.send(a)}
49
+ virtualization[:domains][dv.name][:xml_desc] = (dv.xml_desc.split("\n").collect { |line| line.strip }).join
50
+ %w{os_type uuid}.each { |a| virtualization[:domains][dv.name][a] = dv.send(a) }
51
+ %w{cpu_time max_mem memory nr_virt_cpu state}.each { |a| virtualization[:domains][dv.name][a] = dv.info.send(a) }
52
52
  #xdoc = Hpricot virtualization[:domains][dv.name][:xml_desc]
53
53
 
54
54
  end
@@ -57,8 +57,8 @@ Ohai.plugin(:VirtualizationInfo) do
57
57
  virtconn.list_networks.each do |n|
58
58
  nv = virtconn.lookup_network_by_name n
59
59
  virtualization[:networks][n] = Mash.new
60
- virtualization[:networks][n][:xml_desc] = (nv.xml_desc.split("\n").collect {|line| line.strip}).join
61
- ['bridge_name','uuid'].each {|a| virtualization[:networks][n][a] = nv.send(a)}
60
+ virtualization[:networks][n][:xml_desc] = (nv.xml_desc.split("\n").collect { |line| line.strip }).join
61
+ %w{bridge_name uuid}.each { |a| virtualization[:networks][n][a] = nv.send(a) }
62
62
  #xdoc = Hpricot virtualization[:networks][n][:xml_desc]
63
63
 
64
64
  end
@@ -67,17 +67,17 @@ Ohai.plugin(:VirtualizationInfo) do
67
67
  virtconn.list_storage_pools.each do |pool|
68
68
  sp = virtconn.lookup_storage_pool_by_name pool
69
69
  virtualization[:storage][pool] = Mash.new
70
- virtualization[:storage][pool][:xml_desc] = (sp.xml_desc.split("\n").collect {|line| line.strip}).join
71
- ['autostart','uuid'].each {|a| virtualization[:storage][pool][a] = sp.send(a)}
72
- ['allocation','available','capacity','state'].each {|a| virtualization[:storage][pool][a] = sp.info.send(a)}
70
+ virtualization[:storage][pool][:xml_desc] = (sp.xml_desc.split("\n").collect { |line| line.strip }).join
71
+ %w{autostart uuid}.each { |a| virtualization[:storage][pool][a] = sp.send(a) }
72
+ %w{allocation available capacity state}.each { |a| virtualization[:storage][pool][a] = sp.info.send(a) }
73
73
  #xdoc = Hpricot virtualization[:storage][pool][:xml_desc]
74
74
 
75
75
  virtualization[:storage][pool][:volumes] = Mash.new
76
76
  sp.list_volumes.each do |v|
77
77
  virtualization[:storage][pool][:volumes][v] = Mash.new
78
78
  sv = sp.lookup_volume_by_name v
79
- ['key','name','path'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a)}
80
- ['allocation','capacity','type'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a)}
79
+ %w{key name path}.each { |a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a) }
80
+ %w{allocation capacity type}.each { |a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a) }
81
81
  end
82
82
  end
83
83
 
@@ -49,7 +49,7 @@ Ohai.plugin(:VMware) do
49
49
  # vmware-toolbox-cmd stat <param> commands
50
50
  # Iterate through each parameter supported by the "vwware-toolbox-cmd stat" command, assign value
51
51
  # to attribute "vmware[:<parameter>]"
52
- [ "hosttime", "speed", "sessionid", "balloon", "swap", "memlimit", "memres", "cpures", "cpulimit" ].each do |param|
52
+ %w{hosttime speed sessionid balloon swap memlimit memres cpures cpulimit}.each do |param|
53
53
  vmware[param] = from_cmd("#{vmtools_path} stat #{param}")
54
54
  if vmware[param] =~ /UpdateInfo failed/
55
55
  vmware[param] = nil
@@ -58,7 +58,7 @@ Ohai.plugin(:VMware) do
58
58
  # vmware-toolbox-cmd <param> status commands
59
59
  # Iterate through each parameter supported by the "vwware-toolbox-cmd status" command, assign value
60
60
  # to attribute "vmware[:<parameter>]"
61
- [ "upgrade", "timesync" ].each do |param|
61
+ %w{upgrade timesync}.each do |param|
62
62
  vmware[param] = from_cmd("#{vmtools_path} #{param} status")
63
63
  end
64
64
  rescue
@@ -20,14 +20,14 @@ Ohai.plugin(:CPU) do
20
20
  provides "cpu"
21
21
 
22
22
  collect_data(:windows) do
23
- require 'wmi-lite/wmi'
23
+ require "wmi-lite/wmi"
24
24
 
25
25
  cpu Mash.new
26
26
  cores = 0
27
27
  logical_processors = 0
28
28
 
29
29
  wmi = WmiLite::Wmi.new
30
- processors = wmi.instances_of('Win32_Processor')
30
+ processors = wmi.instances_of("Win32_Processor")
31
31
 
32
32
  processors.each_with_index do |processor, index|
33
33
  current_cpu = index.to_s
@@ -43,23 +43,23 @@ Ohai.plugin(:CPU) do
43
43
  #
44
44
 
45
45
  begin
46
- cpu[current_cpu]["cores"] = processor['numberofcores']
47
- cores += processor['numberofcores']
46
+ cpu[current_cpu]["cores"] = processor["numberofcores"]
47
+ cores += processor["numberofcores"]
48
48
  rescue NoMethodError => e
49
49
  Ohai::Log.info("Can not find numberofcores property on Win32_Processor. Consider applying this patch: http://support.microsoft.com/kb/932370")
50
50
  cpu[current_cpu]["cores"] = nil
51
51
  end
52
52
 
53
- logical_processors += processor['numberoflogicalprocessors']
54
- cpu[current_cpu]["vendor_id"] = processor['manufacturer']
55
- cpu[current_cpu]["family"] = processor['family'].to_s
56
- cpu[current_cpu]["model"] = processor['revision'].to_s
57
- cpu[current_cpu]["stepping"] = processor['stepping'].nil? \
58
- ? processor['description'].match(/Stepping\s+(\d+)/)[1] \
59
- : processor['stepping']
60
- cpu[current_cpu]["physical_id"] = processor['deviceid']
61
- cpu[current_cpu]["model_name"] = processor['description']
62
- cpu[current_cpu]["mhz"] = processor['maxclockspeed'].to_s
53
+ logical_processors += processor["numberoflogicalprocessors"]
54
+ cpu[current_cpu]["vendor_id"] = processor["manufacturer"]
55
+ cpu[current_cpu]["family"] = processor["family"].to_s
56
+ cpu[current_cpu]["model"] = processor["revision"].to_s
57
+ cpu[current_cpu]["stepping"] = processor["stepping"].nil? \
58
+ ? processor["description"].match(/Stepping\s+(\d+)/)[1] \
59
+ : processor["stepping"]
60
+ cpu[current_cpu]["physical_id"] = processor["deviceid"]
61
+ cpu[current_cpu]["model_name"] = processor["description"]
62
+ cpu[current_cpu]["mhz"] = processor["maxclockspeed"].to_s
63
63
  cpu[current_cpu]["cache_size"] = "#{processor['l2cachesize']} KB"
64
64
  end
65
65
 
@@ -22,23 +22,23 @@ Ohai.plugin(:Drivers) do
22
22
  collect_data(:windows) do
23
23
  if configuration(:enabled)
24
24
 
25
- require 'wmi-lite/wmi'
25
+ require "wmi-lite/wmi"
26
26
 
27
27
  kext = Mash.new
28
28
  pnp_drivers = Mash.new
29
29
 
30
30
  wmi = WmiLite::Wmi.new
31
31
 
32
- drivers = wmi.instances_of('Win32_PnPSignedDriver')
32
+ drivers = wmi.instances_of("Win32_PnPSignedDriver")
33
33
  drivers.each do |driver|
34
- pnp_drivers[driver['deviceid']] = Mash.new
34
+ pnp_drivers[driver["deviceid"]] = Mash.new
35
35
  driver.wmi_ole_object.properties_.each do |p|
36
- pnp_drivers[driver['deviceid']][p.name.wmi_underscore.to_sym] = driver[p.name.downcase]
36
+ pnp_drivers[driver["deviceid"]][p.name.wmi_underscore.to_sym] = driver[p.name.downcase]
37
37
  end
38
- if driver['devicename']
39
- kext[driver['devicename']] = pnp_drivers[driver['deviceid']]
40
- kext[driver['devicename']][:version] = pnp_drivers[driver['deviceid']][:driver_version]
41
- kext[driver['devicename']][:date] = pnp_drivers[driver['deviceid']][:driver_date] ? pnp_drivers[driver['deviceid']][:driver_date].to_s[0..7] : nil
38
+ if driver["devicename"]
39
+ kext[driver["devicename"]] = pnp_drivers[driver["deviceid"]]
40
+ kext[driver["devicename"]][:version] = pnp_drivers[driver["deviceid"]][:driver_version]
41
+ kext[driver["devicename"]][:date] = pnp_drivers[driver["deviceid"]][:driver_date] ? pnp_drivers[driver["deviceid"]][:driver_date].to_s[0..7] : nil
42
42
  end
43
43
  end
44
44
 
@@ -21,7 +21,7 @@ Ohai.plugin(:Filesystem) do
21
21
 
22
22
  collect_data(:windows) do
23
23
 
24
- require 'wmi-lite/wmi'
24
+ require "wmi-lite/wmi"
25
25
 
26
26
  fs = Mash.new
27
27
  ld_info = Mash.new
@@ -30,10 +30,10 @@ Ohai.plugin(:Filesystem) do
30
30
 
31
31
  # Grab filesystem data from WMI
32
32
  # Note: we should really be parsing Win32_Volume and Win32_Mapped drive
33
- disks = wmi.instances_of('Win32_LogicalDisk')
33
+ disks = wmi.instances_of("Win32_LogicalDisk")
34
34
 
35
35
  disks.each do |disk|
36
- filesystem = disk['deviceid']
36
+ filesystem = disk["deviceid"]
37
37
  fs[filesystem] = Mash.new
38
38
  ld_info[filesystem] = Mash.new
39
39
  disk.wmi_ole_object.properties_.each do |p|
@@ -42,7 +42,7 @@ Ohai.plugin(:Filesystem) do
42
42
  fs[filesystem][:kb_size] = ld_info[filesystem][:size].to_i / 1000
43
43
  fs[filesystem][:kb_available] = ld_info[filesystem][:free_space].to_i / 1000
44
44
  fs[filesystem][:kb_used] = fs[filesystem][:kb_size].to_i - fs[filesystem][:kb_available].to_i
45
- fs[filesystem][:percent_used] = (fs[filesystem][:kb_size].to_i != 0 ? fs[filesystem][:kb_used].to_i * 100 / fs[filesystem][:kb_size].to_i : 0)
45
+ fs[filesystem][:percent_used] = (fs[filesystem][:kb_size].to_i != 0 ? fs[filesystem][:kb_used].to_i * 100 / fs[filesystem][:kb_size].to_i : 0)
46
46
  fs[filesystem][:mount] = ld_info[filesystem][:name]
47
47
  fs[filesystem][:fs_type] = ld_info[filesystem][:file_system].downcase unless ld_info[filesystem][:file_system] == nil
48
48
  fs[filesystem][:volume_name] = ld_info[filesystem][:volume_name]
@@ -35,4 +35,4 @@ Ohai.plugin(:Memory) do
35
35
  # SwapFree
36
36
  memory[:swap][:free] = os["FreeSpaceInPagingFiles"] + "kB"
37
37
  end
38
- end
38
+ end
@@ -27,7 +27,7 @@ Ohai.plugin(:Network) do
27
27
 
28
28
  collect_data(:windows) do
29
29
 
30
- require 'wmi-lite/wmi'
30
+ require "wmi-lite/wmi"
31
31
 
32
32
  iface = Mash.new
33
33
  iface_config = Mash.new
@@ -40,11 +40,11 @@ Ohai.plugin(:Network) do
40
40
  # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394217%28v=vs.85%29.aspx
41
41
  wmi = WmiLite::Wmi.new
42
42
 
43
- adapters = wmi.instances_of('Win32_NetworkAdapterConfiguration')
43
+ adapters = wmi.instances_of("Win32_NetworkAdapterConfiguration")
44
44
 
45
45
  adapters.each do |adapter|
46
46
 
47
- i = adapter['index']
47
+ i = adapter["index"]
48
48
  iface_config[i] = Mash.new
49
49
  adapter.wmi_ole_object.properties_.each do |p|
50
50
  iface_config[i][p.name.wmi_underscore.to_sym] = adapter[p.name.downcase]
@@ -53,10 +53,10 @@ Ohai.plugin(:Network) do
53
53
 
54
54
  # http://msdn.microsoft.com/en-us/library/windows/desktop/aa394216(v=vs.85).aspx
55
55
 
56
- adapters = wmi.instances_of('Win32_NetworkAdapter')
56
+ adapters = wmi.instances_of("Win32_NetworkAdapter")
57
57
 
58
58
  adapters.each do |adapter|
59
- i = adapter['index']
59
+ i = adapter["index"]
60
60
  iface_instance[i] = Mash.new
61
61
  adapter.wmi_ole_object.properties_.each do |p|
62
62
  iface_instance[i][p.name.wmi_underscore.to_sym] = adapter[p.name.downcase]
@@ -76,7 +76,7 @@ Ohai.plugin(:Network) do
76
76
  ip = iface[cint][:configuration][:ip_address][i]
77
77
  _ip = IPAddress("#{ip}/#{iface[cint][:configuration][:ip_subnet][i]}")
78
78
  iface[cint][:addresses][ip] = Mash.new(
79
- :prefixlen => _ip.prefix
79
+ :prefixlen => _ip.prefix,
80
80
  )
81
81
  if _ip.ipv6?
82
82
  # inet6 address
@@ -84,7 +84,7 @@ Ohai.plugin(:Network) do
84
84
  iface[cint][:addresses][ip][:scope] = "Link" if ip =~ /^fe80/i
85
85
  else
86
86
  # should be an inet4 address
87
- iface[cint][:addresses][ip][:netmask] = _ip.netmask.to_s
87
+ iface[cint][:addresses][ip][:netmask] = _ip.netmask.to_s
88
88
  if iface[cint][:configuration][:ip_use_zero_broadcast]
89
89
  iface[cint][:addresses][ip][:broadcast] = _ip.network.to_s
90
90
  else
@@ -96,7 +96,7 @@ Ohai.plugin(:Network) do
96
96
  # Apparently you can have more than one mac_address? Odd.
97
97
  [iface[cint][:configuration][:mac_address]].flatten.each do |mac_addr|
98
98
  iface[cint][:addresses][mac_addr] = {
99
- "family" => "lladdr"
99
+ "family" => "lladdr"
100
100
  }
101
101
  end
102
102
  iface[cint][:mtu] = iface[cint][:configuration][:mtu]
@@ -110,7 +110,7 @@ Ohai.plugin(:Network) do
110
110
  end
111
111
  end
112
112
 
113
- cint=nil
113
+ cint = nil
114
114
  so = shell_out("arp -a")
115
115
  if so.exitstatus == 0
116
116
  so.stdout.lines do |line|
@@ -119,7 +119,7 @@ Ohai.plugin(:Network) do
119
119
  end
120
120
  next unless iface[cint]
121
121
  if line =~ /^\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+([a-fA-F0-9\:-]+)/
122
- iface[cint][:arp][$1] = $2.gsub("-",":").downcase
122
+ iface[cint][:arp][$1] = $2.gsub("-", ":").downcase
123
123
  end
124
124
  end
125
125
  end
@@ -27,8 +27,7 @@ Ohai.plugin(:Platform) do
27
27
 
28
28
  collect_data(:windows) do
29
29
  platform os
30
- platform_version kernel['release']
30
+ platform_version kernel["release"]
31
31
  platform_family "windows"
32
32
  end
33
33
  end
34
-
@@ -19,38 +19,38 @@
19
19
  #
20
20
 
21
21
  Ohai.plugin(:Virtualization) do
22
- provides 'virtualization'
22
+ provides "virtualization"
23
23
 
24
24
  collect_data(:windows) do
25
- require 'wmi-lite/wmi'
25
+ require "wmi-lite/wmi"
26
26
 
27
27
  virtualization Mash.new unless virtualization
28
28
  virtualization[:systems] = Mash.new unless virtualization[:systems]
29
29
 
30
30
  # Grab BIOS data from WMI to determine vendor information
31
31
  wmi = WmiLite::Wmi.new
32
- bios = wmi.instances_of('Win32_BIOS')
32
+ bios = wmi.instances_of("Win32_BIOS")
33
33
 
34
- case bios[0]['manufacturer']
35
- when 'innotek GmbH'
36
- virtualization[:system] = 'vbox'
37
- virtualization[:role] = 'guest'
38
- virtualization[:systems][:vbox] = 'guest'
39
- when 'Parallels Software International Inc.'
40
- virtualization[:system] = 'parallels'
41
- virtualization[:role] = 'guest'
42
- virtualization[:systems][:parallels] = 'guest'
43
- when 'Bochs'
34
+ case bios[0]["manufacturer"]
35
+ when "innotek GmbH"
36
+ virtualization[:system] = "vbox"
37
+ virtualization[:role] = "guest"
38
+ virtualization[:systems][:vbox] = "guest"
39
+ when "Parallels Software International Inc."
40
+ virtualization[:system] = "parallels"
41
+ virtualization[:role] = "guest"
42
+ virtualization[:systems][:parallels] = "guest"
43
+ when "Bochs"
44
44
  virtualization[:system] = "kvm"
45
45
  virtualization[:role] = "guest"
46
46
  virtualization[:systems][:kvm] = "guest"
47
47
  end
48
48
 
49
49
  # vmware fusion detection
50
- if bios[0]['serialnumber'] =~ /VMware/
51
- virtualization[:system] = 'vmware'
52
- virtualization[:role] = 'guest'
53
- virtualization[:systems][:vmware] = 'guest'
50
+ if bios[0]["serialnumber"] =~ /VMware/
51
+ virtualization[:system] = "vmware"
52
+ virtualization[:role] = "guest"
53
+ virtualization[:systems][:vmware] = "guest"
54
54
  end
55
55
  end
56
56
  end