ohai 16.5.6 → 16.10.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -8
  3. data/bin/ohai +1 -0
  4. data/lib/ohai.rb +1 -0
  5. data/lib/ohai/application.rb +40 -0
  6. data/lib/ohai/common/dmi.rb +8 -3
  7. data/lib/ohai/config.rb +1 -0
  8. data/lib/ohai/dsl.rb +1 -0
  9. data/lib/ohai/dsl/plugin.rb +9 -1
  10. data/lib/ohai/dsl/plugin/versionvii.rb +28 -17
  11. data/lib/ohai/exception.rb +1 -0
  12. data/lib/ohai/hints.rb +1 -0
  13. data/lib/ohai/log.rb +1 -0
  14. data/lib/ohai/mash.rb +1 -0
  15. data/lib/ohai/mixin/azure_metadata.rb +4 -3
  16. data/lib/ohai/mixin/chef_utils_wiring.rb +14 -1
  17. data/lib/ohai/mixin/command.rb +1 -0
  18. data/lib/ohai/mixin/constant_helper.rb +1 -0
  19. data/lib/ohai/mixin/dmi_decode.rb +1 -0
  20. data/lib/ohai/mixin/do_metadata.rb +3 -2
  21. data/lib/ohai/mixin/ec2_metadata.rb +37 -11
  22. data/lib/ohai/mixin/gce_metadata.rb +4 -3
  23. data/lib/ohai/mixin/http_helper.rb +1 -0
  24. data/lib/ohai/mixin/network_helper.rb +1 -0
  25. data/lib/ohai/mixin/os.rb +67 -1
  26. data/lib/ohai/mixin/scaleway_metadata.rb +3 -2
  27. data/lib/ohai/mixin/seconds_to_human.rb +1 -0
  28. data/lib/ohai/mixin/shell_out.rb +1 -0
  29. data/lib/ohai/mixin/softlayer_metadata.rb +2 -1
  30. data/lib/ohai/mixin/string.rb +1 -0
  31. data/lib/ohai/mixin/train_helpers.rb +36 -0
  32. data/lib/ohai/mixin/which.rb +1 -0
  33. data/lib/ohai/plugin_config.rb +1 -0
  34. data/lib/ohai/plugins/aix/kernel.rb +7 -4
  35. data/lib/ohai/plugins/aix/memory.rb +4 -3
  36. data/lib/ohai/plugins/aix/network.rb +51 -58
  37. data/lib/ohai/plugins/aix/platform.rb +3 -2
  38. data/lib/ohai/plugins/aix/uptime.rb +3 -2
  39. data/lib/ohai/plugins/aix/virtualization.rb +6 -6
  40. data/lib/ohai/plugins/azure.rb +25 -4
  41. data/lib/ohai/plugins/bsd/virtualization.rb +3 -2
  42. data/lib/ohai/plugins/c.rb +4 -3
  43. data/lib/ohai/plugins/chef.rb +2 -1
  44. data/lib/ohai/plugins/cloud.rb +2 -1
  45. data/lib/ohai/plugins/command.rb +1 -0
  46. data/lib/ohai/plugins/cpu.rb +31 -32
  47. data/lib/ohai/plugins/darwin/hardware.rb +1 -0
  48. data/lib/ohai/plugins/darwin/memory.rb +2 -3
  49. data/lib/ohai/plugins/darwin/network.rb +8 -9
  50. data/lib/ohai/plugins/darwin/platform.rb +1 -0
  51. data/lib/ohai/plugins/darwin/virtualization.rb +2 -1
  52. data/lib/ohai/plugins/digital_ocean.rb +3 -1
  53. data/lib/ohai/plugins/dmi.rb +6 -5
  54. data/lib/ohai/plugins/docker.rb +2 -1
  55. data/lib/ohai/plugins/dragonflybsd/memory.rb +9 -8
  56. data/lib/ohai/plugins/dragonflybsd/network.rb +1 -0
  57. data/lib/ohai/plugins/dragonflybsd/platform.rb +3 -2
  58. data/lib/ohai/plugins/ec2.rb +17 -7
  59. data/lib/ohai/plugins/elixir.rb +1 -1
  60. data/lib/ohai/plugins/erlang.rb +1 -0
  61. data/lib/ohai/plugins/eucalyptus.rb +4 -1
  62. data/lib/ohai/plugins/filesystem.rb +4 -4
  63. data/lib/ohai/plugins/fips.rb +1 -0
  64. data/lib/ohai/plugins/freebsd/memory.rb +9 -8
  65. data/lib/ohai/plugins/freebsd/network.rb +1 -0
  66. data/lib/ohai/plugins/freebsd/platform.rb +3 -2
  67. data/lib/ohai/plugins/gce.rb +3 -2
  68. data/lib/ohai/plugins/go.rb +1 -1
  69. data/lib/ohai/plugins/groovy.rb +1 -1
  70. data/lib/ohai/plugins/grub2.rb +40 -0
  71. data/lib/ohai/plugins/haskell.rb +1 -0
  72. data/lib/ohai/plugins/hostname.rb +2 -2
  73. data/lib/ohai/plugins/init_package.rb +2 -1
  74. data/lib/ohai/plugins/java.rb +1 -0
  75. data/lib/ohai/plugins/kernel.rb +14 -11
  76. data/lib/ohai/plugins/keys.rb +1 -0
  77. data/lib/ohai/plugins/languages.rb +1 -0
  78. data/lib/ohai/plugins/libvirt.rb +4 -3
  79. data/lib/ohai/plugins/linode.rb +22 -14
  80. data/lib/ohai/plugins/linux/block_device.rb +9 -8
  81. data/lib/ohai/plugins/linux/hostnamectl.rb +3 -2
  82. data/lib/ohai/plugins/linux/interrupts.rb +4 -3
  83. data/lib/ohai/plugins/linux/ipc.rb +1 -0
  84. data/lib/ohai/plugins/linux/lsb.rb +7 -20
  85. data/lib/ohai/plugins/linux/lspci.rb +1 -1
  86. data/lib/ohai/plugins/linux/machineid.rb +5 -4
  87. data/lib/ohai/plugins/linux/mdadm.rb +3 -2
  88. data/lib/ohai/plugins/linux/memory.rb +38 -37
  89. data/lib/ohai/plugins/linux/network.rb +33 -7
  90. data/lib/ohai/plugins/linux/platform.rb +32 -31
  91. data/lib/ohai/plugins/linux/selinux.rb +1 -0
  92. data/lib/ohai/plugins/linux/sessions.rb +1 -0
  93. data/lib/ohai/plugins/linux/sysctl.rb +1 -0
  94. data/lib/ohai/plugins/linux/systemd_paths.rb +1 -0
  95. data/lib/ohai/plugins/linux/virtualization.rb +24 -23
  96. data/lib/ohai/plugins/lua.rb +1 -1
  97. data/lib/ohai/plugins/mono.rb +1 -1
  98. data/lib/ohai/plugins/netbsd/memory.rb +1 -0
  99. data/lib/ohai/plugins/netbsd/network.rb +1 -0
  100. data/lib/ohai/plugins/netbsd/platform.rb +3 -2
  101. data/lib/ohai/plugins/network.rb +2 -1
  102. data/lib/ohai/plugins/nodejs.rb +1 -1
  103. data/lib/ohai/plugins/ohai.rb +1 -0
  104. data/lib/ohai/plugins/ohai_time.rb +2 -1
  105. data/lib/ohai/plugins/openbsd/memory.rb +1 -0
  106. data/lib/ohai/plugins/openbsd/network.rb +1 -0
  107. data/lib/ohai/plugins/openbsd/platform.rb +3 -2
  108. data/lib/ohai/plugins/openstack.rb +1 -0
  109. data/lib/ohai/plugins/os.rb +6 -1
  110. data/lib/ohai/plugins/packages.rb +2 -1
  111. data/lib/ohai/plugins/passwd.rb +58 -1
  112. data/lib/ohai/plugins/perl.rb +1 -1
  113. data/lib/ohai/plugins/php.rb +1 -1
  114. data/lib/ohai/plugins/platform.rb +1 -0
  115. data/lib/ohai/plugins/powershell.rb +1 -1
  116. data/lib/ohai/plugins/ps.rb +1 -0
  117. data/lib/ohai/plugins/python.rb +1 -1
  118. data/lib/ohai/plugins/rackspace.rb +6 -5
  119. data/lib/ohai/plugins/root_group.rb +1 -0
  120. data/lib/ohai/plugins/ruby.rb +3 -2
  121. data/lib/ohai/plugins/rust.rb +1 -1
  122. data/lib/ohai/plugins/scala.rb +1 -0
  123. data/lib/ohai/plugins/scaleway.rb +3 -2
  124. data/lib/ohai/plugins/scsi.rb +1 -1
  125. data/lib/ohai/plugins/shard.rb +1 -1
  126. data/lib/ohai/plugins/shells.rb +3 -2
  127. data/lib/ohai/plugins/softlayer.rb +1 -0
  128. data/lib/ohai/plugins/solaris2/dmi.rb +2 -1
  129. data/lib/ohai/plugins/solaris2/memory.rb +1 -0
  130. data/lib/ohai/plugins/solaris2/network.rb +2 -1
  131. data/lib/ohai/plugins/solaris2/platform.rb +8 -14
  132. data/lib/ohai/plugins/solaris2/virtualization.rb +4 -4
  133. data/lib/ohai/plugins/ssh_host_key.rb +13 -12
  134. data/lib/ohai/plugins/sysconf.rb +1 -0
  135. data/lib/ohai/plugins/timezone.rb +1 -0
  136. data/lib/ohai/plugins/train.rb +35 -0
  137. data/lib/ohai/plugins/uptime.rb +2 -1
  138. data/lib/ohai/plugins/virtualbox.rb +2 -1
  139. data/lib/ohai/plugins/vmware.rb +3 -3
  140. data/lib/ohai/plugins/windows/dmi.rb +1 -0
  141. data/lib/ohai/plugins/windows/drivers.rb +1 -0
  142. data/lib/ohai/plugins/windows/memory.rb +1 -0
  143. data/lib/ohai/plugins/windows/network.rb +2 -1
  144. data/lib/ohai/plugins/windows/platform.rb +1 -0
  145. data/lib/ohai/plugins/windows/system_enclosure.rb +1 -0
  146. data/lib/ohai/plugins/windows/virtualization.rb +1 -0
  147. data/lib/ohai/plugins/zpools.rb +5 -3
  148. data/lib/ohai/provides_map.rb +1 -0
  149. data/lib/ohai/runner.rb +7 -4
  150. data/lib/ohai/system.rb +33 -4
  151. data/lib/ohai/train_transport.rb +29 -0
  152. data/lib/ohai/util/file_helper.rb +1 -0
  153. data/lib/ohai/util/ip_helper.rb +2 -1
  154. data/lib/ohai/util/win32.rb +1 -0
  155. data/lib/ohai/version.rb +2 -1
  156. data/ohai.gemspec +3 -1
  157. metadata +22 -5
  158. data/lib/ohai/plugins/joyent.rb +0 -77
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Matt Ray (<matt@chef.io>)
3
4
  # Author:: Tim Smith (<tsmith@chef.io>)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Author:: Isa Farnik (<isa@chef.io>)
@@ -34,7 +35,11 @@ Ohai.plugin(:OS) do
34
35
 
35
36
  # This is __DragonFly_version / __FreeBSD_version. See sys/param.h or
36
37
  # http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html.
37
- os_version shell_out("sysctl -n kern.osreldate").stdout.split($/)[0]
38
+ os_version shell_out("sysctl -n kern.osreldate").stdout.strip
39
+ end
40
+
41
+ collect_data(:target) do
42
+ os collect_os
38
43
  end
39
44
 
40
45
  collect_data do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Author:: "Christian Höltje" <choltje@us.ibm.com>
2
3
  # Author:: "Christopher M. Luciano" <cmlucian@us.ibm.com>
3
4
  # Author:: Shahul Khajamohideen (<skhajamohid1@bloomberg.net>)
@@ -163,7 +164,7 @@ Ohai.plugin(:Packages) do
163
164
  # Output format is
164
165
  # name version
165
166
  so.stdout.lines do |pkg|
166
- name, version = pkg.split(" ")
167
+ name, version = pkg.split
167
168
  packages[name] = { "version" => version }
168
169
  end
169
170
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  Ohai.plugin(:Passwd) do
3
4
  provides "etc", "current_user"
@@ -42,6 +43,62 @@ Ohai.plugin(:Passwd) do
42
43
  end
43
44
 
44
45
  collect_data(:windows) do
45
- # Etc returns nil on Windows
46
+ require "wmi-lite/wmi" unless defined?(WmiLite::Wmi)
47
+
48
+ unless etc
49
+ etc Mash.new
50
+
51
+ wmi = WmiLite::Wmi.new
52
+
53
+ etc[:passwd] = Mash.new
54
+ users = wmi.query("SELECT * FROM Win32_UserAccount WHERE LocalAccount = True")
55
+ users.each do |user|
56
+ uname = user["Name"].strip.downcase
57
+ Ohai::Log.debug("processing user #{uname}")
58
+ etc[:passwd][uname] = Mash.new
59
+ wmi_obj = user.wmi_ole_object
60
+ wmi_obj.properties_.each do |key|
61
+ etc[:passwd][uname][key.name.downcase] = user[key.name]
62
+ end
63
+ end
64
+
65
+ etc[:group] = Mash.new
66
+ groups = wmi.query("SELECT * FROM Win32_Group WHERE LocalAccount = True")
67
+ groups.each do |group|
68
+ gname = group["Name"].strip.downcase
69
+ Ohai::Log.debug("processing group #{gname}")
70
+ etc[:group][gname] = Mash.new
71
+ wmi_obj = group.wmi_ole_object
72
+ wmi_obj.properties_.each do |key|
73
+ etc[:group][gname][key.name.downcase] = group[key.name]
74
+ end
75
+
76
+ # This is the primary reason that we're using WMI instead of powershell
77
+ # cmdlets - the powershell start up cost is huge, and you *must* do this
78
+ # query for every. single. group. individually.
79
+
80
+ # The query returns nothing unless you specify domain *and* name, it's
81
+ # a path, not a set of queries.
82
+ subq = "Win32_Group.Domain='#{group["Domain"]}',Name='#{group["Name"]}'"
83
+ members = wmi.query(
84
+ "SELECT * FROM Win32_GroupUser WHERE GroupComponent=\"#{subq}\""
85
+ )
86
+ etc[:group][gname]["members"] = members.map do |member|
87
+ mi = {}
88
+ info = Hash[
89
+ member["partcomponent"].split(",").map { |x| x.split("=") }.map { |a, b| [a, b.undump] }
90
+ ]
91
+ if info.keys.any? { |x| x.match?("Win32_UserAccount") }
92
+ mi["type"] = :user
93
+ else
94
+ # NOTE: the type here is actually Win32_SystemAccount, because,
95
+ # that's what groups are in the Windows universe.
96
+ mi["type"] = :group
97
+ end
98
+ mi["name"] = info["Name"]
99
+ mi
100
+ end
101
+ end
102
+ end
46
103
  end
47
104
  end
@@ -18,7 +18,7 @@
18
18
 
19
19
  Ohai.plugin(:Perl) do
20
20
  provides "languages/perl"
21
- depends "languages"
21
+ depends "languages".freeze
22
22
 
23
23
  collect_data do
24
24
 
@@ -20,7 +20,7 @@
20
20
 
21
21
  Ohai.plugin(:PHP) do
22
22
  provides "languages/php"
23
- depends "languages"
23
+ depends "languages".freeze
24
24
 
25
25
  collect_data do
26
26
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -17,7 +17,7 @@
17
17
 
18
18
  Ohai.plugin(:Powershell) do
19
19
  provides "languages/powershell"
20
- depends "languages"
20
+ depends "languages".freeze
21
21
 
22
22
  collect_data(:windows) do
23
23
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Author:: Bryan McLellan (<btm@loftninjas.org>)
@@ -19,7 +19,7 @@
19
19
  Ohai.plugin(:Python) do
20
20
  provides "languages/python"
21
21
 
22
- depends "languages"
22
+ depends "languages".freeze
23
23
 
24
24
  collect_data do
25
25
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Cary Penniman (<cary@rightscale.com>)
3
4
  # License:: Apache License, Version 2.0
@@ -25,7 +26,7 @@ Ohai.plugin(:Rackspace) do
25
26
  # true:: If kernel name matches
26
27
  # false:: Otherwise
27
28
  def has_rackspace_kernel?
28
- kernel[:release].split("-").last.eql?("rscloud")
29
+ kernel[:release].end_with?("-rscloud")
29
30
  end
30
31
 
31
32
  # Checks for rackspace provider attribute
@@ -160,10 +161,10 @@ Ohai.plugin(:Rackspace) do
160
161
  get_global_ipv6_address(:public_ipv6, :eth0)
161
162
  unless rackspace[:public_ip].nil?
162
163
  rackspace[:public_hostname] = begin
163
- Resolv.getname(rackspace[:public_ip])
164
- rescue Resolv::ResolvError, Resolv::ResolvTimeout
165
- rackspace[:public_ip]
166
- end
164
+ Resolv.getname(rackspace[:public_ip])
165
+ rescue Resolv::ResolvError, Resolv::ResolvTimeout
166
+ rackspace[:public_ip]
167
+ end
167
168
  end
168
169
  rackspace[:local_ipv4] = rackspace[:private_ip]
169
170
  get_global_ipv6_address(:local_ipv6, :eth1)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Joseph Anthony Pasquale Holsten (<joseph@josephholsten.com>)
3
4
  # Copyright:: Copyright (c) 2013 Joseph Anthony Pasquale Holsten
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Adam Jacob (<adam@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -48,13 +49,13 @@ Ohai.plugin(:Ruby) do
48
49
  }
49
50
 
50
51
  # Create a query string from above hash
51
- env_string = ""
52
+ env_string = []
52
53
  values.each_key do |v|
53
54
  env_string << "#{v}=\#{#{values[v]}},"
54
55
  end
55
56
 
56
57
  # Query the system ruby
57
- result = run_ruby "require 'rubygems'; puts %Q(#{env_string})"
58
+ result = run_ruby "require 'rubygems'; puts %Q(#{env_string.join})"
58
59
 
59
60
  # Parse results to plugin hash
60
61
  result.split(",").each do |entry|
@@ -15,7 +15,7 @@
15
15
 
16
16
  Ohai.plugin(:Rust) do
17
17
  provides "languages/rust"
18
- depends "languages"
18
+ depends "languages".freeze
19
19
 
20
20
  collect_data do
21
21
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Author:: Christopher M Luciano (<cmlucian@us.ibm.com>)
2
3
  # © Copyright IBM Corporation 2015.
3
4
  # License:: Apache License, Version 2.0
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Jonathan Amiez (<jonathan.amiez@gmail.com>)
3
4
  # License:: Apache License, Version 2.0
@@ -26,7 +27,7 @@ Ohai.plugin(:Scaleway) do
26
27
  # looks for `scaleway` keyword in kernel command line
27
28
  # @return [Boolean] do we have the keyword or not?
28
29
  def has_scaleway_cmdline?
29
- if ::File.exist?("/proc/cmdline") && /scaleway/.match?(::File.read("/proc/cmdline"))
30
+ if file_exist?("/proc/cmdline") && /scaleway/.match?(file_read("/proc/cmdline"))
30
31
  logger.trace("Plugin Scaleway: has_scaleway_cmdline? == true")
31
32
  return true
32
33
  end
@@ -43,7 +44,7 @@ Ohai.plugin(:Scaleway) do
43
44
  false
44
45
  end
45
46
 
46
- collect_data do
47
+ collect_data(:linux) do
47
48
  if looks_like_scaleway?
48
49
  logger.trace("Plugin Scaleway: looks_like_scaleway? == true")
49
50
  scaleway Mash.new
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Phil Dibowitz <phil@ipom.com>
3
4
  # Copyright:: Copyright (c) 2018 Facebook, Inc.
@@ -17,7 +18,6 @@
17
18
  #
18
19
 
19
20
  Ohai.plugin(:Lsscsi) do
20
- depends "platform"
21
21
  provides "scsi"
22
22
  optional true
23
23
 
@@ -18,7 +18,7 @@
18
18
 
19
19
  Ohai.plugin(:ShardSeed) do
20
20
  depends "hostname", "dmi", "machine_id", "machinename", "fips", "hardware", "kernel"
21
- provides "shard_seed"
21
+ provides "shard_seed".freeze
22
22
 
23
23
  def get_dmi_property(dmi, thing)
24
24
  %w{system base_board chassis}.each do |section|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Tim Smith (<tsmith@chef.io>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -20,9 +21,9 @@ Ohai.plugin(:Shells) do
20
21
  provides "shells"
21
22
 
22
23
  collect_data do
23
- if ::File.exist?("/etc/shells")
24
+ if file_exist?("/etc/shells")
24
25
  shells []
25
- ::File.readlines("/etc/shells").each do |line|
26
+ file_open("/etc/shells").readlines.each do |line|
26
27
  # remove carriage returns and skip over comments / empty lines
27
28
  shells << line.chomp if line[0] == "/"
28
29
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Alexey Karpik <alexey.karpik@rightscale.com>
3
4
  # Author:: Peter Schroeter <peter.schroeter@rightscale.com>
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Kurt Yoder (ktyopscode@yoderhome.com)
3
4
  # Copyright:: Copyright (c) 2010 Kurt Yoder
@@ -128,7 +129,7 @@ Ohai.plugin(:DMI) do
128
129
  id = smb_to_id[header_information[3]]
129
130
 
130
131
  # Don't overcapture for now (OHAI-260)
131
- unless Ohai::Common::DMI.whitelisted_ids.include?(id)
132
+ unless Ohai::Common::DMI.allowlisted_ids.include?(id)
132
133
  dmi_record = nil
133
134
  next
134
135
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # License:: Apache License, Version 2.0
3
4
  #
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Benjamin Black (<nostromo@gmail.com>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -126,7 +127,7 @@ Ohai.plugin(:Network) do
126
127
  end
127
128
  if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask (([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
128
129
  iface[cint][:addresses] ||= Mash.new
129
- iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2) , "broadcast" => $4 }
130
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2), "broadcast" => $4 }
130
131
  end
131
132
  if line =~ %r{\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*)/(\d+)\s*$}
132
133
  iface[cint][:addresses] ||= Mash.new
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Benjamin Black (<nostromo@gmail.com>)
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -20,7 +21,7 @@ Ohai.plugin(:Platform) do
20
21
  provides "platform", "platform_version", "platform_build", "platform_family"
21
22
 
22
23
  collect_data(:solaris2) do
23
- if File.exist?("/sbin/uname")
24
+ if file_exist?("/sbin/uname")
24
25
  uname_exec = "/sbin/uname"
25
26
  else
26
27
  uname_exec = "uname"
@@ -35,26 +36,19 @@ Ohai.plugin(:Platform) do
35
36
  end
36
37
  end
37
38
 
38
- File.open("/etc/release") do |file|
39
+ file_open("/etc/release") do |file|
39
40
  while ( line = file.gets )
40
41
  case line
41
- when /^.*(SmartOS).*$/
42
+ when /.*SmartOS.*/
42
43
  platform "smartos"
43
- when /^\s*(OmniOS).*r(\d+).*$/
44
+ when /^\s*OmniOS.*r(\d+).*$/
44
45
  platform "omnios"
45
- platform_version $2
46
- when /^\s*(OpenIndiana).*oi_(\d+).*$/
46
+ platform_version $1
47
+ when /^\s*OpenIndiana.*(Development oi_|Hipster )(\d\S*)/ # https://rubular.com/r/iMtOBwbnyqDz7u
47
48
  platform "openindiana"
48
49
  platform_version $2
49
- when /^\s*(OpenSolaris).*snv_(\d+).*$/
50
- platform "opensolaris"
51
- platform_version $2
52
- when /^\s*(Oracle Solaris)/
53
- platform "solaris2"
54
- when /^\s*(Solaris)\s.*$/
50
+ when /^\s*(Oracle Solaris|Solaris)/
55
51
  platform "solaris2"
56
- when /^\s*(NexentaCore)\s.*$/
57
- platform "nexentacore"
58
52
  end
59
53
  end
60
54
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Sean Walbran (<seanwalbran@gmail.com>)
3
4
  # Author:: Kurt Yoder (<ktyopscode@yoderhome.com>)
@@ -34,7 +35,7 @@ Ohai.plugin(:Virtualization) do
34
35
 
35
36
  # Detect paravirt KVM/QEMU from cpuinfo, report as KVM
36
37
  psrinfo_path = Ohai.abs_path( "/usr/sbin/psrinfo" )
37
- if File.exist?(psrinfo_path)
38
+ if file_exist?(psrinfo_path)
38
39
  so = shell_out("#{psrinfo_path} -pv")
39
40
  if /QEMU Virtual CPU|Common KVM processor|Common 32-bit KVM processor/.match?(so.stdout)
40
41
  virtualization[:system] = "kvm"
@@ -55,7 +56,7 @@ Ohai.plugin(:Virtualization) do
55
56
  if File.executable?("/usr/sbin/zoneadm")
56
57
  zones = Mash.new
57
58
  shell_out("zoneadm list -pc").stdout.lines do |line|
58
- info = line.chomp.split(/:/)
59
+ info = line.chomp.split(":")
59
60
  zones[info[1]] = {
60
61
  "id" => info[0],
61
62
  "state" => info[2],
@@ -68,12 +69,11 @@ Ohai.plugin(:Virtualization) do
68
69
 
69
70
  if zones.length == 1
70
71
  first_zone = zones.keys[0]
72
+ virtualization[:system] = "zone"
71
73
  if first_zone == "global"
72
- virtualization[:system] = "zone"
73
74
  virtualization[:role] = "host"
74
75
  virtualization[:systems][:zone] = "host"
75
76
  else
76
- virtualization[:system] = "zone"
77
77
  virtualization[:role] = "guest"
78
78
  virtualization[:systems][:zone] = "guest"
79
79
  virtualization[:guest_uuid] = zones[first_zone]["uuid"]
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  #
2
3
  # Author:: Bryan McLellan <btm@chef.io>
3
4
  # Copyright:: Copyright (c) Chef Software Inc.
@@ -38,9 +39,9 @@ Ohai.plugin(:SSHHostKey) do
38
39
  collect_data do
39
40
  keys[:ssh] = Mash.new
40
41
 
41
- sshd_config = if File.exist?("/etc/ssh/sshd_config")
42
+ sshd_config = if file_exist?("/etc/ssh/sshd_config")
42
43
  "/etc/ssh/sshd_config"
43
- elsif File.exist?("/etc/sshd_config")
44
+ elsif file_exist?("/etc/sshd_config")
44
45
  # Darwin
45
46
  "/etc/sshd_config"
46
47
  else
@@ -49,11 +50,11 @@ Ohai.plugin(:SSHHostKey) do
49
50
  end
50
51
 
51
52
  if sshd_config
52
- File.open(sshd_config) do |conf|
53
+ file_open(sshd_config) do |conf|
53
54
  conf.each_line do |line|
54
55
  if /^hostkey\s/i.match?(line)
55
56
  pub_file = "#{line.split[1]}.pub"
56
- content = IO.read(pub_file).split
57
+ content = file_read(pub_file).split
57
58
  key_type, key_subtype = extract_keytype?(content)
58
59
  keys[:ssh]["host_#{key_type}_public"] = content[1] unless key_type.nil?
59
60
  keys[:ssh]["host_#{key_type}_type"] = key_subtype unless key_subtype.nil?
@@ -62,22 +63,22 @@ Ohai.plugin(:SSHHostKey) do
62
63
  end
63
64
  end
64
65
 
65
- if keys[:ssh][:host_dsa_public].nil? && File.exist?("/etc/ssh/ssh_host_dsa_key.pub")
66
- keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
66
+ if keys[:ssh][:host_dsa_public].nil? && file_exist?("/etc/ssh/ssh_host_dsa_key.pub")
67
+ keys[:ssh][:host_dsa_public] = file_read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
67
68
  end
68
69
 
69
- if keys[:ssh][:host_rsa_public].nil? && File.exist?("/etc/ssh/ssh_host_rsa_key.pub")
70
- keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
70
+ if keys[:ssh][:host_rsa_public].nil? && file_exist?("/etc/ssh/ssh_host_rsa_key.pub")
71
+ keys[:ssh][:host_rsa_public] = file_read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
71
72
  end
72
73
 
73
- if keys[:ssh][:host_ecdsa_public].nil? && File.exist?("/etc/ssh/ssh_host_ecdsa_key.pub")
74
- content = IO.read("/etc/ssh/ssh_host_ecdsa_key.pub")
74
+ if keys[:ssh][:host_ecdsa_public].nil? && file_exist?("/etc/ssh/ssh_host_ecdsa_key.pub")
75
+ content = file_read("/etc/ssh/ssh_host_ecdsa_key.pub")
75
76
  keys[:ssh][:host_ecdsa_public] = content.split[1]
76
77
  keys[:ssh][:host_ecdsa_type] = content.split[0]
77
78
  end
78
79
 
79
- if keys[:ssh][:host_ed25519_public].nil? && File.exist?("/etc/ssh/ssh_host_ed25519_key.pub")
80
- keys[:ssh][:host_ed25519_public] = IO.read("/etc/ssh/ssh_host_ed25519_key.pub").split[1]
80
+ if keys[:ssh][:host_ed25519_public].nil? && file_exist?("/etc/ssh/ssh_host_ed25519_key.pub")
81
+ keys[:ssh][:host_ed25519_public] = file_read("/etc/ssh/ssh_host_ed25519_key.pub").split[1]
81
82
  end
82
83
  end
83
84
  end