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
@@ -38,8 +38,8 @@ Ohai.plugin(:Platform) do
38
38
  def read_os_release_info(file)
39
39
  return nil unless File.exist?(file)
40
40
  File.read(file).split.inject({}) do |map, line|
41
- key, value = line.split('=')
42
- map[key] = value.gsub(/\A"|"\Z/, '') if value
41
+ key, value = line.split("=")
42
+ map[key] = value.gsub(/\A"|"\Z/, "") if value
43
43
  map
44
44
  end
45
45
  end
@@ -54,8 +54,8 @@ Ohai.plugin(:Platform) do
54
54
  def os_release_info
55
55
  @os_release_info ||=
56
56
  begin
57
- os_release_info = read_os_release_info('/etc/os-release')
58
- cisco_release_info = os_release_info['CISCO_RELEASE_INFO'] if os_release_info
57
+ os_release_info = read_os_release_info("/etc/os-release")
58
+ cisco_release_info = os_release_info["CISCO_RELEASE_INFO"] if os_release_info
59
59
  if cisco_release_info && File.exist?(cisco_release_info)
60
60
  os_release_info.merge!(read_os_release_info(cisco_release_info))
61
61
  end
@@ -69,7 +69,7 @@ Ohai.plugin(:Platform) do
69
69
  # @returns [Boolean] if we are Cisco according to /etc/os-release
70
70
  #
71
71
  def os_release_file_is_cisco?
72
- File.exist?('/etc/os-release') && os_release_info['CISCO_RELEASE_INFO']
72
+ File.exist?("/etc/os-release") && os_release_info["CISCO_RELEASE_INFO"]
73
73
  end
74
74
 
75
75
  collect_data(:linux) do
@@ -105,8 +105,8 @@ Ohai.plugin(:Platform) do
105
105
  platform_version contents.match(/(\d\.\d\.\d)/)[0]
106
106
  elsif File.exist?("/etc/redhat-release")
107
107
  if os_release_file_is_cisco? # Cisco guestshell
108
- platform 'nexus_centos'
109
- platform_version os_release_info['VERSION']
108
+ platform "nexus_centos"
109
+ platform_version os_release_info["VERSION"]
110
110
  else
111
111
  contents = File.read("/etc/redhat-release").chomp
112
112
  platform get_redhatish_platform(contents)
@@ -116,10 +116,10 @@ Ohai.plugin(:Platform) do
116
116
  contents = File.read("/etc/system-release").chomp
117
117
  platform get_redhatish_platform(contents)
118
118
  platform_version get_redhatish_version(contents)
119
- elsif File.exist?('/etc/gentoo-release')
119
+ elsif File.exist?("/etc/gentoo-release")
120
120
  platform "gentoo"
121
- platform_version File.read('/etc/gentoo-release').scan(/(\d+|\.+)/).join
122
- elsif File.exist?('/etc/SuSE-release')
121
+ platform_version File.read("/etc/gentoo-release").scan(/(\d+|\.+)/).join
122
+ elsif File.exist?("/etc/SuSE-release")
123
123
  suse_release = File.read("/etc/SuSE-release")
124
124
  suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
125
125
  suse_version = suse_release[/VERSION = ([\d\.]{2,})/, 1] if suse_version == ""
@@ -129,37 +129,37 @@ Ohai.plugin(:Platform) do
129
129
  else
130
130
  platform "suse"
131
131
  end
132
- elsif File.exist?('/etc/slackware-version')
132
+ elsif File.exist?("/etc/slackware-version")
133
133
  platform "slackware"
134
134
  platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
135
- elsif File.exist?('/etc/arch-release')
135
+ elsif File.exist?("/etc/arch-release")
136
136
  platform "arch"
137
137
  # no way to determine platform_version in a rolling release distribution
138
138
  # kernel release will be used - ex. 2.6.32-ARCH
139
139
  platform_version `uname -r`.strip
140
- elsif File.exist?('/etc/exherbo-release')
140
+ elsif File.exist?("/etc/exherbo-release")
141
141
  platform "exherbo"
142
142
  # no way to determine platform_version in a rolling release distribution
143
143
  # kernel release will be used - ex. 3.13
144
144
  platform_version `uname -r`.strip
145
- elsif File.exist?('/etc/alpine-release')
145
+ elsif File.exist?("/etc/alpine-release")
146
146
  platform "alpine"
147
147
  platform_version File.read("/etc/alpine-release").strip()
148
148
  elsif os_release_file_is_cisco?
149
- raise 'unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field' if
150
- os_release_info['ID_LIKE'].nil? || ! os_release_info['ID_LIKE'].include?('wrlinux')
149
+ raise "unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field" if
150
+ os_release_info["ID_LIKE"].nil? || ! os_release_info["ID_LIKE"].include?("wrlinux")
151
151
 
152
- case os_release_info['ID']
153
- when 'nexus'
154
- platform 'nexus'
155
- when 'ios_xr'
156
- platform 'ios_xr'
152
+ case os_release_info["ID"]
153
+ when "nexus"
154
+ platform "nexus"
155
+ when "ios_xr"
156
+ platform "ios_xr"
157
157
  else
158
- raise 'unknown Cisco /etc/os-release or /etc/cisco-release ID field'
158
+ raise "unknown Cisco /etc/os-release or /etc/cisco-release ID field"
159
159
  end
160
160
 
161
- platform_family 'wrlinux'
162
- platform_version os_release_info['VERSION']
161
+ platform_family "wrlinux"
162
+ platform_version os_release_info["VERSION"]
163
163
  elsif lsb[:id] =~ /RedHat/i
164
164
  platform "redhat"
165
165
  platform_version lsb[:release]
@@ -16,8 +16,8 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'ohai/util/file_helper'
20
- require 'ohai/mixin/dmi_decode'
19
+ require "ohai/util/file_helper"
20
+ require "ohai/mixin/dmi_decode"
21
21
 
22
22
  include Ohai::Util::FileHelper
23
23
  include Ohai::Mixin::DmiDecode
@@ -26,11 +26,11 @@ Ohai.plugin(:Virtualization) do
26
26
  provides "virtualization"
27
27
 
28
28
  def lxc_version_exists?
29
- which('lxc-version')
29
+ which("lxc-version")
30
30
  end
31
31
 
32
32
  def docker_exists?
33
- which('docker')
33
+ which("docker")
34
34
  end
35
35
 
36
36
  collect_data(:linux) do
@@ -118,11 +118,11 @@ Ohai.plugin(:Virtualization) do
118
118
 
119
119
  # parse dmidecode to discover various virtualization guests
120
120
  if File.exist?("/usr/sbin/dmidecode")
121
- guest = guest_from_dmi(shell_out('dmidecode').stdout)
121
+ guest = guest_from_dmi(shell_out("dmidecode").stdout)
122
122
  if guest
123
123
  virtualization[:system] = guest
124
- virtualization[:role] = 'guest'
125
- virtualization[:systems][guest.to_sym] = 'guest'
124
+ virtualization[:role] = "guest"
125
+ virtualization[:systems][guest.to_sym] = "guest"
126
126
  end
127
127
  end
128
128
 
@@ -163,7 +163,7 @@ Ohai.plugin(:Virtualization) do
163
163
  if File.exist?("/proc/self/cgroup")
164
164
  cgroup_content = File.read("/proc/self/cgroup")
165
165
  if cgroup_content =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$} ||
166
- cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-.+$}
166
+ cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-.+$}
167
167
  virtualization[:system] = $1
168
168
  virtualization[:role] = "guest"
169
169
  virtualization[:systems][$1.to_sym] = "guest"
@@ -33,7 +33,7 @@ Ohai.plugin(:Mono) do
33
33
  mono[:version] = output[4]
34
34
  end
35
35
  if output.length >= 11
36
- mono[:builddate] = "%s %s %s %s" % [output[6],output[7],output[8],output[11].gsub!(/\)/,'')]
36
+ mono[:builddate] = "%s %s %s %s" % [output[6], output[7], output[8], output[11].gsub!(/\)/, "")]
37
37
  end
38
38
  languages[:mono] = mono if mono[:version]
39
39
  end
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  Ohai.plugin(:CPU) do
20
- provides 'cpu'
20
+ provides "cpu"
21
21
 
22
22
  collect_data(:netbsd) do
23
23
  cpuinfo = Mash.new
@@ -58,7 +58,7 @@ Ohai.plugin(:Network) do
58
58
  if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
59
59
  iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
60
60
  # convert the netmask to decimal for consistency
61
- netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
61
+ netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}"
62
62
  if $3.empty?
63
63
  iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
64
64
  else
@@ -76,7 +76,7 @@ Ohai.plugin(:Network) do
76
76
  end
77
77
  end
78
78
  if line =~ /flags=\d+<(.+)>/
79
- flags = $1.split(',')
79
+ flags = $1.split(",")
80
80
  iface[cint][:flags] = flags if flags.length > 0
81
81
  end
82
82
  if line =~ /metric: (\d+) mtu: (\d+)/
@@ -16,8 +16,8 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'ipaddress'
20
- require 'ohai/mixin/network_constants'
19
+ require "ipaddress"
20
+ require "ohai/mixin/network_constants"
21
21
 
22
22
  Ohai.plugin(:NetworkAddresses) do
23
23
  include Ohai::Mixin::NetworkConstants
@@ -29,21 +29,21 @@ Ohai.plugin(:NetworkAddresses) do
29
29
  # from interface data create array of hashes with ipaddress, scope, and iface
30
30
  # sorted by scope, prefixlen and then ipaddress where longest prefixes first
31
31
  def sorted_ips(family = "inet")
32
- fail "bad family #{family}" unless %w(inet inet6).include? family
32
+ raise "bad family #{family}" unless %w{inet inet6}.include? family
33
33
 
34
34
  # priority of ipv6 link scopes to sort by later
35
35
  scope_prio = [ "global", "site", "link", "host", "node", nil ]
36
36
 
37
37
  # grab ipaddress, scope, and iface for sorting later
38
38
  ipaddresses = []
39
- Mash[network['interfaces']].each do |iface, iface_v|
40
- next if iface_v.nil? || !iface_v.has_key?('addresses')
41
- iface_v['addresses'].each do |addr, addr_v|
42
- next if addr_v.nil? or not addr_v.has_key? "family" or addr_v['family'] != family
39
+ Mash[network["interfaces"]].each do |iface, iface_v|
40
+ next if iface_v.nil? || !iface_v.has_key?("addresses")
41
+ iface_v["addresses"].each do |addr, addr_v|
42
+ next if addr_v.nil? or not addr_v.has_key? "family" or addr_v["family"] != family
43
43
  ipaddresses << {
44
44
  :ipaddress => addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"),
45
45
  :scope => addr_v["scope"].nil? ? nil : addr_v["scope"].downcase,
46
- :iface => iface
46
+ :iface => iface,
47
47
  }
48
48
  end
49
49
  end
@@ -53,7 +53,7 @@ Ohai.plugin(:NetworkAddresses) do
53
53
  ipaddresses.sort_by do |v|
54
54
  [ ( scope_prio.index(v[:scope]) || 999999 ),
55
55
  128 - v[:ipaddress].prefix.to_i,
56
- ( family == "inet" ? v[:ipaddress].to_u32 : v[:ipaddress].to_u128 )
56
+ ( family == "inet" ? v[:ipaddress].to_u32 : v[:ipaddress].to_u128 ),
57
57
  ]
58
58
  end
59
59
  end
@@ -68,7 +68,7 @@ Ohai.plugin(:NetworkAddresses) do
68
68
  return [ nil, nil ] if ips.empty?
69
69
 
70
70
  # shortcuts to access default #{family} interface and gateway
71
- int_attr = Ohai::Mixin::NetworkConstants::FAMILIES[family] +"_interface"
71
+ int_attr = Ohai::Mixin::NetworkConstants::FAMILIES[family] + "_interface"
72
72
  gw_attr = Ohai::Mixin::NetworkConstants::FAMILIES[family] + "_gateway"
73
73
 
74
74
  if network[int_attr]
@@ -113,7 +113,7 @@ Ohai.plugin(:NetworkAddresses) do
113
113
 
114
114
  # select mac address of first interface with family of lladdr
115
115
  def find_mac_from_iface(iface)
116
- r = network["interfaces"][iface]["addresses"].select{|k,v| v["family"] == "lladdr"}
116
+ r = network["interfaces"][iface]["addresses"].select { |k, v| v["family"] == "lladdr" }
117
117
  r.nil? || r.first.nil? ? nil : r.first.first
118
118
  end
119
119
 
@@ -22,35 +22,39 @@ Ohai.plugin(:NetworkListeners) do
22
22
  depends "network", "counters/network"
23
23
 
24
24
  collect_data do
25
- require 'sigar'
26
- flags = Sigar::NETCONN_TCP|Sigar::NETCONN_SERVER
25
+ begin
26
+ require "sigar"
27
+ flags = Sigar::NETCONN_TCP | Sigar::NETCONN_SERVER
27
28
 
28
- network Mash.new unless network
29
- listeners = Mash.new
29
+ network Mash.new unless network
30
+ listeners = Mash.new
30
31
 
31
- sigar = Sigar.new
32
- sigar.net_connection_list(flags).each do |conn|
33
- port = conn.local_port
34
- addr = conn.local_address.to_s
35
- if addr == "0.0.0.0" || addr == "::"
36
- addr = "*"
32
+ sigar = Sigar.new
33
+ sigar.net_connection_list(flags).each do |conn|
34
+ port = conn.local_port
35
+ addr = conn.local_address.to_s
36
+ if addr == "0.0.0.0" || addr == "::"
37
+ addr = "*"
38
+ end
39
+ listeners[port] = Mash.new
40
+ listeners[port][:address] = addr
41
+ begin
42
+ pid = sigar.proc_port(conn.type, port)
43
+ # workaround for a failure of proc_state to throw
44
+ # after the first 0 has been supplied to it
45
+ #
46
+ # no longer required when hyperic/sigar#48 is fixed
47
+ throw ArgumentError.new("No such process") if pid == 0
48
+ listeners[port][:pid] = pid
49
+ listeners[port][:name] = sigar.proc_state(pid).name
50
+ rescue
51
+ end
37
52
  end
38
- listeners[port] = Mash.new
39
- listeners[port][:address] = addr
40
- begin
41
- pid = sigar.proc_port(conn.type, port)
42
- # workaround for a failure of proc_state to throw
43
- # after the first 0 has been supplied to it
44
- #
45
- # no longer required when hyperic/sigar#48 is fixed
46
- throw ArgumentError.new("No such process") if pid == 0
47
- listeners[port][:pid] = pid
48
- listeners[port][:name] = sigar.proc_state(pid).name
49
- rescue
50
- end
51
- end
52
53
 
53
- network[:listeners] = Mash.new
54
- network[:listeners][:tcp] = listeners
54
+ network[:listeners] = Mash.new
55
+ network[:listeners][:tcp] = listeners
56
+ rescue LoadError
57
+ Ohai::Log.debug("Could not load sigar gem. Skipping NetworkListeners plugin")
58
+ end
55
59
  end
56
60
  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.
@@ -20,7 +20,7 @@ Ohai.plugin(:Ohai) do
20
20
  provides "chef_packages/ohai"
21
21
 
22
22
  collect_data do
23
- require 'ohai'
23
+ require "ohai"
24
24
 
25
25
  chef_packages Mash.new unless chef_packages
26
26
  chef_packages[:ohai] = Mash.new
@@ -17,19 +17,19 @@
17
17
  #
18
18
 
19
19
  Ohai.plugin(:CPU) do
20
- provides 'cpu'
20
+ provides "cpu"
21
21
 
22
22
  collect_data(:openbsd) do
23
23
  cpuinfo = Mash.new
24
24
 
25
- # OpenBSD provides most cpu information via sysctl, the only thing we need to
26
- # to scrape from dmesg.boot is the cpu feature list.
25
+ # OpenBSD provides most cpu information via sysctl, the only thing we need to
26
+ # to scrape from dmesg.boot is the cpu feature list.
27
27
  # cpu0: FPU,V86,DE,PSE,TSC,MSR,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,TM,SBF,EST,TM2
28
28
 
29
29
  File.open("/var/run/dmesg.boot").each do |line|
30
30
  case line
31
31
  when /cpu\d+:\s+([A-Z]+$|[A-Z]+,.*$)/
32
- cpuinfo["flags"] = $1.downcase.split(',')
32
+ cpuinfo["flags"] = $1.downcase.split(",")
33
33
  end
34
34
  end
35
35
 
@@ -71,13 +71,13 @@ Ohai.plugin(:Memory) do
71
71
  memory[:page_count] = $1
72
72
  memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
73
73
  when /(\d+) pages free/
74
- memory[:free] = memory[:page_size].to_i * $1.to_i
74
+ memory[:free] = memory[:page_size].to_i * $1.to_i
75
75
  when /(\d+) pages active/
76
- memory[:active] = memory[:page_size].to_i * $1.to_i
76
+ memory[:active] = memory[:page_size].to_i * $1.to_i
77
77
  when /(\d+) pages inactive/
78
- memory[:inactive] = memory[:page_size].to_i * $1.to_i
78
+ memory[:inactive] = memory[:page_size].to_i * $1.to_i
79
79
  when /(\d+) pages wired/
80
- memory[:wired] = memory[:page_size].to_i * $1.to_i
80
+ memory[:wired] = memory[:page_size].to_i * $1.to_i
81
81
  end
82
82
  end
83
83
 
@@ -58,7 +58,7 @@ Ohai.plugin(:Network) do
58
58
  if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
59
59
  iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
60
60
  # convert the netmask to decimal for consistency
61
- netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
61
+ netmask = "#{$2[2, 2].hex}.#{$2[4, 2].hex}.#{$2[6, 2].hex}.#{$2[8, 2].hex}"
62
62
  if $3.empty?
63
63
  iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
64
64
  else
@@ -76,7 +76,7 @@ Ohai.plugin(:Network) do
76
76
  end
77
77
  end
78
78
  if line =~ /flags=\d+<(.+)>/
79
- flags = $1.split(',')
79
+ flags = $1.split(",")
80
80
  iface[cint][:flags] = flags if flags.length > 0
81
81
  end
82
82
  if line =~ /metric: (\d+) mtu: (\d+)/
@@ -100,7 +100,7 @@ Ohai.plugin(:Network) do
100
100
  # From netstat(1), not sure of the implications:
101
101
  # Show the state of all network interfaces or a single interface
102
102
  # which have been auto-configured (interfaces statically configured
103
- # into a system, but not located at boot time are not shown).
103
+ # into a system, but not located at boot time are not shown).
104
104
  so = shell_out("netstat -idn")
105
105
  so.stdout.lines do |line|
106
106
  # Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop
@@ -15,22 +15,22 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
 
18
- require 'ohai/mixin/ec2_metadata'
18
+ require "ohai/mixin/ec2_metadata"
19
19
 
20
20
  Ohai.plugin(:Openstack) do
21
21
  provides "openstack"
22
22
 
23
23
  include Ohai::Mixin::Ec2Metadata
24
24
 
25
- def collect_openstack_metadata(addr = Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, api_version = '2013-04-04')
25
+ def collect_openstack_metadata(addr = Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, api_version = "2013-04-04")
26
26
  path = "/openstack/#{api_version}/meta_data.json"
27
27
  uri = "http://#{addr}#{path}"
28
28
  begin
29
- response = http_client.get_response(URI.parse(uri),nil,nil)
29
+ response = http_client.get_response(URI.parse(uri), nil, nil)
30
30
  case response.code
31
- when '200'
31
+ when "200"
32
32
  FFI_Yajl::Parser.parse(response.body)
33
- when '404'
33
+ when "404"
34
34
  Ohai::Log.debug("Encountered 404 response retreiving OpenStack specific metadata path: #{path} ; continuing.")
35
35
  nil
36
36
  else
@@ -44,20 +44,20 @@ Ohai.plugin(:Openstack) do
44
44
 
45
45
  collect_data do
46
46
  # Adds openstack Mash
47
- if hint?('openstack') || hint?('hp')
47
+ if hint?("openstack") || hint?("hp")
48
48
  Ohai::Log.debug("ohai openstack")
49
49
 
50
- if can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR,80)
50
+ if can_metadata_connect?(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80)
51
51
  openstack Mash.new
52
52
  Ohai::Log.debug("connecting to the OpenStack metadata service")
53
- fetch_metadata.each {|k, v| openstack[k] = v }
53
+ fetch_metadata.each { |k, v| openstack[k] = v }
54
54
 
55
- if hint?('hp')
56
- openstack['provider'] = 'hp'
55
+ if hint?("hp")
56
+ openstack["provider"] = "hp"
57
57
  else
58
- openstack['provider'] = 'openstack'
58
+ openstack["provider"] = "openstack"
59
59
  Ohai::Log.debug("connecting to the OpenStack specific metadata service")
60
- openstack['metadata'] = collect_openstack_metadata
60
+ openstack["metadata"] = collect_openstack_metadata
61
61
  end
62
62
 
63
63
  else