ohai 8.8.1 → 8.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/README.md +1 -1
  4. data/Rakefile +6 -0
  5. data/bin/ohai +2 -2
  6. data/lib/ohai.rb +4 -4
  7. data/lib/ohai/config.rb +2 -2
  8. data/lib/ohai/dsl.rb +2 -2
  9. data/lib/ohai/dsl/plugin.rb +3 -3
  10. data/lib/ohai/dsl/plugin/versionvi.rb +3 -3
  11. data/lib/ohai/dsl/plugin/versionvii.rb +2 -2
  12. data/lib/ohai/exception.rb +2 -2
  13. data/lib/ohai/hints.rb +2 -2
  14. data/lib/ohai/loader.rb +1 -1
  15. data/lib/ohai/log.rb +2 -2
  16. data/lib/ohai/mixin/command.rb +2 -2
  17. data/lib/ohai/mixin/constant_helper.rb +2 -2
  18. data/lib/ohai/mixin/dmi_decode.rb +1 -1
  19. data/lib/ohai/mixin/ec2_metadata.rb +3 -3
  20. data/lib/ohai/mixin/network_constants.rb +4 -4
  21. data/lib/ohai/mixin/os.rb +2 -2
  22. data/lib/ohai/mixin/seconds_to_human.rb +4 -4
  23. data/lib/ohai/mixin/string.rb +4 -4
  24. data/lib/ohai/plugin_config.rb +1 -1
  25. data/lib/ohai/plugins/aix/cpu.rb +35 -29
  26. data/lib/ohai/plugins/aix/filesystem.rb +58 -40
  27. data/lib/ohai/plugins/aix/kernel.rb +3 -2
  28. data/lib/ohai/plugins/aix/memory.rb +4 -3
  29. data/lib/ohai/plugins/aix/network.rb +6 -4
  30. data/lib/ohai/plugins/aix/os.rb +30 -0
  31. data/lib/ohai/plugins/aix/platform.rb +3 -2
  32. data/lib/ohai/plugins/aix/uptime.rb +3 -2
  33. data/lib/ohai/plugins/aix/virtualization.rb +115 -5
  34. data/lib/ohai/plugins/azure.rb +1 -1
  35. data/lib/ohai/plugins/bsd/filesystem.rb +1 -1
  36. data/lib/ohai/plugins/command.rb +4 -4
  37. data/lib/ohai/plugins/darwin/cpu.rb +5 -3
  38. data/lib/ohai/plugins/darwin/filesystem.rb +4 -4
  39. data/lib/ohai/plugins/darwin/filesystem2.rb +4 -4
  40. data/lib/ohai/plugins/darwin/memory.rb +6 -5
  41. data/lib/ohai/plugins/darwin/network.rb +2 -2
  42. data/lib/ohai/plugins/darwin/platform.rb +2 -2
  43. data/lib/ohai/plugins/darwin/system_profiler.rb +2 -2
  44. data/lib/ohai/plugins/dragonflybsd/os.rb +2 -2
  45. data/lib/ohai/plugins/ec2.rb +3 -3
  46. data/lib/ohai/plugins/erlang.rb +3 -3
  47. data/lib/ohai/plugins/eucalyptus.rb +3 -3
  48. data/lib/ohai/plugins/freebsd/cpu.rb +8 -4
  49. data/lib/ohai/plugins/freebsd/os.rb +2 -2
  50. data/lib/ohai/plugins/hostname.rb +12 -4
  51. data/lib/ohai/plugins/init_package.rb +2 -8
  52. data/lib/ohai/plugins/java.rb +2 -2
  53. data/lib/ohai/plugins/kernel.rb +5 -4
  54. data/lib/ohai/plugins/keys.rb +3 -3
  55. data/lib/ohai/plugins/languages.rb +4 -4
  56. data/lib/ohai/plugins/linux/block_device.rb +3 -3
  57. data/lib/ohai/plugins/linux/cpu.rb +2 -2
  58. data/lib/ohai/plugins/linux/filesystem.rb +2 -2
  59. data/lib/ohai/plugins/linux/filesystem2.rb +3 -3
  60. data/lib/ohai/plugins/linux/lsb.rb +2 -2
  61. data/lib/ohai/plugins/linux/memory.rb +2 -2
  62. data/lib/ohai/plugins/linux/network.rb +141 -59
  63. data/lib/ohai/plugins/linux/platform.rb +6 -1
  64. data/lib/ohai/plugins/linux/virtualization.rb +1 -1
  65. data/lib/ohai/plugins/network.rb +49 -42
  66. data/lib/ohai/plugins/ohai_time.rb +4 -4
  67. data/lib/ohai/plugins/openstack.rb +2 -2
  68. data/lib/ohai/plugins/os.rb +2 -2
  69. data/lib/ohai/plugins/packages.rb +122 -0
  70. data/lib/ohai/plugins/perl.rb +5 -5
  71. data/lib/ohai/plugins/platform.rb +2 -2
  72. data/lib/ohai/plugins/powershell.rb +2 -2
  73. data/lib/ohai/plugins/ps.rb +2 -2
  74. data/lib/ohai/plugins/python.rb +1 -1
  75. data/lib/ohai/plugins/rackspace.rb +13 -0
  76. data/lib/ohai/plugins/ruby.rb +6 -6
  77. data/lib/ohai/plugins/sigar/network_route.rb +1 -1
  78. data/lib/ohai/plugins/solaris2/filesystem.rb +1 -1
  79. data/lib/ohai/plugins/solaris2/network.rb +1 -1
  80. data/lib/ohai/plugins/solaris2/platform.rb +1 -1
  81. data/lib/ohai/plugins/solaris2/virtualization.rb +5 -5
  82. data/lib/ohai/plugins/solaris2/zpools.rb +2 -2
  83. data/lib/ohai/plugins/ssh_host_key.rb +2 -2
  84. data/lib/ohai/plugins/uptime.rb +4 -4
  85. data/lib/ohai/plugins/virtualbox.rb +1 -1
  86. data/lib/ohai/plugins/virtualization.rb +7 -7
  87. data/lib/ohai/plugins/vmware.rb +1 -1
  88. data/lib/ohai/plugins/windows/filesystem.rb +1 -1
  89. data/lib/ohai/plugins/windows/network.rb +1 -1
  90. data/lib/ohai/plugins/windows/platform.rb +1 -1
  91. data/lib/ohai/plugins/windows/virtualization.rb +1 -1
  92. data/lib/ohai/provides_map.rb +3 -3
  93. data/lib/ohai/runner.rb +2 -2
  94. data/lib/ohai/system.rb +2 -2
  95. data/lib/ohai/util/file_helper.rb +1 -1
  96. data/lib/ohai/util/win32.rb +1 -1
  97. data/lib/ohai/util/win32/group_helper.rb +1 -1
  98. data/lib/ohai/version.rb +3 -3
  99. data/spec/data/plugins/dpkg-query.output +1087 -0
  100. data/spec/data/plugins/lslpp.output +49 -0
  101. data/spec/data/plugins/pkginfo.output +50 -0
  102. data/spec/data/plugins/pkglist.output +24 -0
  103. data/spec/data/plugins/rpmquery.output +388 -0
  104. data/spec/functional/application_spec.rb +1 -1
  105. data/spec/functional/loader_spec.rb +1 -1
  106. data/spec/functional/plugins/powershell_spec.rb +1 -1
  107. data/spec/functional/plugins/root_group_spec.rb +2 -2
  108. data/spec/ohai_spec.rb +6 -6
  109. data/spec/unit/application_spec.rb +1 -1
  110. data/spec/unit/config_spec.rb +1 -1
  111. data/spec/unit/dsl/plugin_spec.rb +2 -2
  112. data/spec/unit/hints_spec.rb +2 -2
  113. data/spec/unit/loader_spec.rb +2 -2
  114. data/spec/unit/mixin/ec2_metadata_spec.rb +1 -1
  115. data/spec/unit/plugin_config_spec.rb +1 -1
  116. data/spec/unit/plugins/aix/cpu_spec.rb +68 -40
  117. data/spec/unit/plugins/aix/filesystem_spec.rb +152 -50
  118. data/spec/unit/plugins/aix/hostname_spec.rb +5 -3
  119. data/spec/unit/plugins/aix/kernel_spec.rb +2 -1
  120. data/spec/unit/plugins/aix/memory_spec.rb +7 -5
  121. data/spec/unit/plugins/aix/network_spec.rb +17 -1
  122. data/spec/unit/plugins/aix/os_spec.rb +35 -0
  123. data/spec/unit/plugins/aix/platform_spec.rb +5 -4
  124. data/spec/unit/plugins/aix/uptime_spec.rb +2 -1
  125. data/spec/unit/plugins/aix/virtualization_spec.rb +269 -3
  126. data/spec/unit/plugins/azure_spec.rb +1 -1
  127. data/spec/unit/plugins/bsd/filesystem_spec.rb +1 -1
  128. data/spec/unit/plugins/bsd/virtualization_spec.rb +2 -2
  129. data/spec/unit/plugins/chef_spec.rb +8 -8
  130. data/spec/unit/plugins/darwin/cpu_spec.rb +8 -3
  131. data/spec/unit/plugins/darwin/hostname_spec.rb +2 -2
  132. data/spec/unit/plugins/darwin/kernel_spec.rb +4 -4
  133. data/spec/unit/plugins/darwin/memory_spec.rb +1 -1
  134. data/spec/unit/plugins/darwin/network_spec.rb +1 -1
  135. data/spec/unit/plugins/darwin/platform_spec.rb +6 -6
  136. data/spec/unit/plugins/darwin/system_profiler_output.rb +0 -1
  137. data/spec/unit/plugins/darwin/system_profiler_spec.rb +4 -4
  138. data/spec/unit/plugins/ec2_spec.rb +3 -3
  139. data/spec/unit/plugins/erlang_spec.rb +3 -3
  140. data/spec/unit/plugins/eucalyptus_spec.rb +2 -2
  141. data/spec/unit/plugins/fail_spec.rb +6 -6
  142. data/spec/unit/plugins/freebsd/cpu_spec.rb +19 -4
  143. data/spec/unit/plugins/freebsd/hostname_spec.rb +2 -2
  144. data/spec/unit/plugins/freebsd/kernel_spec.rb +4 -4
  145. data/spec/unit/plugins/freebsd/platform_spec.rb +7 -7
  146. data/spec/unit/plugins/hostname_spec.rb +2 -2
  147. data/spec/unit/plugins/init_package_spec.rb +12 -2
  148. data/spec/unit/plugins/java_spec.rb +5 -5
  149. data/spec/unit/plugins/kernel_spec.rb +4 -2
  150. data/spec/unit/plugins/linux/block_device_spec.rb +75 -0
  151. data/spec/unit/plugins/linux/cpu_spec.rb +2 -2
  152. data/spec/unit/plugins/linux/filesystem2_spec.rb +14 -14
  153. data/spec/unit/plugins/linux/filesystem_spec.rb +1 -1
  154. data/spec/unit/plugins/linux/hostname_spec.rb +2 -2
  155. data/spec/unit/plugins/linux/kernel_spec.rb +5 -5
  156. data/spec/unit/plugins/linux/lsb_spec.rb +17 -17
  157. data/spec/unit/plugins/linux/network_spec.rb +80 -11
  158. data/spec/unit/plugins/linux/platform_spec.rb +20 -1
  159. data/spec/unit/plugins/linux/uptime_spec.rb +8 -8
  160. data/spec/unit/plugins/linux/virtualization_spec.rb +1 -1
  161. data/spec/unit/plugins/lua_spec.rb +2 -2
  162. data/spec/unit/plugins/netbsd/hostname_spec.rb +2 -2
  163. data/spec/unit/plugins/netbsd/kernel_spec.rb +2 -2
  164. data/spec/unit/plugins/netbsd/platform_spec.rb +2 -2
  165. data/spec/unit/plugins/network_spec.rb +110 -37
  166. data/spec/unit/plugins/nodejs_spec.rb +2 -2
  167. data/spec/unit/plugins/ohai_spec.rb +5 -5
  168. data/spec/unit/plugins/ohai_time_spec.rb +8 -8
  169. data/spec/unit/plugins/openbsd/hostname_spec.rb +2 -2
  170. data/spec/unit/plugins/openbsd/kernel_spec.rb +4 -4
  171. data/spec/unit/plugins/openbsd/platform_spec.rb +6 -6
  172. data/spec/unit/plugins/openstack_spec.rb +2 -2
  173. data/spec/unit/plugins/os_spec.rb +11 -11
  174. data/spec/unit/plugins/packages_spec.rb +241 -0
  175. data/spec/unit/plugins/perl_spec.rb +3 -3
  176. data/spec/unit/plugins/php_spec.rb +2 -2
  177. data/spec/unit/plugins/platform_spec.rb +2 -2
  178. data/spec/unit/plugins/python_spec.rb +3 -3
  179. data/spec/unit/plugins/rackspace_spec.rb +7 -0
  180. data/spec/unit/plugins/ruby_spec.rb +3 -3
  181. data/spec/unit/plugins/sigar/network_route_spec.rb +1 -1
  182. data/spec/unit/plugins/solaris2/cpu_spec.rb +1 -1
  183. data/spec/unit/plugins/solaris2/filesystem.rb +1 -1
  184. data/spec/unit/plugins/solaris2/network_spec.rb +3 -3
  185. data/spec/unit/plugins/solaris2/platform_spec.rb +5 -5
  186. data/spec/unit/plugins/solaris2/virtualization_spec.rb +1 -1
  187. data/spec/unit/plugins/ssh_host_keys_spec.rb +2 -2
  188. data/spec/unit/plugins/virtualbox_spec.rb +1 -1
  189. data/spec/unit/plugins/windows/virtualization_spec.rb +1 -1
  190. data/spec/unit/provides_map_spec.rb +2 -2
  191. data/spec/unit/runner_spec.rb +2 -2
  192. data/spec/unit/system_spec.rb +3 -3
  193. data/spec/unit/util/file_helper_spec.rb +1 -1
  194. metadata +13 -3
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) 2015-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -142,6 +142,9 @@ Ohai.plugin(:Platform) do
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')
146
+ platform "alpine"
147
+ platform_version File.read("/etc/alpine-release").strip()
145
148
  elsif os_release_file_is_cisco?
146
149
  raise 'unknown Cisco /etc/os-release or /etc/cisco-release ID_LIKE field' if
147
150
  os_release_info['ID_LIKE'].nil? || ! os_release_info['ID_LIKE'].include?('wrlinux')
@@ -191,6 +194,8 @@ Ohai.plugin(:Platform) do
191
194
  platform_family "arch"
192
195
  when /exherbo/
193
196
  platform_family "exherbo"
197
+ when /alpine/
198
+ platform_family "alpine"
194
199
  end
195
200
  end
196
201
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Thom May (<thom@clearairturbulence.org>)
3
- # Copyright:: Copyright (c) 2009 Opscode, Inc.
3
+ # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,14 +1,14 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
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.
@@ -26,19 +26,21 @@ Ohai.plugin(:NetworkAddresses) do
26
26
 
27
27
  depends "network/interfaces"
28
28
 
29
+ # from interface data create array of hashes with ipaddress, scope, and iface
30
+ # sorted by scope, prefixlen and then ipaddress where longest prefixes first
29
31
  def sorted_ips(family = "inet")
30
- raise "bad family #{family}" unless [ "inet", "inet6" ].include? family
32
+ fail "bad family #{family}" unless %w(inet inet6).include? family
31
33
 
32
- # going to use that later to sort by scope
34
+ # priority of ipv6 link scopes to sort by later
33
35
  scope_prio = [ "global", "site", "link", "host", "node", nil ]
34
36
 
37
+ # grab ipaddress, scope, and iface for sorting later
35
38
  ipaddresses = []
36
- # ipaddresses going to hold #{family} ipaddresses and their scope
37
39
  Mash[network['interfaces']].each do |iface, iface_v|
38
- next if iface_v.nil? or not iface_v.has_key? 'addresses'
40
+ next if iface_v.nil? || !iface_v.has_key?('addresses')
39
41
  iface_v['addresses'].each do |addr, addr_v|
40
42
  next if addr_v.nil? or not addr_v.has_key? "family" or addr_v['family'] != family
41
- ipaddresses << {
43
+ ipaddresses << {
42
44
  :ipaddress => addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"),
43
45
  :scope => addr_v["scope"].nil? ? nil : addr_v["scope"].downcase,
44
46
  :iface => iface
@@ -49,35 +51,35 @@ Ohai.plugin(:NetworkAddresses) do
49
51
  # sort ip addresses by scope, by prefixlen and then by ip address
50
52
  # 128 - prefixlen: longest prefixes first
51
53
  ipaddresses.sort_by do |v|
52
- [ ( scope_prio.index(v[:scope]) or 999999 ),
54
+ [ ( scope_prio.index(v[:scope]) || 999999 ),
53
55
  128 - v[:ipaddress].prefix.to_i,
54
56
  ( family == "inet" ? v[:ipaddress].to_u32 : v[:ipaddress].to_u128 )
55
57
  ]
56
58
  end
57
59
  end
58
60
 
61
+ # finds ip address / interface for interface with default route based on
62
+ # passed in family. returns [ipaddress, interface] uses 1st ip if no default
63
+ # route is found
59
64
  def find_ip(family = "inet")
60
- ips=sorted_ips(family)
65
+ ips = sorted_ips(family)
61
66
 
62
- # return if there isn't any #{family} address !
67
+ # return if there aren't any #{family} addresses!
63
68
  return [ nil, nil ] if ips.empty?
64
69
 
65
70
  # shortcuts to access default #{family} interface and gateway
66
71
  int_attr = Ohai::Mixin::NetworkConstants::FAMILIES[family] +"_interface"
67
72
  gw_attr = Ohai::Mixin::NetworkConstants::FAMILIES[family] + "_gateway"
68
73
 
69
- # If we have a default interface that has addresses,
70
- # populate the short-cut attributes ipaddress, ip6address and macaddress
71
74
  if network[int_attr]
72
-
73
75
  # working with the address(es) of the default network interface
74
76
  gw_if_ips = ips.select do |v|
75
77
  v[:iface] == network[int_attr]
76
78
  end
77
79
  if gw_if_ips.empty?
78
80
  Ohai::Log.warn("[#{family}] no ip address on #{network[int_attr]}")
79
- elsif network[gw_attr] and
80
- network["interfaces"][network[int_attr]] and
81
+ elsif network[gw_attr] &&
82
+ network["interfaces"][network[int_attr]] &&
81
83
  network["interfaces"][network[int_attr]]["addresses"]
82
84
  if [ "0.0.0.0", "::", /^fe80:/ ].any? { |pat| pat === network[gw_attr] }
83
85
  # link level default route
@@ -109,15 +111,16 @@ Ohai.plugin(:NetworkAddresses) do
109
111
  [ r[:ipaddress].to_s, r[:iface] ]
110
112
  end
111
113
 
114
+ # select mac address of first interface with family of lladdr
112
115
  def find_mac_from_iface(iface)
113
- r = network["interfaces"][iface]["addresses"].select{|k,v| v["family"]=="lladdr"}
114
- r.nil? or r.first.nil? ? nil : r.first.first
116
+ r = network["interfaces"][iface]["addresses"].select{|k,v| v["family"] == "lladdr"}
117
+ r.nil? || r.first.nil? ? nil : r.first.first
115
118
  end
116
119
 
120
+ # address_to_match: String
121
+ # ipaddress: IPAddress
122
+ # iface: String
117
123
  def network_contains_address(address_to_match, ipaddress, iface)
118
- # address_to_match: String
119
- # ipaddress: IPAddress
120
- # iface: String
121
124
  if peer = network["interfaces"][iface]["addresses"][ipaddress.to_s][:peer]
122
125
  IPAddress(peer) == IPAddress(address_to_match)
123
126
  else
@@ -125,11 +128,10 @@ Ohai.plugin(:NetworkAddresses) do
125
128
  end
126
129
  end
127
130
 
128
- # ipaddress, ip6address and macaddress can be set by the #{os}::network plugin
129
- # atm it is expected macaddress is set at the same time than ipaddress
130
- # if ipaddress is set and macaddress is nil, that means the interface
131
- # ipaddress is bound to has the NOARP flag
132
-
131
+ # ipaddress, ip6address and macaddress are set for each interface by the
132
+ # #{os}::network plugin. atm it is expected macaddress is set at the same
133
+ # time as ipaddress. if ipaddress is set and macaddress is nil, that means
134
+ # the interface ipaddress is bound to has the NOARP flag
133
135
  collect_data do
134
136
  results = {}
135
137
 
@@ -138,39 +140,44 @@ Ohai.plugin(:NetworkAddresses) do
138
140
  counters Mash.new unless counters
139
141
  counters[:network] = Mash.new unless counters[:network]
140
142
 
141
- # inet family is treated before inet6
143
+ # inet family is processed before inet6 to give ipv4 precedence
142
144
  Ohai::Mixin::NetworkConstants::FAMILIES.keys.sort.each do |family|
143
145
  r = {}
144
- ( r["ip"], r["iface"] ) = find_ip(family)
146
+ # find the ip/interface with the default route for this family
147
+ (r["ip"], r["iface"]) = find_ip(family)
145
148
  r["mac"] = find_mac_from_iface(r["iface"]) unless r["iface"].nil?
146
149
  # don't overwrite attributes if they've already been set by the "#{os}::network" plugin
147
- if family == "inet" and ipaddress.nil?
150
+ if (family == "inet") && ipaddress.nil?
148
151
  if r["ip"].nil?
149
152
  Ohai::Log.warn("unable to detect ipaddress")
150
- # i don't issue this warning if r["ip"] exists and r["mac"].nil?
151
- # as it could be a valid setup with a NOARP default_interface
152
- Ohai::Log.warn("unable to detect macaddress")
153
153
  else
154
154
  ipaddress r["ip"]
155
- macaddress r["mac"]
156
155
  end
157
- elsif family == "inet6" and ip6address.nil?
156
+ elsif (family == "inet6") && ip6address.nil?
158
157
  if r["ip"].nil?
159
158
  Ohai::Log.debug("unable to detect ip6address")
160
159
  else
161
160
  ip6address r["ip"]
162
- if r["mac"] and macaddress.nil? and ipaddress.nil?
163
- Ohai::Log.debug("macaddress set to #{r["mac"]} from the ipv6 setup")
164
- macaddress r["mac"]
165
- end
166
161
  end
167
162
  end
163
+
164
+ # set the macaddress [only if we haven't already]. this allows the #{os}::network plugin to set macaddress
165
+ # otherwise we set macaddress on a first-found basis (and we started with ipv4)
166
+ if macaddress.nil?
167
+ if r["mac"]
168
+ Ohai::Log.debug("setting macaddress to '#{r["mac"]}' from interface '#{r["iface"]}' for family '#{family}'")
169
+ macaddress r["mac"]
170
+ else
171
+ Ohai::Log.debug("unable to detect macaddress for family '#{family}'")
172
+ end
173
+ end
174
+
168
175
  results[family] = r
169
176
  end
170
177
 
171
- if results["inet"]["iface"] and results["inet6"]["iface"] and
172
- results["inet"]["iface"] != results["inet6"]["iface"]
173
- Ohai::Log.debug("ipaddress and ip6address are set from different interfaces (#{results["inet"]["iface"]} & #{results["inet6"]["iface"]}), macaddress has been set using the ipaddress interface")
178
+ if results["inet"]["iface"] && results["inet6"]["iface"] &&
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"]})")
174
181
  end
175
182
  end
176
183
  end
@@ -1,14 +1,14 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
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.
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Matt Ray (<matt@opscode.com>)
3
- # Copyright:: Copyright (c) 2012 Opscode, Inc.
2
+ # Author:: Matt Ray (<matt@chef.io>)
3
+ # Copyright:: Copyright (c) 2012-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -0,0 +1,122 @@
1
+ # Author:: "Christian Höltje" <choltje@us.ibm.com>
2
+ # Author:: "Christopher M. Luciano" <cmlucian@us.ibm.com>
3
+ # Author:: Shahul Khajamohideen (<skhajamohid1@bloomberg.net>)
4
+ # Copyright (C) 2015 IBM Corp.
5
+ # Copyright (C) 2015 Bloomberg Finance L.P.
6
+ # License:: Apache License, Version 2.0
7
+ #
8
+ # Licensed under the Apache License, Version 2.0 (the "License");
9
+ # you may not use this file except in compliance with the License.
10
+ # You may obtain a copy of the License at
11
+ #
12
+ # http://www.apache.org/licenses/LICENSE-2.0
13
+ #
14
+ # Unless required by applicable law or agreed to in writing, software
15
+ # distributed under the License is distributed on an "AS IS" BASIS,
16
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ # See the License for the specific language governing permissions and
18
+ # limitations under the License.
19
+ #
20
+ #
21
+ Ohai.plugin(:Packages) do
22
+ provides 'packages'
23
+ depends 'platform_family'
24
+
25
+ collect_data(:linux) do
26
+ packages Mash.new
27
+
28
+ if %w(debian).include? platform_family
29
+ so = shell_out('dpkg-query -W')
30
+ pkgs = so.stdout.lines
31
+
32
+ pkgs.each do |pkg|
33
+ name, version = pkg.split
34
+ packages[name] = { 'version' => version }
35
+ end
36
+
37
+ elsif %w(rhel fedora suse).include? platform_family
38
+ require 'shellwords'
39
+ format = Shellwords.escape '%{NAME}\t%{VERSION}\t%{RELEASE}\n'
40
+ so = shell_out("rpm -qa --queryformat #{format}")
41
+ pkgs = so.stdout.lines
42
+
43
+ pkgs.each do |pkg|
44
+ name, version, release = pkg.split
45
+ packages[name] = { 'version' => version, 'release' => release }
46
+ end
47
+ end
48
+ end
49
+
50
+ collect_data(:windows) do
51
+ packages Mash.new
52
+
53
+ require 'wmi-lite'
54
+
55
+ wmi = WmiLite::Wmi.new
56
+ w32_product = wmi.instances_of('Win32_Product')
57
+
58
+ w32_product.find_all.each do |product|
59
+ name = product['name']
60
+ package = packages[name] = Mash.new
61
+ %w(version vendor installdate).each do |attr|
62
+ package[attr] = product[attr]
63
+ end
64
+ end
65
+ end
66
+
67
+ collect_data(:aix) do
68
+ packages Mash.new
69
+ so = shell_out('lslpp -L -q -c')
70
+ pkgs = so.stdout.lines
71
+
72
+ # Output format is
73
+ # Package Name:Fileset:Level
74
+ # On aix, filesets are packages and levels are versions
75
+ pkgs.each do |pkg|
76
+ _, name, version = pkg.split(':')
77
+ packages[name] = { 'version' => version }
78
+ end
79
+ end
80
+
81
+ def collect_ips_packages
82
+ so = shell_out('pkg list -H')
83
+ # Output format is
84
+ # NAME (PUBLISHER) VERSION IFO
85
+ so.stdout.lines.each do |pkg|
86
+ tokens = pkg.split
87
+ if tokens.length == 3 # No publisher info
88
+ name, version, = tokens
89
+ else
90
+ name, publisher, version, = tokens
91
+ publisher = publisher[1..-2]
92
+ end
93
+ packages[name] = { 'version' => version }
94
+ packages[name]['publisher'] = publisher if publisher
95
+ end
96
+ end
97
+
98
+ def collect_sysv_packages
99
+ so = shell_out('pkginfo -l')
100
+ # Each package info is separated by a blank line
101
+ chunked_lines = so.stdout.lines.map(&:strip).chunk do |line|
102
+ !line.empty? || nil
103
+ end
104
+ chunked_lines.each do |_, lines|
105
+ package = {}
106
+ lines.each do |line|
107
+ key, value = line.split(':', 2)
108
+ package[key.strip.downcase] = value.strip unless value.nil?
109
+ end
110
+ # pkginst is the installed package name
111
+ packages[package['pkginst']] = package.tap do |p|
112
+ p.delete('pkginst')
113
+ end
114
+ end
115
+ end
116
+
117
+ collect_data(:solaris2) do
118
+ packages Mash.new
119
+ collect_ips_packages
120
+ collect_sysv_packages
121
+ end
122
+ end
@@ -1,14 +1,14 @@
1
1
  #
2
- # Author:: Joshua Timberman (<joshua@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Joshua Timberman (<joshua@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
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.
@@ -35,7 +35,7 @@ Ohai.plugin(:Perl) do
35
35
  perl[:archname] = $1
36
36
  end
37
37
  end
38
- languages[:perl] = perl
38
+ languages[:perl] = perl
39
39
  end
40
40
 
41
41
  end
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2014 Chef Software, Inc.
2
+ # Copyright:: Copyright (c) 2014-2016 Chef Software, Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,7 +33,7 @@ Ohai.plugin(:Powershell) do
33
33
  # BuildVersion 6.3.9600.16394
34
34
  # PSCompatibleVersions {1.0, 2.0, 3.0, 4.0}
35
35
  # PSRemotingProtocolVersion 2.2
36
-
36
+
37
37
  if so.exitstatus == 0
38
38
  version_info = {}
39
39
  so.stdout.strip.each_line do |line|
@@ -1,7 +1,7 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Bryan McLellan (<btm@loftninjas.org>)
4
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # Copyright:: Copyright (c) 2008-2016 Chef Software, Inc.
5
5
  # Copyright:: Copyright (c) 2009 Bryan McLellan
6
6
  # License:: Apache License, Version 2.0
7
7
  #