ohai 8.22.1 → 8.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ohai/application.rb +2 -0
  3. data/lib/ohai/mixin/dmi_decode.rb +2 -0
  4. data/lib/ohai/mixin/ec2_metadata.rb +14 -0
  5. data/lib/ohai/plugins/azure.rb +5 -5
  6. data/lib/ohai/plugins/c.rb +118 -46
  7. data/lib/ohai/plugins/cloud.rb +1 -0
  8. data/lib/ohai/plugins/dmi.rb +5 -5
  9. data/lib/ohai/plugins/ec2.rb +1 -0
  10. data/lib/ohai/plugins/erlang.rb +3 -5
  11. data/lib/ohai/plugins/groovy.rb +1 -1
  12. data/lib/ohai/plugins/haskell.rb +4 -4
  13. data/lib/ohai/plugins/hostname.rb +6 -6
  14. data/lib/ohai/plugins/ip_scopes.rb +1 -1
  15. data/lib/ohai/plugins/linux/network.rb +15 -15
  16. data/lib/ohai/plugins/linux/platform.rb +82 -43
  17. data/lib/ohai/plugins/linux/sessions.rb +2 -0
  18. data/lib/ohai/plugins/linux/virtualization.rb +18 -0
  19. data/lib/ohai/plugins/lua.rb +1 -1
  20. data/lib/ohai/plugins/network.rb +10 -10
  21. data/lib/ohai/plugins/scala.rb +2 -2
  22. data/lib/ohai/plugins/solaris2/dmi.rb +5 -5
  23. data/lib/ohai/plugins/sysconf.rb +45 -0
  24. data/lib/ohai/plugins/virtualbox.rb +22 -17
  25. data/lib/ohai/plugins/vmware.rb +2 -2
  26. data/lib/ohai/plugins/windows/virtualization.rb +14 -0
  27. data/lib/ohai/system.rb +0 -4
  28. data/lib/ohai/util/file_helper.rb +2 -2
  29. data/lib/ohai/version.rb +1 -1
  30. data/spec/unit/plugins/c_spec.rb +299 -266
  31. data/spec/unit/plugins/cloud_spec.rb +6 -0
  32. data/spec/unit/plugins/ec2_spec.rb +45 -1
  33. data/spec/unit/plugins/erlang_spec.rb +5 -5
  34. data/spec/unit/plugins/linux/network_spec.rb +1 -1
  35. data/spec/unit/plugins/linux/platform_spec.rb +43 -1
  36. data/spec/unit/plugins/linux/virtualization_spec.rb +19 -0
  37. data/spec/unit/plugins/network_spec.rb +23 -23
  38. data/spec/unit/plugins/sysconf_spec.rb +679 -0
  39. data/spec/unit/plugins/windows/virtualization_spec.rb +67 -0
  40. data/spec/unit/system_spec.rb +0 -1
  41. metadata +5 -3
@@ -43,7 +43,7 @@ Ohai.plugin(:IpScopes) do
43
43
 
44
44
  rescue LoadError => e
45
45
  # our favourite gem is not installed. Boohoo.
46
- Ohai::Log.debug("Plugin ip_scopes: cannot load gem, plugin disabled: #{e}")
46
+ Ohai::Log.debug("Plugin IpScopes: cannot load gem, plugin disabled: #{e}")
47
47
  end
48
48
  end
49
49
 
@@ -80,7 +80,7 @@ Ohai.plugin(:Network) do
80
80
  so = shell_out("ip -o -f #{family[:name]} route show table #{default_route_table}")
81
81
  so.stdout.lines do |line|
82
82
  line.strip!
83
- Ohai::Log.debug("Parsing #{line}")
83
+ Ohai::Log.debug("Plugin Network: Parsing #{line}")
84
84
  if line =~ /\\/
85
85
  parts = line.split('\\')
86
86
  route_dest = parts.shift.strip
@@ -95,13 +95,13 @@ Ohai.plugin(:Network) do
95
95
  if route_ending =~ /\bdev\s+([^\s]+)\b/
96
96
  route_int = $1
97
97
  else
98
- Ohai::Log.debug("Skipping route entry without a device: '#{line}'")
98
+ Ohai::Log.debug("Plugin Network: Skipping route entry without a device: '#{line}'")
99
99
  next
100
100
  end
101
101
  route_int = "venet0:0" if is_openvz? && !is_openvz_host? && route_int == "venet0" && iface["venet0:0"]
102
102
 
103
103
  unless iface[route_int]
104
- Ohai::Log.debug("Skipping previously unseen interface from 'ip route show': #{route_int}")
104
+ Ohai::Log.debug("Plugin Network: Skipping previously unseen interface from 'ip route show': #{route_int}")
105
105
  next
106
106
  end
107
107
 
@@ -118,7 +118,7 @@ Ohai.plugin(:Network) do
118
118
  addr = iface[route_int][:addresses]
119
119
  unless addr.nil? || addr.has_key?(route_entry[:src]) ||
120
120
  addr.values.all? { |a| a["family"] != family[:name] }
121
- Ohai::Log.debug("Skipping route entry whose src does not match the interface IP")
121
+ Ohai::Log.debug("Plugin Network: Skipping route entry whose src does not match the interface IP")
122
122
  next
123
123
  end
124
124
  end
@@ -156,7 +156,7 @@ Ohai.plugin(:Network) do
156
156
  so = shell_out("#{ethtool_binary} #{tmp_int}")
157
157
  so.stdout.lines do |line|
158
158
  line.chomp!
159
- Ohai::Log.debug("Parsing ethtool output: #{line}")
159
+ Ohai::Log.debug("Plugin Network: Parsing ethtool output: #{line}")
160
160
  line.lstrip!
161
161
  k, v = line.split(": ")
162
162
  next unless keys.include? k
@@ -177,7 +177,7 @@ Ohai.plugin(:Network) do
177
177
  iface.each_key do |tmp_int|
178
178
  next unless iface[tmp_int][:encapsulation] == "Ethernet"
179
179
  so = shell_out("#{ethtool_binary} -g #{tmp_int}")
180
- Ohai::Log.debug("Parsing ethtool output: #{so.stdout}")
180
+ Ohai::Log.debug("Plugin Network: Parsing ethtool output: #{so.stdout}")
181
181
  type = nil
182
182
  iface[tmp_int]["ring_params"] = {}
183
183
  so.stdout.lines.each do |line|
@@ -462,7 +462,7 @@ Ohai.plugin(:Network) do
462
462
  else
463
463
  default_route_table = configuration(:default_route_table)
464
464
  end
465
- Ohai::Log.debug("default route table is '#{default_route_table}'")
465
+ Ohai::Log.debug("Plugin Network: default route table is '#{default_route_table}'")
466
466
 
467
467
  # Match the lead line for an interface from iproute2
468
468
  # 3: eth0.11@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
@@ -507,14 +507,14 @@ Ohai.plugin(:Network) do
507
507
  else
508
508
  "default_#{family[:name]}_interface"
509
509
  end
510
- Ohai::Log.debug("Unable to determine '#{attribute_name}' as no default routes were found for that interface family")
510
+ Ohai::Log.debug("Plugin Network: Unable to determine '#{attribute_name}' as no default routes were found for that interface family")
511
511
  else
512
512
  network["#{default_prefix}_interface"] = default_route[:dev]
513
- Ohai::Log.debug("#{default_prefix}_interface set to #{default_route[:dev]}")
513
+ Ohai::Log.debug("Plugin Network: #{default_prefix}_interface set to #{default_route[:dev]}")
514
514
 
515
515
  # setting gateway to 0.0.0.0 or :: if the default route is a link level one
516
516
  network["#{default_prefix}_gateway"] = default_route[:via] ? default_route[:via] : family[:default_route].chomp("/0")
517
- Ohai::Log.debug("#{default_prefix}_gateway set to #{network["#{default_prefix}_gateway"]}")
517
+ Ohai::Log.debug("Plugin Network: #{default_prefix}_gateway set to #{network["#{default_prefix}_gateway"]}")
518
518
 
519
519
  # deduce the default route the user most likely cares about to pick {ip,mac,ip6}address below
520
520
  favored_route = favored_default_route(routes, iface, default_route, family)
@@ -527,20 +527,20 @@ Ohai.plugin(:Network) do
527
527
  if family[:name] == "inet"
528
528
  ipaddress favored_route[:src]
529
529
  m = get_mac_for_interface(iface, favored_route[:dev])
530
- Ohai::Log.debug("Overwriting macaddress #{macaddress} with #{m} from interface #{favored_route[:dev]}") if macaddress
530
+ Ohai::Log.debug("Plugin Network: Overwriting macaddress #{macaddress} with #{m} from interface #{favored_route[:dev]}") if macaddress
531
531
  macaddress m
532
532
  elsif family[:name] == "inet6"
533
533
  # this rarely does anything since we rarely have src for ipv6, so this usually falls back on the network plugin
534
534
  ip6address favored_route[:src]
535
535
  if macaddress
536
- Ohai::Log.debug("Not setting macaddress from ipv6 interface #{favored_route[:dev]} because macaddress is already set")
536
+ Ohai::Log.debug("Plugin Network: Not setting macaddress from ipv6 interface #{favored_route[:dev]} because macaddress is already set")
537
537
  else
538
538
  macaddress get_mac_for_interface(iface, favored_route[:dev])
539
539
  end
540
540
  end
541
541
  else
542
- Ohai::Log.debug("the linux/network plugin was 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.")
543
- Ohai::Log.debug("this potential default route was excluded: #{default_route}")
542
+ 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.")
543
+ Ohai::Log.debug("Plugin Network: This potential default route was excluded: #{default_route}")
544
544
  end
545
545
  end
546
546
  end # end families.each
@@ -550,7 +550,7 @@ Ohai.plugin(:Network) do
550
550
  route_result = so.stdout.split($/).grep( /^0.0.0.0/ )[0].split( /[ \t]+/ )
551
551
  network[:default_gateway], network[:default_interface] = route_result.values_at(1, 7)
552
552
  rescue Ohai::Exceptions::Exec
553
- Ohai::Log.debug("Unable to determine default interface")
553
+ Ohai::Log.debug("Plugin Network: Unable to determine default interface")
554
554
  end
555
555
 
556
556
  so = shell_out("ifconfig -a")
@@ -72,6 +72,62 @@ Ohai.plugin(:Platform) do
72
72
  File.exist?("/etc/os-release") && os_release_info["CISCO_RELEASE_INFO"]
73
73
  end
74
74
 
75
+ #
76
+ # Determines the platform version for Cumulus Linux systems
77
+ #
78
+ # @returns [String] cumulus Linux version from /etc/cumulus/etc.replace/os-release
79
+ #
80
+ def cumulus_version
81
+ release_contents = File.read("/etc/cumulus/etc.replace/os-release")
82
+ release_contents.match(/VERSION_ID=(.*)/)[1]
83
+ rescue NoMethodError, Errno::ENOENT, Errno::EACCES # rescue regex failure, file missing, or permission denied
84
+ Ohai::Log.warn("Detected Cumulus Linux, but /etc/cumulus/etc/replace/os-release could not be parsed to determine platform_version")
85
+ nil
86
+ end
87
+
88
+ #
89
+ # Determines the platform version for Debian based systems
90
+ #
91
+ # @returns [String] version of the platform
92
+ #
93
+ def debian_platform_version
94
+ if platform == "cumulus"
95
+ cumulus_version
96
+ else # not cumulus
97
+ File.read("/etc/debian_version").chomp
98
+ end
99
+ end
100
+
101
+ #
102
+ # Determines the platform_family based on the platform
103
+ #
104
+ # @returns [String] platform_family value
105
+ #
106
+ def determine_platform_family
107
+ case platform
108
+ when /debian/, /ubuntu/, /linuxmint/, /raspbian/, /cumulus/
109
+ "debian"
110
+ when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
111
+ "rhel"
112
+ when /suse/
113
+ "suse"
114
+ when /fedora/, /pidora/, /arista_eos/
115
+ "fedora"
116
+ when /nexus/, /ios_xr/
117
+ "wrlinux"
118
+ when /gentoo/
119
+ "gentoo"
120
+ when /slackware/
121
+ "slackware"
122
+ when /arch/
123
+ "arch"
124
+ when /exherbo/
125
+ "exherbo"
126
+ when /alpine/
127
+ "alpine"
128
+ end
129
+ end
130
+
75
131
  collect_data(:linux) do
76
132
  # platform [ and platform_version ? ] should be lower case to avoid dealing with RedHat/Redhat/redhat matching
77
133
  if File.exist?("/etc/oracle-release")
@@ -94,10 +150,12 @@ Ohai.plugin(:Platform) do
94
150
  else
95
151
  if File.exist?("/usr/bin/raspi-config")
96
152
  platform "raspbian"
153
+ elsif Dir.exist?("/etc/cumulus")
154
+ platform "cumulus"
97
155
  else
98
156
  platform "debian"
99
157
  end
100
- platform_version File.read("/etc/debian_version").chomp
158
+ platform_version debian_platform_version
101
159
  end
102
160
  elsif File.exist?("/etc/parallels-release")
103
161
  contents = File.read("/etc/parallels-release").chomp
@@ -116,12 +174,6 @@ Ohai.plugin(:Platform) do
116
174
  contents = File.read("/etc/system-release").chomp
117
175
  platform get_redhatish_platform(contents)
118
176
  platform_version get_redhatish_version(contents)
119
- elsif File.exist?("/etc/gentoo-release")
120
- platform "gentoo"
121
- # the gentoo release version is the base version used to bootstrap
122
- # a node and doesn't have a lot of meaning in a rolling release distro
123
- # kernel release will be used - ex. 3.18.7-gentoo
124
- platform_version `uname -r`.strip
125
177
  elsif File.exist?("/etc/SuSE-release")
126
178
  suse_release = File.read("/etc/SuSE-release")
127
179
  suse_version = suse_release.scan(/VERSION = (\d+)\nPATCHLEVEL = (\d+)/).flatten.join(".")
@@ -137,22 +189,6 @@ Ohai.plugin(:Platform) do
137
189
  else
138
190
  platform "suse"
139
191
  end
140
- elsif File.exist?("/etc/slackware-version")
141
- platform "slackware"
142
- platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
143
- elsif File.exist?("/etc/arch-release")
144
- platform "arch"
145
- # no way to determine platform_version in a rolling release distribution
146
- # kernel release will be used - ex. 2.6.32-ARCH
147
- platform_version `uname -r`.strip
148
- elsif File.exist?("/etc/exherbo-release")
149
- platform "exherbo"
150
- # no way to determine platform_version in a rolling release distribution
151
- # kernel release will be used - ex. 3.13
152
- platform_version `uname -r`.strip
153
- elsif File.exist?("/etc/alpine-release")
154
- platform "alpine"
155
- platform_version File.read("/etc/alpine-release").strip()
156
192
  elsif File.exist?("/etc/Eos-release")
157
193
  platform "arista_eos"
158
194
  platform_version File.read("/etc/Eos-release").strip.split[-1]
@@ -172,6 +208,28 @@ Ohai.plugin(:Platform) do
172
208
 
173
209
  platform_family "wrlinux"
174
210
  platform_version os_release_info["VERSION"]
211
+ elsif File.exist?("/etc/gentoo-release")
212
+ platform "gentoo"
213
+ # the gentoo release version is the base version used to bootstrap
214
+ # a node and doesn't have a lot of meaning in a rolling release distro
215
+ # kernel release will be used - ex. 3.18.7-gentoo
216
+ platform_version `uname -r`.strip
217
+ elsif File.exist?("/etc/slackware-version")
218
+ platform "slackware"
219
+ platform_version File.read("/etc/slackware-version").scan(/(\d+|\.+)/).join
220
+ elsif File.exist?("/etc/arch-release")
221
+ platform "arch"
222
+ # no way to determine platform_version in a rolling release distribution
223
+ # kernel release will be used - ex. 2.6.32-ARCH
224
+ platform_version `uname -r`.strip
225
+ elsif File.exist?("/etc/exherbo-release")
226
+ platform "exherbo"
227
+ # no way to determine platform_version in a rolling release distribution
228
+ # kernel release will be used - ex. 3.13
229
+ platform_version `uname -r`.strip
230
+ elsif File.exist?("/etc/alpine-release")
231
+ platform "alpine"
232
+ platform_version File.read("/etc/alpine-release").strip()
175
233
  elsif lsb[:id] =~ /RedHat/i
176
234
  platform "redhat"
177
235
  platform_version lsb[:release]
@@ -189,25 +247,6 @@ Ohai.plugin(:Platform) do
189
247
  platform_version lsb[:release]
190
248
  end
191
249
 
192
- case platform
193
- when /debian/, /ubuntu/, /linuxmint/, /raspbian/
194
- platform_family "debian"
195
- when /fedora/, /pidora/
196
- platform_family "fedora"
197
- when /oracle/, /centos/, /redhat/, /scientific/, /enterpriseenterprise/, /amazon/, /xenserver/, /cloudlinux/, /ibm_powerkvm/, /parallels/, /nexus_centos/ # Note that 'enterpriseenterprise' is oracle's LSB "distributor ID"
198
- platform_family "rhel"
199
- when /suse/
200
- platform_family "suse"
201
- when /gentoo/
202
- platform_family "gentoo"
203
- when /slackware/
204
- platform_family "slackware"
205
- when /arch/
206
- platform_family "arch"
207
- when /exherbo/
208
- platform_family "exherbo"
209
- when /alpine/
210
- platform_family "alpine"
211
- end
250
+ platform_family determine_platform_family
212
251
  end
213
252
  end
@@ -45,6 +45,8 @@ Ohai.plugin(:Sessions) do
45
45
  sessions[:by_user][user] = [s]
46
46
  end
47
47
  end
48
+ else
49
+ Ohai::Log.debug("Plugin Sessions: Could not find loginctl. Skipping plugin.")
48
50
  end
49
51
  end
50
52
  end
@@ -49,6 +49,7 @@ Ohai.plugin(:Virtualization) do
49
49
  # This file should exist on most Xen systems, normally empty for guests
50
50
  if File.exist?("/proc/xen/capabilities")
51
51
  if File.read("/proc/xen/capabilities") =~ /control_d/i
52
+ Ohai::Log.debug("Plugin Virtualization: /proc/xen/capabilities contains control_d. Detecting as Xen host")
52
53
  virtualization[:role] = "host"
53
54
  virtualization[:systems][:xen] = "host"
54
55
  end
@@ -65,10 +66,12 @@ Ohai.plugin(:Virtualization) do
65
66
  if File.exist?("/proc/modules")
66
67
  modules = File.read("/proc/modules")
67
68
  if modules =~ /^vboxdrv/
69
+ Ohai::Log.debug("Plugin Virtualization: /proc/modules contains vboxdrv. Detecting as vbox host")
68
70
  virtualization[:system] = "vbox"
69
71
  virtualization[:role] = "host"
70
72
  virtualization[:systems][:vbox] = "host"
71
73
  elsif modules =~ /^vboxguest/
74
+ Ohai::Log.debug("Plugin Virtualization: /proc/modules contains vboxguest. Detecting as vbox guest")
72
75
  virtualization[:system] = "vbox"
73
76
  virtualization[:role] = "guest"
74
77
  virtualization[:systems][:vbox] = "guest"
@@ -77,6 +80,7 @@ Ohai.plugin(:Virtualization) do
77
80
 
78
81
  # if nova binary is present we're on an openstack host
79
82
  if nova_exists?
83
+ Ohai::Log.debug("Plugin Virtualization: nova command exists. Detecting as openstack host")
80
84
  virtualization[:system] = "openstack"
81
85
  virtualization[:role] = "host"
82
86
  virtualization[:systems][:openstack] = "host"
@@ -85,6 +89,7 @@ Ohai.plugin(:Virtualization) do
85
89
  # Detect paravirt KVM/QEMU from cpuinfo, report as KVM
86
90
  if File.exist?("/proc/cpuinfo")
87
91
  if File.read("/proc/cpuinfo") =~ /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/
92
+ Ohai::Log.debug("Plugin Virtualization: /proc/cpuinfo lists a KVM paravirt CPU string. Detecting as kvm guest")
88
93
  virtualization[:system] = "kvm"
89
94
  virtualization[:role] = "guest"
90
95
  virtualization[:systems][:kvm] = "guest"
@@ -96,9 +101,11 @@ Ohai.plugin(:Virtualization) do
96
101
  if File.exist?("/sys/devices/virtual/misc/kvm")
97
102
  virtualization[:system] = "kvm"
98
103
  if File.read("/proc/cpuinfo") =~ /hypervisor/
104
+ Ohai::Log.debug("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo lists the hypervisor feature. Detecting as kvm guest")
99
105
  virtualization[:role] = "guest"
100
106
  virtualization[:systems][:kvm] = "guest"
101
107
  else
108
+ Ohai::Log.debug("Plugin Virtualization: /sys/devices/virtual/misc/kvm present and /proc/cpuinfo does not list the hypervisor feature. Detecting as kvm host")
102
109
  virtualization[:role] = "host"
103
110
  virtualization[:systems][:kvm] = "host"
104
111
  end
@@ -107,10 +114,12 @@ Ohai.plugin(:Virtualization) do
107
114
  # Detect OpenVZ / Virtuozzo.
108
115
  # http://wiki.openvz.org/BC_proc_entries
109
116
  if File.exist?("/proc/bc/0")
117
+ Ohai::Log.debug("Plugin Virtualization: /proc/bc/0 exists. Detecting as openvz host")
110
118
  virtualization[:system] = "openvz"
111
119
  virtualization[:role] = "host"
112
120
  virtualization[:systems][:openvz] = "host"
113
121
  elsif File.exist?("/proc/vz")
122
+ Ohai::Log.debug("Plugin Virtualization: /proc/vz exists. Detecting as openvz guest")
114
123
  virtualization[:system] = "openvz"
115
124
  virtualization[:role] = "guest"
116
125
  virtualization[:systems][:openvz] = "guest"
@@ -119,6 +128,7 @@ Ohai.plugin(:Virtualization) do
119
128
  # Detect Parallels virtual machine from pci devices
120
129
  if File.exist?("/proc/bus/pci/devices")
121
130
  if File.read("/proc/bus/pci/devices") =~ /1ab84000/
131
+ Ohai::Log.debug("Plugin Virtualization: /proc/bus/pci/devices contains '1ab84000' pci device. Detecting as parallels guest")
122
132
  virtualization[:system] = "parallels"
123
133
  virtualization[:role] = "guest"
124
134
  virtualization[:systems][:parallels] = "guest"
@@ -129,6 +139,7 @@ Ohai.plugin(:Virtualization) do
129
139
  if File.exist?("/usr/sbin/dmidecode")
130
140
  guest = guest_from_dmi(shell_out("dmidecode").stdout)
131
141
  if guest
142
+ Ohai::Log.debug("Plugin Virtualization: dmidecode contains string indicating #{guest} guest")
132
143
  virtualization[:system] = guest
133
144
  virtualization[:role] = "guest"
134
145
  virtualization[:systems][guest.to_sym] = "guest"
@@ -142,9 +153,11 @@ Ohai.plugin(:Virtualization) do
142
153
  if vxid && vxid[2]
143
154
  virtualization[:system] = "linux-vserver"
144
155
  if vxid[2] == "0"
156
+ Ohai::Log.debug("Plugin Virtualization: /proc/self/status contains 's_context' or 'VxID' with a value of 0. Detecting as linux-vserver host")
145
157
  virtualization[:role] = "host"
146
158
  virtualization[:systems]["linux-vserver"] = "host"
147
159
  else
160
+ Ohai::Log.debug("Plugin Virtualization: /proc/self/status contains 's_context' or 'VxID' with a non-0 value. Detecting as linux-vserver guest")
148
161
  virtualization[:role] = "guest"
149
162
  virtualization[:systems]["linux-vserver"] = "guest"
150
163
  end
@@ -173,6 +186,7 @@ Ohai.plugin(:Virtualization) do
173
186
  cgroup_content = File.read("/proc/self/cgroup")
174
187
  if cgroup_content =~ %r{^\d+:[^:]+:/(lxc|docker)/.+$} ||
175
188
  cgroup_content =~ %r{^\d+:[^:]+:/[^/]+/(lxc|docker)-.+$}
189
+ Ohai::Log.debug("Plugin Virtualization: /proc/self/cgroup indicates #{$1} container. Detecting as #{$1} guest")
176
190
  virtualization[:system] = $1
177
191
  virtualization[:role] = "guest"
178
192
  virtualization[:systems][$1.to_sym] = "guest"
@@ -181,6 +195,7 @@ Ohai.plugin(:Virtualization) do
181
195
  # Even so, it is likely we are on an LXC capable host that is not being used as such
182
196
  # So we're cautious here to not overwrite other existing values (OHAI-573)
183
197
  unless virtualization[:system] && virtualization[:role]
198
+ Ohai::Log.debug("Plugin Virtualization: /proc/self/cgroup and lxc-version command exist. Detecting as lxc host")
184
199
  virtualization[:system] = "lxc"
185
200
  virtualization[:role] = "host"
186
201
  end
@@ -190,6 +205,7 @@ Ohai.plugin(:Virtualization) do
190
205
  virtualization[:systems][:lxc] = "host"
191
206
  end
192
207
  elsif File.exist?("/.dockerenv") || File.exist?("/.dockerinit")
208
+ Ohai::Log.debug("Plugin Virtualization: .dockerenv or .dockerinit exist. Detecting as docker guest")
193
209
  virtualization[:system] = "docker"
194
210
  virtualization[:role] = "guest"
195
211
  virtualization[:systems][:docker] = "guest"
@@ -198,9 +214,11 @@ Ohai.plugin(:Virtualization) do
198
214
  # Detect LXD
199
215
  # See https://github.com/lxc/lxd/blob/master/doc/dev-lxd.md
200
216
  if File.exist?("/dev/lxd/sock")
217
+ Ohai::Log.debug("Plugin Virtualization: /dev/lxd/sock exists. Detecting as lxd guest")
201
218
  virtualization[:system] = "lxd"
202
219
  virtualization[:role] = "guest"
203
220
  elsif File.exist?("/var/lib/lxd/devlxd")
221
+ Ohai::Log.debug("Plugin Virtualization: /var/lib/lxd/devlxd exists. Detecting as lxd host")
204
222
  virtualization[:system] = "lxd"
205
223
  virtualization[:role] = "host"
206
224
  end
@@ -31,7 +31,7 @@ Ohai.plugin(:Lua) do
31
31
  languages[:lua] = lua if lua[:version]
32
32
  end
33
33
  rescue Ohai::Exceptions::Exec
34
- Ohai::Log.debug('Lua plugin: Could not shell_out "lua -v". Skipping plugin')
34
+ Ohai::Log.debug('Plugin Lua: Could not shell_out "lua -v". Skipping plugin')
35
35
  end
36
36
  end
37
37
  end
@@ -77,13 +77,13 @@ Ohai.plugin(:NetworkAddresses) do
77
77
  v[:iface] == network[int_attr]
78
78
  end
79
79
  if gw_if_ips.empty?
80
- Ohai::Log.warn("[#{family}] no ip address on #{network[int_attr]}")
80
+ Ohai::Log.warn("Plugin Network: [#{family}] no ip address on #{network[int_attr]}")
81
81
  elsif network[gw_attr] &&
82
82
  network["interfaces"][network[int_attr]] &&
83
83
  network["interfaces"][network[int_attr]]["addresses"]
84
84
  if [ "0.0.0.0", "::", /^fe80:/ ].any? { |pat| pat === network[gw_attr] }
85
85
  # link level default route
86
- Ohai::Log.debug("link level default #{family} route, picking ip from #{network[gw_attr]}")
86
+ Ohai::Log.debug("Plugin Network: link level default #{family} route, picking ip from #{network[gw_attr]}")
87
87
  r = gw_if_ips.first
88
88
  else
89
89
  # checking network masks
@@ -92,9 +92,9 @@ Ohai.plugin(:NetworkAddresses) do
92
92
  end.first
93
93
  if r.nil?
94
94
  r = gw_if_ips.first
95
- Ohai::Log.debug("[#{family}] no ipaddress/mask on #{network[int_attr]} matching the gateway #{network[gw_attr]}, picking #{r[:ipaddress]}")
95
+ Ohai::Log.debug("Plugin Network: [#{family}] no ipaddress/mask on #{network[int_attr]} matching the gateway #{network[gw_attr]}, picking #{r[:ipaddress]}")
96
96
  else
97
- Ohai::Log.debug("[#{family}] Using default interface #{network[int_attr]} and default gateway #{network[gw_attr]} to set the default ip to #{r[:ipaddress]}")
97
+ Ohai::Log.debug("Plugin Network: [#{family}] Using default interface #{network[int_attr]} and default gateway #{network[gw_attr]} to set the default ip to #{r[:ipaddress]}")
98
98
  end
99
99
  end
100
100
  else
@@ -103,7 +103,7 @@ Ohai.plugin(:NetworkAddresses) do
103
103
  end
104
104
  else
105
105
  r = ips.first
106
- Ohai::Log.debug("[#{family}] no default interface, picking the first ipaddress")
106
+ Ohai::Log.debug("Plugin Network: [#{family}] no default interface, picking the first ipaddress")
107
107
  end
108
108
 
109
109
  return [ nil, nil ] if r.nil? || r.empty?
@@ -149,13 +149,13 @@ Ohai.plugin(:NetworkAddresses) do
149
149
  # don't overwrite attributes if they've already been set by the "#{os}::network" plugin
150
150
  if (family == "inet") && ipaddress.nil?
151
151
  if r["ip"].nil?
152
- Ohai::Log.warn("unable to detect ipaddress")
152
+ Ohai::Log.warn("Plugin Network: unable to detect ipaddress")
153
153
  else
154
154
  ipaddress r["ip"]
155
155
  end
156
156
  elsif (family == "inet6") && ip6address.nil?
157
157
  if r["ip"].nil?
158
- Ohai::Log.debug("unable to detect ip6address")
158
+ Ohai::Log.debug("Plugin Network: unable to detect ip6address")
159
159
  else
160
160
  ip6address r["ip"]
161
161
  end
@@ -165,10 +165,10 @@ Ohai.plugin(:NetworkAddresses) do
165
165
  # otherwise we set macaddress on a first-found basis (and we started with ipv4)
166
166
  if macaddress.nil?
167
167
  if r["mac"]
168
- Ohai::Log.debug("setting macaddress to '#{r["mac"]}' from interface '#{r["iface"]}' for family '#{family}'")
168
+ Ohai::Log.debug("Plugin Network: setting macaddress to '#{r["mac"]}' from interface '#{r["iface"]}' for family '#{family}'")
169
169
  macaddress r["mac"]
170
170
  else
171
- Ohai::Log.debug("unable to detect macaddress for family '#{family}'")
171
+ Ohai::Log.debug("Plugin Network: unable to detect macaddress for family '#{family}'")
172
172
  end
173
173
  end
174
174
 
@@ -177,7 +177,7 @@ Ohai.plugin(:NetworkAddresses) do
177
177
 
178
178
  if results["inet"]["iface"] && results["inet6"]["iface"] &&
179
179
  (results["inet"]["iface"] != results["inet6"]["iface"])
180
- Ohai::Log.debug("ipaddress and ip6address are set from different interfaces (#{results["inet"]["iface"]} & #{results["inet6"]["iface"]})")
180
+ Ohai::Log.debug("Plugin Network: ipaddress and ip6address are set from different interfaces (#{results["inet"]["iface"]} & #{results["inet6"]["iface"]})")
181
181
  end
182
182
  end
183
183
  end