ohai 13.12.6 → 14.0.28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -12
  3. data/README.md +7 -12
  4. data/Rakefile +16 -23
  5. data/docs/man/man1/ohai.1 +97 -0
  6. data/lib/ohai/application.rb +9 -4
  7. data/lib/ohai/common/dmi.rb +4 -16
  8. data/lib/ohai/config.rb +5 -1
  9. data/lib/ohai/dsl.rb +0 -1
  10. data/lib/ohai/dsl/plugin.rb +12 -16
  11. data/lib/ohai/dsl/plugin/versionvii.rb +17 -5
  12. data/lib/ohai/hints.rb +2 -2
  13. data/lib/ohai/loader.rb +21 -70
  14. data/lib/ohai/log.rb +1 -1
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -4
  16. data/lib/ohai/mixin/command.rb +3 -3
  17. data/lib/ohai/mixin/dmi_decode.rb +0 -2
  18. data/lib/ohai/mixin/do_metadata.rb +1 -1
  19. data/lib/ohai/mixin/ec2_metadata.rb +8 -8
  20. data/lib/ohai/mixin/gce_metadata.rb +1 -5
  21. data/lib/ohai/mixin/http_helper.rb +3 -3
  22. data/lib/ohai/mixin/scaleway_metadata.rb +46 -0
  23. data/lib/ohai/mixin/softlayer_metadata.rb +3 -3
  24. data/lib/ohai/plugins/aix/filesystem.rb +1 -1
  25. data/lib/ohai/plugins/aix/memory.rb +1 -1
  26. data/lib/ohai/plugins/aix/network.rb +2 -2
  27. data/lib/ohai/plugins/aix/virtualization.rb +1 -1
  28. data/lib/ohai/plugins/azure.rb +5 -5
  29. data/lib/ohai/plugins/bsd/virtualization.rb +11 -11
  30. data/lib/ohai/plugins/c.rb +8 -8
  31. data/lib/ohai/plugins/chef.rb +2 -1
  32. data/lib/ohai/plugins/cloud.rb +0 -3
  33. data/lib/ohai/plugins/darwin/cpu.rb +2 -2
  34. data/lib/ohai/plugins/darwin/filesystem.rb +0 -2
  35. data/lib/ohai/plugins/darwin/hardware.rb +9 -3
  36. data/lib/ohai/plugins/darwin/network.rb +2 -2
  37. data/lib/ohai/plugins/darwin/system_profiler.rb +19 -19
  38. data/lib/ohai/plugins/darwin/virtualization.rb +10 -0
  39. data/lib/ohai/plugins/digital_ocean.rb +4 -4
  40. data/lib/ohai/plugins/dmi.rb +15 -14
  41. data/lib/ohai/plugins/docker.rb +57 -0
  42. data/lib/ohai/plugins/ec2.rb +11 -11
  43. data/lib/ohai/plugins/elixir.rb +1 -1
  44. data/lib/ohai/plugins/erlang.rb +2 -2
  45. data/lib/ohai/plugins/eucalyptus.rb +5 -5
  46. data/lib/ohai/plugins/gce.rb +2 -2
  47. data/lib/ohai/plugins/go.rb +1 -1
  48. data/lib/ohai/plugins/groovy.rb +1 -1
  49. data/lib/ohai/plugins/haskell.rb +4 -4
  50. data/lib/ohai/plugins/hostname.rb +6 -6
  51. data/lib/ohai/plugins/init_package.rb +1 -1
  52. data/lib/ohai/plugins/java.rb +1 -1
  53. data/lib/ohai/plugins/kernel.rb +109 -40
  54. data/lib/ohai/plugins/libvirt.rb +113 -0
  55. data/lib/ohai/plugins/linode.rb +4 -4
  56. data/lib/ohai/plugins/linux/block_device.rb +4 -4
  57. data/lib/ohai/plugins/linux/cpu.rb +3 -3
  58. data/lib/ohai/plugins/linux/filesystem.rb +4 -6
  59. data/lib/ohai/plugins/linux/lsb.rb +3 -3
  60. data/lib/ohai/plugins/linux/lspci.rb +2 -1
  61. data/lib/ohai/plugins/linux/machineid.rb +4 -4
  62. data/lib/ohai/plugins/linux/network.rb +16 -16
  63. data/lib/ohai/plugins/linux/platform.rb +4 -10
  64. data/lib/ohai/plugins/linux/sessions.rb +2 -1
  65. data/lib/ohai/plugins/linux/virtualization.rb +53 -31
  66. data/lib/ohai/plugins/lua.rb +1 -1
  67. data/lib/ohai/plugins/mono.rb +2 -2
  68. data/lib/ohai/plugins/network.rb +11 -11
  69. data/lib/ohai/plugins/nodejs.rb +1 -1
  70. data/lib/ohai/plugins/ohai.rb +0 -2
  71. data/lib/ohai/plugins/openstack.rb +7 -10
  72. data/lib/ohai/plugins/packages.rb +1 -1
  73. data/lib/ohai/plugins/passwd.rb +1 -0
  74. data/lib/ohai/plugins/perl.rb +1 -1
  75. data/lib/ohai/plugins/php.rb +1 -1
  76. data/lib/ohai/plugins/powershell.rb +1 -1
  77. data/lib/ohai/plugins/python.rb +1 -1
  78. data/lib/ohai/plugins/rackspace.rb +5 -5
  79. data/lib/ohai/plugins/root_group.rb +6 -9
  80. data/lib/ohai/plugins/ruby.rb +2 -2
  81. data/lib/ohai/plugins/rust.rb +1 -1
  82. data/lib/ohai/plugins/scala.rb +1 -1
  83. data/lib/ohai/plugins/scaleway.rb +56 -0
  84. data/lib/ohai/plugins/shard.rb +1 -0
  85. data/lib/ohai/plugins/softlayer.rb +2 -2
  86. data/lib/ohai/plugins/solaris2/cpu.rb +1 -1
  87. data/lib/ohai/plugins/solaris2/dmi.rb +13 -13
  88. data/lib/ohai/plugins/solaris2/network.rb +6 -6
  89. data/lib/ohai/plugins/solaris2/platform.rb +2 -2
  90. data/lib/ohai/plugins/ssh_host_key.rb +7 -7
  91. data/lib/ohai/plugins/uptime.rb +2 -7
  92. data/lib/ohai/plugins/virtualbox.rb +1 -1
  93. data/lib/ohai/plugins/vmware.rb +2 -2
  94. data/lib/ohai/plugins/windows/cpu.rb +2 -16
  95. data/lib/ohai/plugins/windows/network.rb +4 -2
  96. data/lib/ohai/plugins/zpools.rb +3 -3
  97. data/lib/ohai/provides_map.rb +1 -1
  98. data/lib/ohai/runner.rb +11 -14
  99. data/lib/ohai/system.rb +8 -71
  100. data/lib/ohai/util/file_helper.rb +2 -2
  101. data/lib/ohai/util/win32/group_helper.rb +0 -2
  102. data/lib/ohai/version.rb +1 -1
  103. data/ohai.gemspec +6 -5
  104. data/spec/functional/plugins/root_group_spec.rb +2 -2
  105. data/spec/functional/plugins/windows/uptime_spec.rb +0 -29
  106. data/spec/unit/dsl/plugin_spec.rb +14 -46
  107. data/spec/unit/loader_spec.rb +8 -70
  108. data/spec/unit/mixin/azure_metadata_spec.rb +9 -4
  109. data/spec/unit/mixin/command_spec.rb +11 -8
  110. data/spec/unit/mixin/ec2_metadata_spec.rb +5 -0
  111. data/spec/unit/mixin/softlayer_metadata_spec.rb +6 -1
  112. data/spec/unit/plugins/aix/filesystem_spec.rb +10 -10
  113. data/spec/unit/plugins/aix/network_spec.rb +1 -1
  114. data/spec/unit/plugins/aix/virtualization_spec.rb +3 -3
  115. data/spec/unit/plugins/cloud_spec.rb +0 -12
  116. data/spec/unit/plugins/darwin/cpu_spec.rb +2 -2
  117. data/spec/unit/plugins/darwin/filesystem_spec.rb +1 -6
  118. data/spec/unit/plugins/darwin/hardware_spec.rb +1 -1
  119. data/spec/unit/plugins/darwin/virtualization_spec.rb +8 -0
  120. data/spec/unit/plugins/dmi_spec.rb +17 -25
  121. data/spec/unit/plugins/docker_spec.rb +100 -0
  122. data/spec/unit/plugins/fail_spec.rb +3 -58
  123. data/spec/unit/plugins/haskell_spec.rb +1 -1
  124. data/spec/unit/plugins/init_package_spec.rb +1 -1
  125. data/spec/unit/plugins/kernel_spec.rb +0 -52
  126. data/spec/unit/plugins/linux/block_device_spec.rb +2 -2
  127. data/spec/unit/plugins/linux/filesystem_spec.rb +2 -7
  128. data/spec/unit/plugins/linux/lsb_spec.rb +5 -5
  129. data/spec/unit/plugins/linux/lspci_spec.rb +2 -2
  130. data/spec/unit/plugins/linux/machineid_spec.rb +5 -5
  131. data/spec/unit/plugins/linux/network_spec.rb +16 -16
  132. data/spec/unit/plugins/linux/platform_spec.rb +1 -17
  133. data/spec/unit/plugins/linux/virtualization_spec.rb +21 -1
  134. data/spec/unit/plugins/network_spec.rb +58 -58
  135. data/spec/unit/plugins/openstack_spec.rb +5 -24
  136. data/spec/unit/plugins/rackspace_spec.rb +6 -6
  137. data/spec/unit/plugins/root_group_spec.rb +1 -1
  138. data/spec/unit/plugins/ruby_spec.rb +1 -1
  139. data/spec/unit/plugins/rust_spec.rb +1 -1
  140. data/spec/unit/plugins/scala_spec.rb +1 -1
  141. data/spec/unit/plugins/scaleway_spec.rb +91 -0
  142. data/spec/unit/plugins/solaris2/cpu_spec.rb +3 -3
  143. data/spec/unit/plugins/solaris2/platform_spec.rb +2 -2
  144. data/spec/unit/plugins/ssh_host_keys_spec.rb +8 -8
  145. data/spec/unit/plugins/sysconf_spec.rb +1 -0
  146. data/spec/unit/plugins/windows/kernel_spec.rb +79 -0
  147. data/spec/unit/plugins/windows/uptime_spec.rb +8 -58
  148. data/spec/unit/provides_map_spec.rb +4 -4
  149. data/spec/unit/runner_spec.rb +15 -54
  150. data/spec/unit/system_spec.rb +35 -348
  151. data/spec/unit/util/file_helper_spec.rb +2 -0
  152. metadata +28 -28
  153. data/lib/ohai/dsl/plugin/versionvi.rb +0 -61
  154. data/lib/ohai/plugins/bsd/filesystem2.rb +0 -121
  155. data/lib/ohai/plugins/ip_scopes.rb +0 -67
  156. data/lib/ohai/plugins/virtualization.rb +0 -83
  157. data/spec/data/plugins/messages.rb +0 -8
  158. data/spec/data/plugins/v6message.rb +0 -2
  159. data/spec/unit/plugins/bsd/filesystem2_spec.rb +0 -126
  160. data/spec/unit/plugins/ip_scopes_spec.rb +0 -139
@@ -0,0 +1,113 @@
1
+ #
2
+ # Author:: Benjamin Black (<bb@chef.io>)
3
+ # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ # Note: This plugin requires libvirt-bin/libvirt-dev as well as the ruby-libvirt
20
+ # gem to be installed before it will properly parse data
21
+
22
+ Ohai.plugin(:Libvirt) do
23
+ %w{ uri capabilities nodeinfo domains networks storage }.each do |info|
24
+ provides "libvirt/#{info}"
25
+ depends "virtualization"
26
+ end
27
+
28
+ def emu
29
+ @emu ||= (virtualization[:system].eql?("kvm") ? "qemu" : virtualization[:system])
30
+ end
31
+
32
+ def load_libvirt
33
+ require "libvirt" # this is the ruby-libvirt gem not the libvirt gem
34
+ logger.trace("Plugin Libvirt: Successfully loaded ruby-libvirt gem")
35
+ rescue LoadError
36
+ logger.trace("Plugin Libvirt: Can't load gem ruby-libvirt.")
37
+ end
38
+
39
+ def virtconn
40
+ @virt_connect ||= Libvirt.open_read_only("#{emu}:///system")
41
+ end
42
+
43
+ def get_node_data
44
+ node_data = Mash.new
45
+ ni = virtconn.node_get_info
46
+ %w{cores cpus memory mhz model nodes sockets threads}.each { |a| node_data[a] = ni.send(a) }
47
+ node_data
48
+ end
49
+
50
+ def get_domain_data
51
+ domain_data = Mash.new
52
+ virtconn.list_domains.each do |d|
53
+ dv = virtconn.lookup_domain_by_id d
54
+ domain_data[dv.name] = Mash.new
55
+ domain_data[dv.name][:id] = d
56
+ %w{os_type uuid}.each { |a| domain_data[dv.name][a] = dv.send(a) }
57
+ %w{cpu_time max_mem memory nr_virt_cpu state}.each { |a| domain_data[dv.name][a] = dv.info.send(a) }
58
+ end
59
+ domain_data
60
+ end
61
+
62
+ def get_network_data
63
+ network_data = Mash.new
64
+ virtconn.list_networks.each do |n|
65
+ nv = virtconn.lookup_network_by_name n
66
+ network_data[n] = Mash.new
67
+ %w{bridge_name uuid}.each { |a| network_data[n][a] = nv.send(a) }
68
+ end
69
+ network_data
70
+ end
71
+
72
+ def get_storage_data
73
+ storage_data = Mash.new
74
+ virtconn.list_storage_pools.each do |pool|
75
+ sp = virtconn.lookup_storage_pool_by_name pool
76
+ storage_data[pool] = Mash.new
77
+ %w{autostart uuid}.each { |a| storage_data[pool][a] = sp.send(a) }
78
+ %w{allocation available capacity state}.each { |a| storage_data[pool][a] = sp.info.send(a) }
79
+
80
+ storage_data[pool][:volumes] = Mash.new
81
+ sp.list_volumes.each do |v|
82
+ storage_data[pool][:volumes][v] = Mash.new
83
+ sv = sp.lookup_volume_by_name v
84
+ %w{key name path}.each { |a| storage_data[pool][:volumes][v][a] = sv.send(a) }
85
+ %w{allocation capacity type}.each { |a| storage_data[pool][:volumes][v][a] = sv.info.send(a) }
86
+ end
87
+ end
88
+ storage_data
89
+ end
90
+
91
+ collect_data do
92
+ if virtualization[:role].eql?("host")
93
+ load_libvirt
94
+ begin
95
+ libvirt_data = Mash.new
96
+ libvirt_data[:uri] = virtconn.uri
97
+ libvirt_data[:libvirt_version] = Libvirt.version(emu)[0].to_s
98
+ libvirt_data[:nodeinfo] = get_node_data
99
+ libvirt_data[:domains] = get_domain_data
100
+ libvirt_data[:networks] = get_network_data
101
+ libvirt_data[:storage] = get_storage_data
102
+ virtconn.close
103
+ libvirt libvirt_data
104
+ rescue NameError
105
+ logger.trace("Plugin Libvirt: Cannot load ruby-libvirt gem. Skipping...")
106
+ rescue Libvirt::ConnectionError
107
+ logger.trace("Plugin Libvirt: Failed to connect to #{emu}:///system. Skipping...")
108
+ end
109
+ else
110
+ logger.trace("Plugin Libvirt: Node is not a virtualization host. Skipping...")
111
+ end
112
+ end
113
+ end
@@ -24,7 +24,7 @@ Ohai.plugin(:Linode) do
24
24
  #
25
25
  # Returns true or false
26
26
  def has_linode_kernel?
27
- if kernel_data = kernel
27
+ if ( kernel_data = kernel )
28
28
  kernel_data[:release].split("-").last =~ /linode/
29
29
  end
30
30
  end
@@ -43,7 +43,7 @@ Ohai.plugin(:Linode) do
43
43
  #
44
44
  # Alters linode mash with new interface based on name parameter
45
45
  def get_ip_address(name, eth)
46
- if eth_iface = network[:interfaces][eth]
46
+ if ( eth_iface = network[:interfaces][eth] )
47
47
  eth_iface[:addresses].each do |key, info|
48
48
  linode[name] = key if info["family"] == "inet"
49
49
  end
@@ -53,13 +53,13 @@ Ohai.plugin(:Linode) do
53
53
  collect_data do
54
54
  # Setup linode mash if it is a linode system
55
55
  if looks_like_linode?
56
- Ohai::Log.debug("Plugin Linode: looks_like_linode? == true")
56
+ logger.trace("Plugin Linode: looks_like_linode? == true")
57
57
  linode Mash.new
58
58
  get_ip_address(:public_ip, :eth0)
59
59
  get_ip_address(:private_ip, "eth0:1")
60
60
  hint?("linode").each { |k, v| linode[k] = v } if hint?("linode").kind_of?(Hash)
61
61
  else
62
- Ohai::Log.debug("Plugin Linode: looks_like_linode? == false")
62
+ logger.trace("Plugin Linode: looks_like_linode? == false")
63
63
  end
64
64
  end
65
65
  end
@@ -20,23 +20,23 @@ Ohai.plugin(:BlockDevice) do
20
20
  provides "block_device"
21
21
 
22
22
  collect_data(:linux) do
23
- if File.exists?("/sys/block")
23
+ if File.exist?("/sys/block")
24
24
  block = Mash.new
25
25
  Dir["/sys/block/*"].each do |block_device_dir|
26
26
  dir = File.basename(block_device_dir)
27
27
  block[dir] = Mash.new
28
28
  %w{size removable}.each do |check|
29
- if File.exists?("/sys/block/#{dir}/#{check}")
29
+ if File.exist?("/sys/block/#{dir}/#{check}")
30
30
  File.open("/sys/block/#{dir}/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
31
31
  end
32
32
  end
33
33
  %w{model rev state timeout vendor queue_depth}.each do |check|
34
- if File.exists?("/sys/block/#{dir}/device/#{check}")
34
+ if File.exist?("/sys/block/#{dir}/device/#{check}")
35
35
  File.open("/sys/block/#{dir}/device/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
36
36
  end
37
37
  end
38
38
  %w{rotational physical_block_size logical_block_size}.each do |check|
39
- if File.exists?("/sys/block/#{dir}/queue/#{check}")
39
+ if File.exist?("/sys/block/#{dir}/queue/#{check}")
40
40
  File.open("/sys/block/#{dir}/queue/#{check}") { |f| block[dir][check] = f.read_nonblock(1024).strip }
41
41
  end
42
42
  end
@@ -92,7 +92,7 @@ Ohai.plugin(:CPU) do
92
92
  cpu[:cores] = real_cpu.keys.length * cpu["0"]["cores"].to_i
93
93
  else
94
94
  begin
95
- Ohai::Log.debug("Plugin CPU: Falling back to aggregate data from lscpu as real cpu & core data is missing in /proc/cpuinfo")
95
+ logger.trace("Plugin CPU: Falling back to aggregate data from lscpu as real cpu & core data is missing in /proc/cpuinfo")
96
96
  so = shell_out("lscpu")
97
97
  if so.exitstatus == 0
98
98
  lscpu_data = Mash.new
@@ -110,10 +110,10 @@ Ohai.plugin(:CPU) do
110
110
  cpu[:real] = lscpu_data[:sockets]
111
111
  cpu[:cores] = lscpu_data[:sockets] * lscpu_data[:cores]
112
112
  else
113
- Ohai::Log.debug("Plugin CPU: Error executing lscpu. CPU data may not be available.")
113
+ logger.trace("Plugin CPU: Error executing lscpu. CPU data may not be available.")
114
114
  end
115
115
  rescue Ohai::Exceptions::Exec # util-linux isn't installed most likely
116
- Ohai::Log.debug("Plugin CPU: Error executing lscpu. util-linux may not be installed.")
116
+ logger.trace("Plugin CPU: Error executing lscpu. util-linux may not be installed.")
117
117
  end
118
118
  end
119
119
  end
@@ -20,7 +20,6 @@
20
20
 
21
21
  Ohai.plugin(:Filesystem) do
22
22
  provides "filesystem"
23
- provides "filesystem2"
24
23
 
25
24
  def find_device(name)
26
25
  %w{/dev /dev/mapper}.each do |dir|
@@ -134,7 +133,7 @@ Ohai.plugin(:Filesystem) do
134
133
  unless Ohai.config[:plugin][:filesystem][:allow_partial_data]
135
134
  raise e
136
135
  end
137
- Ohai::Log.warn("Plugin Filesystem: df binary is not available. Some data will not be available.")
136
+ logger.warn("Plugin Filesystem: df binary is not available. Some data will not be available.")
138
137
  end
139
138
 
140
139
  # Grab mount information from /bin/mount
@@ -154,7 +153,7 @@ Ohai.plugin(:Filesystem) do
154
153
  unless Ohai.config[:plugin][:filesystem][:allow_partial_data]
155
154
  raise e
156
155
  end
157
- Ohai::Log.warn("Plugin Filesystem: mount binary is not available. Some data will not be available.")
156
+ logger.warn("Plugin Filesystem: mount binary is not available. Some data will not be available.")
158
157
  end
159
158
 
160
159
  # We used to try to decide if we wanted to run lsblk or blkid
@@ -197,10 +196,10 @@ Ohai.plugin(:Filesystem) do
197
196
  keys_to_update << key
198
197
  end
199
198
 
200
- keys_to_update.each do |key|
199
+ keys_to_update.each do |k|
201
200
  [:fs_type, :uuid, :label].each do |subkey|
202
201
  if parsed[subkey] && !parsed[subkey].empty?
203
- fs[key][subkey] = parsed[subkey]
202
+ fs[k][subkey] = parsed[subkey]
204
203
  end
205
204
  end
206
205
  end
@@ -250,6 +249,5 @@ Ohai.plugin(:Filesystem) do
250
249
 
251
250
  # Set the filesystem data
252
251
  filesystem fs_data
253
- filesystem2 fs_data
254
252
  end
255
253
  end
@@ -22,7 +22,7 @@ Ohai.plugin(:LSB) do
22
22
  collect_data(:linux) do
23
23
  lsb Mash.new
24
24
 
25
- if File.exists?("/usr/bin/lsb_release")
25
+ if File.exist?("/usr/bin/lsb_release")
26
26
  # From package redhat-lsb on Fedora/Redhat, lsb-release on Debian/Ubuntu
27
27
  so = shell_out("lsb_release -a")
28
28
  so.stdout.lines do |line|
@@ -39,7 +39,7 @@ Ohai.plugin(:LSB) do
39
39
  lsb[:id] = line
40
40
  end
41
41
  end
42
- elsif File.exists?("/etc/lsb-release")
42
+ elsif File.exist?("/etc/lsb-release")
43
43
  # Old, non-standard Debian support
44
44
  File.open("/etc/lsb-release").each do |line|
45
45
  case line
@@ -54,7 +54,7 @@ Ohai.plugin(:LSB) do
54
54
  end
55
55
  end
56
56
  else
57
- Ohai::Log.debug("Plugin LSB: Skipping LSB, cannot find /etc/lsb-release or /usr/bin/lsb_release")
57
+ logger.trace("Plugin LSB: Skipping LSB, cannot find /etc/lsb-release or /usr/bin/lsb_release")
58
58
  end
59
59
  end
60
60
  end
@@ -20,6 +20,7 @@
20
20
  Ohai.plugin(:Lspci) do
21
21
  depends "platform"
22
22
  provides "pci"
23
+ optional true
23
24
 
24
25
  collect_data(:linux) do
25
26
  devices = Mash.new
@@ -50,7 +51,7 @@ Ohai.plugin(:Lspci) do
50
51
  next if dev.nil?
51
52
  case dev[0]
52
53
  when "Device" # There are two different Device tags
53
- if tmp = dev[1].match(/(#{hh}:#{hh}.#{h})/)
54
+ if ( tmp = dev[1].match(/(#{hh}:#{hh}.#{h})/) )
54
55
  # We have a device id
55
56
  d_id = tmp[0] # From now on we will need this id
56
57
  devices[d_id] = Mash.new
@@ -22,10 +22,10 @@ Ohai.plugin(:Machineid) do
22
22
  collect_data(:linux) do
23
23
  mid = nil
24
24
 
25
- if File.exists?("/etc/machine-id")
26
- mid = File.read("/etc/machine-id").chomp
27
- elsif File.exists?("/var/lib/dbus/machine-id")
28
- mid = File.read("/var/lib/dbus/machine-id").chomp
25
+ if ::File.exist?("/etc/machine-id")
26
+ mid = ::File.read("/etc/machine-id").chomp
27
+ elsif ::File.exist?("/var/lib/dbus/machine-id")
28
+ mid = ::File.read("/var/lib/dbus/machine-id").chomp
29
29
  end
30
30
 
31
31
  if mid
@@ -55,7 +55,7 @@ Ohai.plugin(:Network) do
55
55
  if line =~ /^([a-f0-9\:\.]+)\s+dev\s+([^\s]+)\s+lladdr\s+([a-fA-F0-9\:]+)/
56
56
  interface = iface[$2]
57
57
  unless interface
58
- Ohai::Log.warn("neighbor list has entries for unknown interface #{interface}")
58
+ logger.warn("neighbor list has entries for unknown interface #{interface}")
59
59
  next
60
60
  end
61
61
  interface[neigh_attr] = Mash.new unless interface[neigh_attr]
@@ -76,7 +76,7 @@ Ohai.plugin(:Network) do
76
76
  so = shell_out("ip -o -f #{family[:name]} route show table #{default_route_table}")
77
77
  so.stdout.lines do |line|
78
78
  line.strip!
79
- Ohai::Log.debug("Plugin Network: Parsing #{line}")
79
+ logger.trace("Plugin Network: Parsing #{line}")
80
80
  if line =~ /\\/
81
81
  parts = line.split('\\')
82
82
  route_dest = parts.shift.strip
@@ -91,13 +91,13 @@ Ohai.plugin(:Network) do
91
91
  if route_ending =~ /\bdev\s+([^\s]+)\b/
92
92
  route_int = $1
93
93
  else
94
- Ohai::Log.debug("Plugin Network: Skipping route entry without a device: '#{line}'")
94
+ logger.trace("Plugin Network: Skipping route entry without a device: '#{line}'")
95
95
  next
96
96
  end
97
97
  route_int = "venet0:0" if is_openvz? && !is_openvz_host? && route_int == "venet0" && iface["venet0:0"]
98
98
 
99
99
  unless iface[route_int]
100
- Ohai::Log.debug("Plugin Network: Skipping previously unseen interface from 'ip route show': #{route_int}")
100
+ logger.trace("Plugin Network: Skipping previously unseen interface from 'ip route show': #{route_int}")
101
101
  next
102
102
  end
103
103
 
@@ -115,7 +115,7 @@ Ohai.plugin(:Network) do
115
115
  addr = iface[route_int][:addresses]
116
116
  unless addr.nil? || addr.has_key?(route_entry[:src]) ||
117
117
  addr.values.all? { |a| a["family"] != family[:name] }
118
- Ohai::Log.debug("Plugin Network: Skipping route entry whose src does not match the interface IP")
118
+ logger.trace("Plugin Network: Skipping route entry whose src does not match the interface IP")
119
119
  next
120
120
  end
121
121
  end
@@ -155,7 +155,7 @@ Ohai.plugin(:Network) do
155
155
  so = shell_out("#{ethtool_binary_path} #{tmp_int}")
156
156
  so.stdout.lines do |line|
157
157
  line.chomp!
158
- Ohai::Log.debug("Plugin Network: Parsing ethtool output: #{line}")
158
+ logger.trace("Plugin Network: Parsing ethtool output: #{line}")
159
159
  line.lstrip!
160
160
  k, v = line.split(": ")
161
161
  next unless keys.include? k
@@ -176,7 +176,7 @@ Ohai.plugin(:Network) do
176
176
  iface.each_key do |tmp_int|
177
177
  next unless iface[tmp_int][:encapsulation] == "Ethernet"
178
178
  so = shell_out("#{ethtool_binary_path} -g #{tmp_int}")
179
- Ohai::Log.debug("Plugin Network: Parsing ethtool output: #{so.stdout}")
179
+ logger.trace("Plugin Network: Parsing ethtool output: #{so.stdout}")
180
180
  type = nil
181
181
  iface[tmp_int]["ring_params"] = {}
182
182
  so.stdout.lines.each do |line|
@@ -486,7 +486,7 @@ Ohai.plugin(:Network) do
486
486
  else
487
487
  default_route_table = configuration(:default_route_table)
488
488
  end
489
- Ohai::Log.debug("Plugin Network: default route table is '#{default_route_table}'")
489
+ logger.trace("Plugin Network: default route table is '#{default_route_table}'")
490
490
 
491
491
  # Match the lead line for an interface from iproute2
492
492
  # 3: eth0.11@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
@@ -533,14 +533,14 @@ Ohai.plugin(:Network) do
533
533
  else
534
534
  "default_#{family[:name]}_interface"
535
535
  end
536
- Ohai::Log.debug("Plugin Network: Unable to determine '#{attribute_name}' as no default routes were found for that interface family")
536
+ logger.trace("Plugin Network: Unable to determine '#{attribute_name}' as no default routes were found for that interface family")
537
537
  else
538
538
  network["#{default_prefix}_interface"] = default_route[:dev]
539
- Ohai::Log.debug("Plugin Network: #{default_prefix}_interface set to #{default_route[:dev]}")
539
+ logger.trace("Plugin Network: #{default_prefix}_interface set to #{default_route[:dev]}")
540
540
 
541
541
  # setting gateway to 0.0.0.0 or :: if the default route is a link level one
542
542
  network["#{default_prefix}_gateway"] = default_route[:via] ? default_route[:via] : family[:default_route].chomp("/0")
543
- Ohai::Log.debug("Plugin Network: #{default_prefix}_gateway set to #{network["#{default_prefix}_gateway"]}")
543
+ logger.trace("Plugin Network: #{default_prefix}_gateway set to #{network["#{default_prefix}_gateway"]}")
544
544
 
545
545
  # deduce the default route the user most likely cares about to pick {ip,mac,ip6}address below
546
546
  favored_route = favored_default_route(routes, iface, default_route, family)
@@ -553,20 +553,20 @@ Ohai.plugin(:Network) do
553
553
  if family[:name] == "inet"
554
554
  ipaddress favored_route[:src]
555
555
  m = get_mac_for_interface(iface, favored_route[:dev])
556
- Ohai::Log.debug("Plugin Network: Overwriting macaddress #{macaddress} with #{m} from interface #{favored_route[:dev]}") if macaddress
556
+ logger.trace("Plugin Network: Overwriting macaddress #{macaddress} with #{m} from interface #{favored_route[:dev]}") if macaddress
557
557
  macaddress m
558
558
  elsif family[:name] == "inet6"
559
559
  # this rarely does anything since we rarely have src for ipv6, so this usually falls back on the network plugin
560
560
  ip6address favored_route[:src]
561
561
  if macaddress
562
- Ohai::Log.debug("Plugin Network: Not setting macaddress from ipv6 interface #{favored_route[:dev]} because macaddress is already set")
562
+ logger.trace("Plugin Network: Not setting macaddress from ipv6 interface #{favored_route[:dev]} because macaddress is already set")
563
563
  else
564
564
  macaddress get_mac_for_interface(iface, favored_route[:dev])
565
565
  end
566
566
  end
567
567
  else
568
- Ohai::Log.debug("Plugin Network: Unable to deduce the favored default route for family '#{family[:name]}' despite finding a default route, and is not setting ipaddress/ip6address/macaddress. the network plugin may provide fallbacks.")
569
- Ohai::Log.debug("Plugin Network: This potential default route was excluded: #{default_route}")
568
+ logger.trace("Plugin Network: Unable to deduce the favored default route for family '#{family[:name]}' despite finding a default route, and is not setting ipaddress/ip6address/macaddress. the network plugin may provide fallbacks.")
569
+ logger.trace("Plugin Network: This potential default route was excluded: #{default_route}")
570
570
  end
571
571
  end
572
572
  end # end families.each
@@ -576,7 +576,7 @@ Ohai.plugin(:Network) do
576
576
  route_result = so.stdout.split($/).grep( /^0.0.0.0/ )[0].split( /[ \t]+/ )
577
577
  network[:default_gateway], network[:default_interface] = route_result.values_at(1, 7)
578
578
  rescue Ohai::Exceptions::Exec
579
- Ohai::Log.debug("Plugin Network: Unable to determine default interface")
579
+ logger.trace("Plugin Network: Unable to determine default interface")
580
580
  end
581
581
 
582
582
  so = shell_out("ifconfig -a")
@@ -24,14 +24,8 @@ Ohai.plugin(:Platform) do
24
24
  contents[/^Red Hat/i] ? "redhat" : contents[/(\w+)/i, 1].downcase
25
25
  end
26
26
 
27
- # Amazon Linux AMI release 2013.09
28
- # Amazon Linux 2
29
- # Fedora release 28 (Twenty Eight)
30
- # CentOS release 5.8 (Final)
31
- # CentOS release 6.7 (Final)
32
- # Red Hat Enterprise Linux Server release 7.5 (Maipo)
33
27
  def get_redhatish_version(contents)
34
- contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/(release)? ([\d\.]+)/, 2]
28
+ contents[/Rawhide/i] ? contents[/((\d+) \(Rawhide\))/i, 1].downcase : contents[/release ([\d\.]+)/, 1]
35
29
  end
36
30
 
37
31
  #
@@ -87,7 +81,7 @@ Ohai.plugin(:Platform) do
87
81
  release_contents = File.read("/etc/cumulus/etc.replace/os-release")
88
82
  release_contents.match(/VERSION_ID=(.*)/)[1]
89
83
  rescue NoMethodError, Errno::ENOENT, Errno::EACCES # rescue regex failure, file missing, or permission denied
90
- Ohai::Log.warn("Detected Cumulus Linux, but /etc/cumulus/etc/replace/os-release could not be parsed to determine platform_version")
84
+ logger.warn("Detected Cumulus Linux, but /etc/cumulus/etc/replace/os-release could not be parsed to determine platform_version")
91
85
  nil
92
86
  end
93
87
 
@@ -100,7 +94,7 @@ Ohai.plugin(:Platform) do
100
94
  release_contents = File.read("/etc/f5-release")
101
95
  release_contents.match(/BIG-IP release (\S*)/)[1] # http://rubular.com/r/O8nlrBVqSb
102
96
  rescue NoMethodError, Errno::ENOENT, Errno::EACCES # rescue regex failure, file missing, or permission denied
103
- Ohai::Log.warn("Detected F5 Big-IP, but /etc/f5-release could not be parsed to determine platform_version")
97
+ logger.warn("Detected F5 Big-IP, but /etc/f5-release could not be parsed to determine platform_version")
104
98
  nil
105
99
  end
106
100
 
@@ -291,7 +285,7 @@ Ohai.plugin(:Platform) do
291
285
  # We have to do this for compatibility reasons, or older OS releases might get different
292
286
  # "platform" or "platform_version" attributes (e.g. SLES12, RHEL7).
293
287
  elsif File.exist?("/etc/os-release")
294
- platform os_release_info["ID"] == "sles" ? "suse" : os_release_info["ID"] # SLES is wrong. We call it SUSE
288
+ platform os_release_info["ID"]
295
289
  platform_version os_release_info["VERSION_ID"]
296
290
  # platform_family also does not need to be hardcoded anymore.
297
291
  # This would be the correct way, but we stick with "determine_platform_family" for compatibility reasons.