summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsawanoboly <sawanoboriyu@higanworks.com>2020-12-10 14:42:43 +0900
committersawanoboly <sawanoboriyu@higanworks.com>2020-12-10 14:42:43 +0900
commita2987d3d5d152f651039642e024b8d3f2ef34bb7 (patch)
treed716709c25b24c23f948cdb42067b69612b9efbe
parenta807a2c2d52890c72700b722e87184e47311ba3a (diff)
parent3ef9243c91c67a529bff67dc6a30e356c80b9d2b (diff)
downloadohai-a2987d3d5d152f651039642e024b8d3f2ef34bb7.tar.gz
Merge remote-tracking branch 'origin/master' into imds-v2
-rw-r--r--CHANGELOG.md51
-rw-r--r--VERSION2
-rw-r--r--lib/ohai/dsl/plugin.rb2
-rw-r--r--lib/ohai/dsl/plugin/versionvii.rb2
-rw-r--r--lib/ohai/mixin/azure_metadata.rb4
-rw-r--r--lib/ohai/mixin/ec2_metadata.rb12
-rw-r--r--lib/ohai/mixin/gce_metadata.rb2
-rw-r--r--lib/ohai/plugins/aix/network.rb7
-rw-r--r--lib/ohai/plugins/c.rb6
-rw-r--r--lib/ohai/plugins/cloud.rb2
-rw-r--r--lib/ohai/plugins/cpu.rb38
-rw-r--r--lib/ohai/plugins/darwin/network.rb14
-rw-r--r--lib/ohai/plugins/digital_ocean.rb3
-rw-r--r--lib/ohai/plugins/dmi.rb8
-rw-r--r--lib/ohai/plugins/docker.rb2
-rw-r--r--lib/ohai/plugins/grub2.rb40
-rw-r--r--lib/ohai/plugins/kernel.rb2
-rw-r--r--lib/ohai/plugins/libvirt.rb6
-rw-r--r--lib/ohai/plugins/linode.rb35
-rw-r--r--lib/ohai/plugins/linux/lspci.rb1
-rw-r--r--lib/ohai/plugins/linux/network.rb2
-rw-r--r--lib/ohai/plugins/network.rb2
-rw-r--r--lib/ohai/plugins/passwd.rb2
-rw-r--r--lib/ohai/plugins/rackspace.rb4
-rw-r--r--lib/ohai/plugins/scaleway.rb2
-rw-r--r--lib/ohai/plugins/scsi.rb1
-rw-r--r--lib/ohai/plugins/solaris2/network.rb2
-rw-r--r--lib/ohai/plugins/solaris2/virtualization.rb3
-rw-r--r--lib/ohai/plugins/train.rb1
-rw-r--r--lib/ohai/plugins/virtualbox.rb2
-rw-r--r--lib/ohai/plugins/zpools.rb1
-rw-r--r--lib/ohai/util/ip_helper.rb2
-rw-r--r--lib/ohai/version.rb2
-rw-r--r--ohai.gemspec2
-rw-r--r--spec/unit/plugins/aix/network_spec.rb26
-rw-r--r--spec/unit/plugins/c_spec.rb13
-rw-r--r--spec/unit/plugins/chef_spec.rb1
-rw-r--r--spec/unit/plugins/digital_ocean_spec.rb1
-rw-r--r--spec/unit/plugins/docker_spec.rb23
-rw-r--r--spec/unit/plugins/grub2_spec.rb51
-rw-r--r--spec/unit/plugins/linode_spec.rb24
-rw-r--r--spec/unit/plugins/linux/network_spec.rb2
-rw-r--r--spec/unit/plugins/linux/selinux_spec.rb52
-rw-r--r--spec/unit/plugins/packages_spec.rb8
-rw-r--r--spec/unit/plugins/scaleway_spec.rb1
-rw-r--r--spec/unit/plugins/shard_spec.rb2
-rw-r--r--spec/unit/plugins/solaris2/network_spec.rb2
47 files changed, 299 insertions, 174 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a4628689..ea19ad2d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,34 +1,46 @@
# Change Log
-<!-- latest_release 16.7.33 -->
-## [v16.7.33](https://github.com/chef/ohai/tree/v16.7.33) (2020-11-19)
+<!-- latest_release 16.8.1 -->
+## [v16.8.1](https://github.com/chef/ohai/tree/v16.8.1) (2020-12-04)
#### Merged Pull Requests
-- aix virtualization: Fix lpar name detection [#1580](https://github.com/chef/ohai/pull/1580) ([tas50](https://github.com/tas50))
+- grub2: add plugin to expose GRUB2 environment variables [#1590](https://github.com/chef/ohai/pull/1590) ([davide125](https://github.com/davide125))
<!-- latest_release -->
-<!-- release_rollup since=16.7.18 -->
+<!-- release_rollup since=16.7.37 -->
### Changes not yet released to rubygems.org
#### Merged Pull Requests
-- aix virtualization: Fix lpar name detection [#1580](https://github.com/chef/ohai/pull/1580) ([tas50](https://github.com/tas50)) <!-- 16.7.33 -->
-- Use strip instead of split($/) to cleanup shellout [#1578](https://github.com/chef/ohai/pull/1578) ([tas50](https://github.com/tas50)) <!-- 16.7.32 -->
-- Simplify the aix kernel plugin [#1577](https://github.com/chef/ohai/pull/1577) ([tas50](https://github.com/tas50)) <!-- 16.7.31 -->
-- Gather WPAR state in the AIX virtualization plugin [#1576](https://github.com/chef/ohai/pull/1576) ([tas50](https://github.com/tas50)) <!-- 16.7.30 -->
-- Simplify aix platform / platform_family detection [#1575](https://github.com/chef/ohai/pull/1575) ([tas50](https://github.com/tas50)) <!-- 16.7.29 -->
-- Avoid calling uname 4 times on aix [#1574](https://github.com/chef/ohai/pull/1574) ([tas50](https://github.com/tas50)) <!-- 16.7.28 -->
-- More refactoring of the AIX network plugin [#1573](https://github.com/chef/ohai/pull/1573) ([tas50](https://github.com/tas50)) <!-- 16.7.27 -->
-- Simplify how we gather memory on AIX [#1572](https://github.com/chef/ohai/pull/1572) ([tas50](https://github.com/tas50)) <!-- 16.7.26 -->
-- Refactor how we parse ifconfig in AIX [#1570](https://github.com/chef/ohai/pull/1570) ([tas50](https://github.com/tas50)) <!-- 16.7.25 -->
-- Disable gem caching / rubygems updates in Buildkite [#1571](https://github.com/chef/ohai/pull/1571) ([tas50](https://github.com/tas50)) <!-- 16.7.24 -->
-- Remove the :Joyent plugin as Joyent cloud went EOL 11/2019 [#1569](https://github.com/chef/ohai/pull/1569) ([tas50](https://github.com/tas50)) <!-- 16.7.23 -->
-- Simplify all our splits [#1568](https://github.com/chef/ohai/pull/1568) ([tas50](https://github.com/tas50)) <!-- 16.7.22 -->
-- Minor performance optimizations in AIX Network plugin [#1567](https://github.com/chef/ohai/pull/1567) ([tas50](https://github.com/tas50)) <!-- 16.7.21 -->
-- Update rubocop-performance to 1.9 [#1565](https://github.com/chef/ohai/pull/1565) ([tas50](https://github.com/tas50)) <!-- 16.7.20 -->
-- Update mock logger to fix shellout specs. [#1566](https://github.com/chef/ohai/pull/1566) ([phiggins](https://github.com/phiggins)) <!-- 16.7.19 -->
+- grub2: add plugin to expose GRUB2 environment variables [#1590](https://github.com/chef/ohai/pull/1590) ([davide125](https://github.com/davide125)) <!-- 16.8.1 -->
+- Update Linode plugin to use domain / apt data to detect Linode [#1587](https://github.com/chef/ohai/pull/1587) ([tas50](https://github.com/tas50)) <!-- 16.8.0 -->
+- Remove platform dependencies that aren&#39;t needed [#1586](https://github.com/chef/ohai/pull/1586) ([tas50](https://github.com/tas50)) <!-- 16.7.38 -->
<!-- release_rollup -->
<!-- latest_stable_release -->
+## [v16.7.37](https://github.com/chef/ohai/tree/v16.7.37) (2020-11-24)
+
+#### Merged Pull Requests
+- Update mock logger to fix shellout specs. [#1566](https://github.com/chef/ohai/pull/1566) ([phiggins](https://github.com/phiggins))
+- Update rubocop-performance to 1.9 [#1565](https://github.com/chef/ohai/pull/1565) ([tas50](https://github.com/tas50))
+- Minor performance optimizations in AIX Network plugin [#1567](https://github.com/chef/ohai/pull/1567) ([tas50](https://github.com/tas50))
+- Simplify all our splits [#1568](https://github.com/chef/ohai/pull/1568) ([tas50](https://github.com/tas50))
+- Remove the :Joyent plugin as Joyent cloud went EOL 11/2019 [#1569](https://github.com/chef/ohai/pull/1569) ([tas50](https://github.com/tas50))
+- Disable gem caching / rubygems updates in Buildkite [#1571](https://github.com/chef/ohai/pull/1571) ([tas50](https://github.com/tas50))
+- Refactor how we parse ifconfig in AIX [#1570](https://github.com/chef/ohai/pull/1570) ([tas50](https://github.com/tas50))
+- Simplify how we gather memory on AIX [#1572](https://github.com/chef/ohai/pull/1572) ([tas50](https://github.com/tas50))
+- More refactoring of the AIX network plugin [#1573](https://github.com/chef/ohai/pull/1573) ([tas50](https://github.com/tas50))
+- Avoid calling uname 4 times on aix [#1574](https://github.com/chef/ohai/pull/1574) ([tas50](https://github.com/tas50))
+- Simplify aix platform / platform_family detection [#1575](https://github.com/chef/ohai/pull/1575) ([tas50](https://github.com/tas50))
+- Gather WPAR state in the AIX virtualization plugin [#1576](https://github.com/chef/ohai/pull/1576) ([tas50](https://github.com/tas50))
+- Simplify the aix kernel plugin [#1577](https://github.com/chef/ohai/pull/1577) ([tas50](https://github.com/tas50))
+- Use strip instead of split($/) to cleanup shellout [#1578](https://github.com/chef/ohai/pull/1578) ([tas50](https://github.com/tas50))
+- aix virtualization: Fix lpar name detection [#1580](https://github.com/chef/ohai/pull/1580) ([tas50](https://github.com/tas50))
+- Misc RuboCop cleanup of the codebase [#1582](https://github.com/chef/ohai/pull/1582) ([tas50](https://github.com/tas50))
+- Limit several of the Cloud/VM plugins to certain platforms [#1585](https://github.com/chef/ohai/pull/1585) ([tas50](https://github.com/tas50))
+- Prevent docker plugin crashes on AIX [#1584](https://github.com/chef/ohai/pull/1584) ([tas50](https://github.com/tas50))
+- Fix XLC compiler detection to support 3 part version numbers [#1583](https://github.com/chef/ohai/pull/1583) ([tas50](https://github.com/tas50))
+<!-- latest_stable_release -->
+
## [v16.7.18](https://github.com/chef/ohai/tree/v16.7.18) (2020-11-12)
#### Merged Pull Requests
@@ -51,7 +63,6 @@
- Remove regex anchors in the Linux Memory plugin [#1563](https://github.com/chef/ohai/pull/1563) ([tas50](https://github.com/tas50))
- Remove Linux LSB support for systems without lsb-release CLI [#1562](https://github.com/chef/ohai/pull/1562) ([tas50](https://github.com/tas50))
- Remove the line anchor from the LSB plugin matches [#1561](https://github.com/chef/ohai/pull/1561) ([tas50](https://github.com/tas50))
-<!-- latest_stable_release -->
## [v16.6.5](https://github.com/chef/ohai/tree/v16.6.5) (2020-10-14)
diff --git a/VERSION b/VERSION
index ac9e1c36..0446c757 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-16.7.33 \ No newline at end of file
+16.8.1 \ No newline at end of file
diff --git a/lib/ohai/dsl/plugin.rb b/lib/ohai/dsl/plugin.rb
index cc561d36..48d49a57 100644
--- a/lib/ohai/dsl/plugin.rb
+++ b/lib/ohai/dsl/plugin.rb
@@ -218,7 +218,7 @@ module Ohai
def safe_get_attribute(*keys)
keys.inject(@data) do |attrs, key|
unless attrs.nil? || attrs.is_a?(Array) || attrs.is_a?(Hash)
- raise TypeError.new("Expected Hash but got #{attrs.class}.")
+ raise TypeError, "Expected Hash but got #{attrs.class}."
end
attrs[key]
diff --git a/lib/ohai/dsl/plugin/versionvii.rb b/lib/ohai/dsl/plugin/versionvii.rb
index 6386c2ed..f623ba1e 100644
--- a/lib/ohai/dsl/plugin/versionvii.rb
+++ b/lib/ohai/dsl/plugin/versionvii.rb
@@ -195,8 +195,6 @@ module Ohai
# key? to avoid falsely instantiating a configuration hash.
if Ohai.config[:plugin].key?(snake_case_name)
Ohai.config[:plugin][snake_case_name]
- else
- nil
end
end
end
diff --git a/lib/ohai/mixin/azure_metadata.rb b/lib/ohai/mixin/azure_metadata.rb
index 65b26e8b..7bf17ec9 100644
--- a/lib/ohai/mixin/azure_metadata.rb
+++ b/lib/ohai/mixin/azure_metadata.rb
@@ -36,8 +36,8 @@ module Ohai
# it's important that the newer versions are at the end of this array so we can skip sorting it
AZURE_SUPPORTED_VERSIONS ||= %w{ 2017-04-02 2017-08-01 2017-12-01 2018-02-01 2018-04-02
- 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
- 2019-06-04 2019-08-01 2019-08-15 2019-11-01 }.freeze
+ 2018-10-01 2019-02-01 2019-03-11 2019-04-30 2019-06-01
+ 2019-06-04 2019-08-01 2019-08-15 2019-11-01 }.freeze
def best_api_version
@api_version ||= begin
diff --git a/lib/ohai/mixin/ec2_metadata.rb b/lib/ohai/mixin/ec2_metadata.rb
index 7eb92b53..c5cc5988 100644
--- a/lib/ohai/mixin/ec2_metadata.rb
+++ b/lib/ohai/mixin/ec2_metadata.rb
@@ -42,8 +42,8 @@ module Ohai
EC2_METADATA_ADDR ||= "169.254.169.254"
EC2_SUPPORTED_VERSIONS ||= %w{ 1.0 2007-01-19 2007-03-01 2007-08-29 2007-10-10 2007-12-15
- 2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12
- 2014-02-25 2014-11-05 2015-10-20 2016-04-19 2016-06-30 2016-09-02 }.freeze
+ 2008-02-01 2008-09-01 2009-04-04 2011-01-01 2011-05-01 2012-01-12
+ 2014-02-25 2014-11-05 2015-10-20 2016-04-19 2016-06-30 2016-09-02 }.freeze
EC2_ARRAY_VALUES ||= %w{security-groups local_ipv4s}.freeze
EC2_ARRAY_DIR ||= %w{network/interfaces/macs}.freeze
EC2_JSON_DIR ||= %w{iam}.freeze
@@ -58,7 +58,7 @@ module Ohai
elsif response.code != "200"
raise "Mixin EC2: Unable to determine EC2 metadata version (returned #{response.code} response)"
end
- # Note: Sorting the list of versions may have unintended consequences in
+ # NOTE: Sorting the list of versions may have unintended consequences in
# non-EC2 environments. It appears to be safe in EC2 as of 2013-04-12.
versions = response.body.split("\n").sort
until versions.empty? || EC2_SUPPORTED_VERSIONS.include?(versions.last)
@@ -123,7 +123,7 @@ module Ohai
else
metadata_get(key, best_api_version)
end
- elsif (not key.eql?(id)) && (not key.eql?("/"))
+ elsif (!key.eql?(id)) && (!key.eql?("/"))
name = key[0..-2]
sym = metadata_key(name)
if EC2_ARRAY_DIR.include?(name)
@@ -148,7 +148,7 @@ module Ohai
if key[-1..-1] != "/"
retr_meta = metadata_get("#{id}#{key}", api_version)
metadata[metadata_key(key)] = retr_meta || ""
- elsif not key.eql?("/")
+ elsif !key.eql?("/")
metadata[key[0..-2]] = fetch_dir_metadata("#{id}#{key}", api_version)
end
end
@@ -168,7 +168,7 @@ module Ohai
json = String(data)
parser = FFI_Yajl::Parser.new
metadata[metadata_key(key)] = parser.parse(json)
- elsif not key.eql?("/")
+ elsif !key.eql?("/")
metadata[key[0..-2]] = fetch_json_dir_metadata("#{id}#{key}", api_version)
end
end
diff --git a/lib/ohai/mixin/gce_metadata.rb b/lib/ohai/mixin/gce_metadata.rb
index 8ea838aa..64b35f92 100644
--- a/lib/ohai/mixin/gce_metadata.rb
+++ b/lib/ohai/mixin/gce_metadata.rb
@@ -72,7 +72,7 @@ module Ohai
#
# @return [Boolean] is there a trailing /?
def has_trailing_slash?(data)
- !! ( data =~ %r{/$} )
+ !!( data =~ %r{/$} )
end
def sanitize_key(key)
diff --git a/lib/ohai/plugins/aix/network.rb b/lib/ohai/plugins/aix/network.rb
index cb40e09a..a31ecc4f 100644
--- a/lib/ohai/plugins/aix/network.rb
+++ b/lib/ohai/plugins/aix/network.rb
@@ -72,7 +72,8 @@ Ohai.plugin(:Network) do
else
# We have key value pairs.
if line =~ %r{inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/(\d{1,2}))?}
- tmp_addr, tmp_prefix = $1, $3
+ tmp_addr = $1
+ tmp_prefix = $3
if tmp_prefix.nil?
netmask = hex_to_dec_netmask($1) if line =~ /netmask\s0x(\S+)\s/
unless netmask
@@ -90,7 +91,7 @@ Ohai.plugin(:Network) do
ifaces[int_name][:addresses][tmp_addr][:broadcast] = $1
end
elsif line =~ %r{inet6 ([a-f0-9\:]+)%?(\d*)/?(\d*)?}
- # TODO do we have more properties on inet6 in aix? broadcast
+ # TODO: do we have more properties on inet6 in aix? broadcast
ifaces[int_name][:addresses] ||= Mash.new
ifaces[int_name][:addresses][$1] = { "family" => "inet6", "zone_index" => $2, "prefixlen" => $3 }
else
@@ -119,7 +120,7 @@ Ohai.plugin(:Network) do
interface = $6
ifaces[interface][:routes] ||= []
ifaces[interface][:routes] << Mash.new( destination: $1, family: family,
- via: $2, flags: $3)
+ via: $2, flags: $3)
end
end
end
diff --git a/lib/ohai/plugins/c.rb b/lib/ohai/plugins/c.rb
index fb064e81..80cccaca 100644
--- a/lib/ohai/plugins/c.rb
+++ b/lib/ohai/plugins/c.rb
@@ -123,12 +123,12 @@ Ohai.plugin(:C) do
end
def collect_xlc
- # ibm xlc
-
+ # IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
+ # Version: 13.01.0003.0000
so = shell_out("xlc -qversion")
if so.exitstatus == 0 || (so.exitstatus >> 8) == 249
description = so.stdout.split($/).first
- if description =~ /V(\d+\.\d+)/
+ if description =~ /V(\d+\.\d+(.\d+)?)/
@c[:xlc] = Mash.new
@c[:xlc][:version] = $1
@c[:xlc][:description] = description.strip
diff --git a/lib/ohai/plugins/cloud.rb b/lib/ohai/plugins/cloud.rb
index a49044fb..14e1e454 100644
--- a/lib/ohai/plugins/cloud.rb
+++ b/lib/ohai/plugins/cloud.rb
@@ -110,7 +110,7 @@ Ohai.plugin(:Cloud) do
ipaddr = ""
begin
ipaddr = IPAddr.new(ip)
- raise ArgumentError, "not valid #{address_family} address" unless (address_family == :ipv4) ? ipaddr.ipv4? : ipaddr.ipv6?
+ raise ArgumentError, "not valid #{address_family} address" unless address_family == :ipv4 ? ipaddr.ipv4? : ipaddr.ipv6?
rescue ArgumentError => e
raise "ERROR: the ohai 'cloud' plugin failed with an IP address of '#{ip}' : #{e.message}"
end
diff --git a/lib/ohai/plugins/cpu.rb b/lib/ohai/plugins/cpu.rb
index f9e980b7..9232fdf7 100644
--- a/lib/ohai/plugins/cpu.rb
+++ b/lib/ohai/plugins/cpu.rb
@@ -348,25 +348,25 @@ Ohai.plugin(:CPU) do
key = kv.shift
value = kv.join(" ").chomp
case key
- when /chip_id/
- cpu[instance]["socket"] = value
- cpusockets.push(value) if cpusockets.index(value).nil?
- when /cpu_type/
- cpu[instance]["arch"] = value
- when /clock_MHz/
- cpu[instance]["mhz"] = value
- when /brand/
- cpu[instance]["model_name"] = value.sub(/\s+/, " ")
- when /^state$/
- cpu[instance]["state"] = value
- cpu["cpustates"][value] ||= 0
- cpu["cpustates"][value] += 1
- when /core_id/
- cpu[instance]["core_id"] = value
- # Detect hyperthreading/multithreading
- cpucores.push(value) if cpucores.index(value).nil?
- when /family|fpu_type|model|stepping|vendor_id/
- cpu[instance][key] = value
+ when /chip_id/
+ cpu[instance]["socket"] = value
+ cpusockets.push(value) if cpusockets.index(value).nil?
+ when /cpu_type/
+ cpu[instance]["arch"] = value
+ when /clock_MHz/
+ cpu[instance]["mhz"] = value
+ when /brand/
+ cpu[instance]["model_name"] = value.sub(/\s+/, " ")
+ when /^state$/
+ cpu[instance]["state"] = value
+ cpu["cpustates"][value] ||= 0
+ cpu["cpustates"][value] += 1
+ when /core_id/
+ cpu[instance]["core_id"] = value
+ # Detect hyperthreading/multithreading
+ cpucores.push(value) if cpucores.index(value).nil?
+ when /family|fpu_type|model|stepping|vendor_id/
+ cpu[instance][key] = value
end
end
cpu["cores"] = cpucores.size
diff --git a/lib/ohai/plugins/darwin/network.rb b/lib/ohai/plugins/darwin/network.rb
index 2d3e2a12..a4440a71 100644
--- a/lib/ohai/plugins/darwin/network.rb
+++ b/lib/ohai/plugins/darwin/network.rb
@@ -41,11 +41,9 @@ Ohai.plugin(:Network) do
else
media[line_array[i]]["options"] = $1.split(",")
end
- else
- if line_array[i].eql?("autoselect")
- media["autoselect"] = {} unless media.key?("autoselect")
- media["autoselect"]["options"] = []
- end
+ elsif line_array[i].eql?("autoselect")
+ media["autoselect"] = {} unless media.key?("autoselect")
+ media["autoselect"]["options"] = []
end
else
media["none"] = { "options" => [] }
@@ -145,15 +143,15 @@ Ohai.plugin(:Network) do
end
if line =~ /\s+inet (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) netmask 0x(([0-9a-f]){1,8}) broadcast (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/
iface[cint][:addresses] ||= Mash.new
- iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2) , "broadcast" => $4 }
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2), "broadcast" => $4 }
end
if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+)\s*/
iface[cint][:addresses] ||= Mash.new
- iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 , "scope" => scope_lookup($1) }
+ iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4, "scope" => scope_lookup($1) }
end
if line =~ /\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*) prefixlen (\d+) scopeid 0x([a-f0-9]+)/
iface[cint][:addresses] ||= Mash.new
- iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4 , "scope" => scope_lookup($1) }
+ iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $4, "scope" => scope_lookup($1) }
end
if line =~ /^\s+media: ((\w+)|(\w+ [a-zA-Z0-9\-\<\>]+)) status: (\w+)/
iface[cint][:media] ||= Mash.new
diff --git a/lib/ohai/plugins/digital_ocean.rb b/lib/ohai/plugins/digital_ocean.rb
index d18304b6..94d123f0 100644
--- a/lib/ohai/plugins/digital_ocean.rb
+++ b/lib/ohai/plugins/digital_ocean.rb
@@ -49,7 +49,8 @@ Ohai.plugin(:DigitalOcean) do
false
end
- collect_data do
+ # linux and freebsd is all digitalocean supports
+ collect_data(:linux, :freebsd) do
if looks_like_digital_ocean?
logger.trace("Plugin Digitalocean: looks_like_digital_ocean? == true")
digital_ocean Mash.new
diff --git a/lib/ohai/plugins/dmi.rb b/lib/ohai/plugins/dmi.rb
index c9d4ecaf..4208e22e 100644
--- a/lib/ohai/plugins/dmi.rb
+++ b/lib/ohai/plugins/dmi.rb
@@ -93,14 +93,14 @@ Ohai.plugin(:DMI) do
field = nil
elsif ( type = type_line.match(line) )
- if dmi_record .nil?
+ if dmi_record.nil?
logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
next
end
dmi[dmi_record[:type]][:all_records][dmi_record[:position]][:application_identifier] = type[1]
elsif ( data = data_line.match(line) )
- if dmi_record .nil?
+ if dmi_record.nil?
logger.trace("Plugin DMI: unexpected data line found before header; discarding:\n#{line}")
next
end
@@ -108,11 +108,11 @@ Ohai.plugin(:DMI) do
field = data[1]
elsif ( extended_data = extended_data_line.match(line) )
- if dmi_record .nil?
+ if dmi_record.nil?
logger.trace("Plugin DMI: unexpected extended data line found before header; discarding:\n#{line}")
next
end
- if field .nil?
+ if field.nil?
logger.trace("Plugin DMI: unexpected extended data line found outside data section; discarding:\n#{line}")
next
end
diff --git a/lib/ohai/plugins/docker.rb b/lib/ohai/plugins/docker.rb
index 92e7a5c4..425d03c2 100644
--- a/lib/ohai/plugins/docker.rb
+++ b/lib/ohai/plugins/docker.rb
@@ -48,7 +48,7 @@ Ohai.plugin(:Docker) do
docker[:swarm] = shellout_data["Swarm"]
end
- collect_data do
+ collect_data(:linux, :windows, :darwin) do
require "json" unless defined?(JSON)
if virtualization[:systems][:docker]
diff --git a/lib/ohai/plugins/grub2.rb b/lib/ohai/plugins/grub2.rb
new file mode 100644
index 00000000..02b14e26
--- /dev/null
+++ b/lib/ohai/plugins/grub2.rb
@@ -0,0 +1,40 @@
+# frozen_string_literal: true
+#
+# Author:: Davide Cavalca <dcavalca@fb.com>
+# Copyright:: Copyright (c) 2020 Facebook
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+Ohai.plugin(:Grub2) do
+ provides "grub2/environment"
+ optional true
+
+ collect_data(:dragonflybsd, :freebsd, :linux, :netbsd) do
+ editenv_path = which("grub2-editenv")
+ if editenv_path
+ editenv_out = shell_out("#{editenv_path} list")
+
+ grub2 Mash.new unless grub2
+ grub2[:environment] ||= Mash.new
+
+ editenv_out.stdout.each_line do |line|
+ key, val = line.split("=", 2)
+ grub2[:environment][key] = val.strip
+ end
+ else
+ logger.trace("Plugin Grub2: Could not find grub2-editenv. Skipping plugin.")
+ end
+ end
+end
diff --git a/lib/ohai/plugins/kernel.rb b/lib/ohai/plugins/kernel.rb
index e96967d6..36ff9d4a 100644
--- a/lib/ohai/plugins/kernel.rb
+++ b/lib/ohai/plugins/kernel.rb
@@ -115,7 +115,6 @@ Ohai.plugin(:Kernel) do
when 16 then "WIN95"
when 17 then "WIN98"
when 19 then "WINCE"
- else nil
end
end
@@ -134,7 +133,6 @@ Ohai.plugin(:Kernel) do
when 6 then "Appliance PC"
when 7 then "Performance Server"
when 8 then "Maximum"
- else nil
end
end
diff --git a/lib/ohai/plugins/libvirt.rb b/lib/ohai/plugins/libvirt.rb
index 15b0fa40..42d66e0f 100644
--- a/lib/ohai/plugins/libvirt.rb
+++ b/lib/ohai/plugins/libvirt.rb
@@ -17,11 +17,11 @@
# limitations under the License.
#
-# Note: This plugin requires libvirt-bin/libvirt-dev as well as the ruby-libvirt
+# NOTE: This plugin requires libvirt-bin/libvirt-dev as well as the ruby-libvirt
# gem to be installed before it will properly parse data
Ohai.plugin(:Libvirt) do
- %w{ uri capabilities nodeinfo domains networks storage }.each do |info|
+ %w{uri capabilities nodeinfo domains networks storage}.each do |info|
provides "libvirt/#{info}"
depends "virtualization"
end
@@ -89,7 +89,7 @@ Ohai.plugin(:Libvirt) do
storage_data
end
- collect_data do
+ collect_data(:linux) do
if virtualization[:role].eql?("host")
load_libvirt
begin
diff --git a/lib/ohai/plugins/linode.rb b/lib/ohai/plugins/linode.rb
index c1cb8ae3..4acd8d67 100644
--- a/lib/ohai/plugins/linode.rb
+++ b/lib/ohai/plugins/linode.rb
@@ -18,31 +18,38 @@
Ohai.plugin(:Linode) do
provides "linode"
- depends "kernel"
+ depends "domain"
depends "network/interfaces"
- # Checks for matching linode kernel name
+ # Checks to see if the node is in the members.linode.com domain
#
- # Returns true or false
- def has_linode_kernel?
- if ( kernel_data = kernel )
- kernel_data[:release].split("-").last.include?("linode")
- end
+ # @return [Boolean]
+ #
+ def has_linode_domain?
+ domain&.include?("linode")
+ end
+
+ # Checks for linode mirrors in the apt sources.list file
+ #
+ # @return [Boolean]
+ #
+ def has_linode_apt_repos?
+ file_exist?("/etc/apt/sources.list") && file_read("/etc/apt/sources.list").include?("linode")
end
# Identifies the linode cloud by preferring the hint, then
#
- # Returns true or false
+ # @return [Boolean]
+ #
def looks_like_linode?
- hint?("linode") || has_linode_kernel?
+ hint?("linode") || has_linode_domain? || has_linode_apt_repos?
end
- # Names linode ip address
+ # Alters linode mash with new interface based on name parameter
#
- # name - symbol of ohai name (e.g. :public_ip)
- # eth - Interface name (e.g. :eth0)
+ # @param [Symbol] name Ohai name (e.g. :public_ip)
+ # @param [Symbol] eth Interface name (e.g. :eth0)
#
- # Alters linode mash with new interface based on name parameter
def get_ip_address(name, eth)
if ( eth_iface = network[:interfaces][eth] )
eth_iface[:addresses].each do |key, info|
@@ -51,7 +58,7 @@ Ohai.plugin(:Linode) do
end
end
- collect_data do
+ collect_data(:linux) do
# Setup linode mash if it is a linode system
if looks_like_linode?
logger.trace("Plugin Linode: looks_like_linode? == true")
diff --git a/lib/ohai/plugins/linux/lspci.rb b/lib/ohai/plugins/linux/lspci.rb
index 08b2a6d9..f75a0f86 100644
--- a/lib/ohai/plugins/linux/lspci.rb
+++ b/lib/ohai/plugins/linux/lspci.rb
@@ -19,7 +19,6 @@
# limitations under the License.
Ohai.plugin(:Lspci) do
- depends "platform"
provides "pci"
optional true
diff --git a/lib/ohai/plugins/linux/network.rb b/lib/ohai/plugins/linux/network.rb
index 01f4af47..e32c602c 100644
--- a/lib/ohai/plugins/linux/network.rb
+++ b/lib/ohai/plugins/linux/network.rb
@@ -154,7 +154,7 @@ Ohai.plugin(:Network) do
def ethernet_layer_one(iface)
return iface unless ethtool_binary_path
- keys = %w{ Speed Duplex Port Transceiver Auto-negotiation MDI-X }
+ keys = %w{Speed Duplex Port Transceiver Auto-negotiation MDI-X}
iface.each_key do |tmp_int|
next unless iface[tmp_int][:encapsulation] == "Ethernet"
diff --git a/lib/ohai/plugins/network.rb b/lib/ohai/plugins/network.rb
index be8f26f3..d19c23c0 100644
--- a/lib/ohai/plugins/network.rb
+++ b/lib/ohai/plugins/network.rb
@@ -39,7 +39,7 @@ Ohai.plugin(:NetworkAddresses) do
next if iface_v.nil? || !iface_v.key?("addresses")
iface_v["addresses"].each do |addr, addr_v|
- next if addr_v.nil? || (not addr_v.key? "family") || addr_v["family"] != family
+ next if addr_v.nil? || (!addr_v.key? "family") || addr_v["family"] != family
ipaddresses << {
ipaddress: addr_v["prefixlen"] ? IPAddress("#{addr}/#{addr_v["prefixlen"]}") : IPAddress("#{addr}/#{addr_v["netmask"]}"),
diff --git a/lib/ohai/plugins/passwd.rb b/lib/ohai/plugins/passwd.rb
index a2e33632..aba8c232 100644
--- a/lib/ohai/plugins/passwd.rb
+++ b/lib/ohai/plugins/passwd.rb
@@ -91,7 +91,7 @@ Ohai.plugin(:Passwd) do
if info.keys.any? { |x| x.match?("Win32_UserAccount") }
mi["type"] = :user
else
- # Note: the type here is actually Win32_SystemAccount, because,
+ # NOTE: the type here is actually Win32_SystemAccount, because,
# that's what groups are in the Windows universe.
mi["type"] = :group
end
diff --git a/lib/ohai/plugins/rackspace.rb b/lib/ohai/plugins/rackspace.rb
index 02b06d1a..efe63e40 100644
--- a/lib/ohai/plugins/rackspace.rb
+++ b/lib/ohai/plugins/rackspace.rb
@@ -161,10 +161,10 @@ Ohai.plugin(:Rackspace) do
get_global_ipv6_address(:public_ipv6, :eth0)
unless rackspace[:public_ip].nil?
rackspace[:public_hostname] = begin
- Resolv.getname(rackspace[:public_ip])
+ Resolv.getname(rackspace[:public_ip])
rescue Resolv::ResolvError, Resolv::ResolvTimeout
rackspace[:public_ip]
- end
+ end
end
rackspace[:local_ipv4] = rackspace[:private_ip]
get_global_ipv6_address(:local_ipv6, :eth1)
diff --git a/lib/ohai/plugins/scaleway.rb b/lib/ohai/plugins/scaleway.rb
index d6d43444..4847bb27 100644
--- a/lib/ohai/plugins/scaleway.rb
+++ b/lib/ohai/plugins/scaleway.rb
@@ -44,7 +44,7 @@ Ohai.plugin(:Scaleway) do
false
end
- collect_data do
+ collect_data(:linux) do
if looks_like_scaleway?
logger.trace("Plugin Scaleway: looks_like_scaleway? == true")
scaleway Mash.new
diff --git a/lib/ohai/plugins/scsi.rb b/lib/ohai/plugins/scsi.rb
index 7a554adc..7ed3a63f 100644
--- a/lib/ohai/plugins/scsi.rb
+++ b/lib/ohai/plugins/scsi.rb
@@ -18,7 +18,6 @@
#
Ohai.plugin(:Lsscsi) do
- depends "platform"
provides "scsi"
optional true
diff --git a/lib/ohai/plugins/solaris2/network.rb b/lib/ohai/plugins/solaris2/network.rb
index 754a53e7..fb9c5f07 100644
--- a/lib/ohai/plugins/solaris2/network.rb
+++ b/lib/ohai/plugins/solaris2/network.rb
@@ -127,7 +127,7 @@ Ohai.plugin(:Network) do
end
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})/
iface[cint][:addresses] ||= Mash.new
- iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2) , "broadcast" => $4 }
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => hex_to_dec_netmask($2), "broadcast" => $4 }
end
if line =~ %r{\s+inet6 ([a-f0-9\:]+)(\s*|(\%[a-z0-9]+)\s*)/(\d+)\s*$}
iface[cint][:addresses] ||= Mash.new
diff --git a/lib/ohai/plugins/solaris2/virtualization.rb b/lib/ohai/plugins/solaris2/virtualization.rb
index 6a7fc2ec..752aad23 100644
--- a/lib/ohai/plugins/solaris2/virtualization.rb
+++ b/lib/ohai/plugins/solaris2/virtualization.rb
@@ -69,12 +69,11 @@ Ohai.plugin(:Virtualization) do
if zones.length == 1
first_zone = zones.keys[0]
+ virtualization[:system] = "zone"
if first_zone == "global"
- virtualization[:system] = "zone"
virtualization[:role] = "host"
virtualization[:systems][:zone] = "host"
else
- virtualization[:system] = "zone"
virtualization[:role] = "guest"
virtualization[:systems][:zone] = "guest"
virtualization[:guest_uuid] = zones[first_zone]["uuid"]
diff --git a/lib/ohai/plugins/train.rb b/lib/ohai/plugins/train.rb
index 6d48c4cc..9f28ba3e 100644
--- a/lib/ohai/plugins/train.rb
+++ b/lib/ohai/plugins/train.rb
@@ -29,7 +29,6 @@ Ohai.plugin(:Train) do
if transport_connection.respond_to?(:uri)
train["scheme"] = URI.parse(transport_connection.uri).scheme
train["uri"] = transport_connection.uri
- else
end
end
end
diff --git a/lib/ohai/plugins/virtualbox.rb b/lib/ohai/plugins/virtualbox.rb
index 60ec0213..e04b006d 100644
--- a/lib/ohai/plugins/virtualbox.rb
+++ b/lib/ohai/plugins/virtualbox.rb
@@ -128,7 +128,7 @@ Ohai.plugin(:Virtualbox) do
logger.trace("Plugin VboxHost: Could not run '#{so_cmd}'. Skipping data")
end
- collect_data(:default) do
+ collect_data(:windows, :linux, :solaris2, :darwin) do
case virtualization.dig("systems", "vbox")
when "guest"
logger.trace("Plugin Virtualbox: Node detected as vbox guest. Collecting guest data.")
diff --git a/lib/ohai/plugins/zpools.rb b/lib/ohai/plugins/zpools.rb
index bd6ced99..b2a7d2a4 100644
--- a/lib/ohai/plugins/zpools.rb
+++ b/lib/ohai/plugins/zpools.rb
@@ -46,7 +46,6 @@ Ohai.plugin(:Zpools) do
pools[$1][:zpool_version] = sanitize_value($8)
end
end
-
rescue Ohai::Exceptions::Exec
Ohai::Log.debug('Plugin Zpools: Could not shell_out "zpool list -H -o name,size,alloc,free,cap,dedup,health,version". Skipping plugin.')
end
diff --git a/lib/ohai/util/ip_helper.rb b/lib/ohai/util/ip_helper.rb
index 86617935..044afaec 100644
--- a/lib/ohai/util/ip_helper.rb
+++ b/lib/ohai/util/ip_helper.rb
@@ -33,7 +33,7 @@ module Ohai
IPV6_LINK_LOCAL_UNICAST_BLOCK.include?(ip) || IPV6_PRIVATE_ADDRESS_BLOCK.include?(ip)
end
end
- alias :unique_local_address? :private_address?
+ alias unique_local_address? private_address?
def public_address?(addr)
!private_address?(addr)
diff --git a/lib/ohai/version.rb b/lib/ohai/version.rb
index cc3106d7..cbe4f6a5 100644
--- a/lib/ohai/version.rb
+++ b/lib/ohai/version.rb
@@ -19,5 +19,5 @@
module Ohai
OHAI_ROOT = File.expand_path(__dir__)
- VERSION = "16.7.33"
+ VERSION = "16.8.1"
end
diff --git a/ohai.gemspec b/ohai.gemspec
index 854805db..841982d6 100644
--- a/ohai.gemspec
+++ b/ohai.gemspec
@@ -24,8 +24,8 @@ Gem::Specification.new do |s|
s.add_dependency "mixlib-log", ">= 2.0.1", "< 4.0"
s.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
s.add_dependency "plist", "~> 3.1"
- s.add_dependency "wmi-lite", "~> 1.0"
s.add_dependency "train-core"
+ s.add_dependency "wmi-lite", "~> 1.0"
# Note for ohai developers: If chef-config causes you grief, try:
# bundle install --with development
# this should work as long as chef is a development dependency in Gemfile.
diff --git a/spec/unit/plugins/aix/network_spec.rb b/spec/unit/plugins/aix/network_spec.rb
index af944160..d1aa92c9 100644
--- a/spec/unit/plugins/aix/network_spec.rb
+++ b/spec/unit/plugins/aix/network_spec.rb
@@ -21,19 +21,19 @@ require "spec_helper"
describe Ohai::System, "AIX network plugin" do
before do
@netstat_rn = <<~NETSTAT_RN
- Destination Gateway Flags Refcnt Use Interface
- Destination Gateway Flags Refs Use If Exp Groups
- Only the root user can specify the Z flag
- (Internet):
- default 172.31.0.1 UG 2 1652046 en0 - - =>
- 127/8 127.0.0.1 U 5 2455591 lo0 - - =>
- 172.31.0.0 172.31.10.23 UHSb 0 0 en0 - - =>
- 172.31/20 172.31.10.23 U 1 1015674 en0 - - =>
- 172.31.10.23 127.0.0.1 UGHS 0 1 lo0 - -
- 172.31.15.255 172.31.10.23 UHSb 0 1 en0 - - =>
- Only the root user can specify the Z flag
- (Internet v6):
- ::1%1 ::1%1 UH 1 677032 lo0 - - =>
+ Destination Gateway Flags Refcnt Use Interface
+ Destination Gateway Flags Refs Use If Exp Groups
+ Only the root user can specify the Z flag
+ (Internet):
+ default 172.31.0.1 UG 2 1652046 en0 - - =>
+ 127/8 127.0.0.1 U 5 2455591 lo0 - - =>
+ 172.31.0.0 172.31.10.23 UHSb 0 0 en0 - - =>
+ 172.31/20 172.31.10.23 U 1 1015674 en0 - - =>
+ 172.31.10.23 127.0.0.1 UGHS 0 1 lo0 - -
+ 172.31.15.255 172.31.10.23 UHSb 0 1 en0 - - =>
+ Only the root user can specify the Z flag
+ (Internet v6):
+ ::1%1 ::1%1 UH 1 677032 lo0 - - =>
NETSTAT_RN
@ifconfig = <<~IFCONFIG
diff --git a/spec/unit/plugins/c_spec.rb b/spec/unit/plugins/c_spec.rb
index 319bc476..0b895291 100644
--- a/spec/unit/plugins/c_spec.rb
+++ b/spec/unit/plugins/c_spec.rb
@@ -1,4 +1,3 @@
-
# Author:: Doug MacEachern <dougm@vmware.com>
# Copyright:: Copyright (c) 2010 VMware, Inc.
# License:: Apache License, Version 2.0
@@ -66,6 +65,11 @@ C_XLC = <<~EOF.freeze
Version: 09.00.0000.0000
EOF
+C_XLC_NEWER = <<~EOF.freeze
+ IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)
+ Version: 13.01.0003.0000
+EOF
+
C_SUN = <<~EOF.freeze
cc: Sun C 5.8 Patch 121016-06 2007/08/01
EOF
@@ -109,6 +113,13 @@ describe Ohai::System, "plugin c" do
expect(plugin[:languages][:c]).not_to have_key(:xlc)
end
+ it "properly parses 3 part version numbers in newer XLC releases" do
+ expect(plugin).to receive(:shell_out).with("xlc -qversion").and_return(mock_shell_out(0, C_XLC_NEWER, ""))
+ plugin.run
+ expect(plugin.languages[:c][:xlc][:version]).to eql("13.1.3")
+ expect(plugin.languages[:c][:xlc][:description]).to eql("IBM XL C/C++ for AIX, V13.1.3 (5725-C72, 5765-J07)")
+ end
+
it "does not set the languages[:c][:xlc] tree up if xlc command fails" do
allow(plugin).to receive(:shell_out).with("xlc -qversion").and_raise(Ohai::Exceptions::Exec)
plugin.run
diff --git a/spec/unit/plugins/chef_spec.rb b/spec/unit/plugins/chef_spec.rb
index 9199adc3..2584a278 100644
--- a/spec/unit/plugins/chef_spec.rb
+++ b/spec/unit/plugins/chef_spec.rb
@@ -33,7 +33,6 @@ begin
pending "would set [:chef_packages][:chef][:version] if chef was available", unless: defined?(Chef)
end
-
rescue LoadError
# the chef module is not available, ignoring.
diff --git a/spec/unit/plugins/digital_ocean_spec.rb b/spec/unit/plugins/digital_ocean_spec.rb
index 280668c8..ed1d55a4 100644
--- a/spec/unit/plugins/digital_ocean_spec.rb
+++ b/spec/unit/plugins/digital_ocean_spec.rb
@@ -35,6 +35,7 @@ describe Ohai::System, "plugin digital_ocean" do
end
before do
+ allow(plugin).to receive(:collect_os).and_return(:linux)
allow(plugin).to receive(:hint?).with("digital_ocean").and_return(false)
end
diff --git a/spec/unit/plugins/docker_spec.rb b/spec/unit/plugins/docker_spec.rb
index c3105048..5816bc37 100644
--- a/spec/unit/plugins/docker_spec.rb
+++ b/spec/unit/plugins/docker_spec.rb
@@ -40,12 +40,13 @@ expected_output = {
"local",
],
"Network" => %w{
-bridge
-host
-ipvlan
-macvlan
-null
-overlay},
+ bridge
+ host
+ ipvlan
+ macvlan
+ null
+ overlay
+ },
"Authorization" => nil,
"Log" => %w{
awslogs
@@ -77,10 +78,14 @@ overlay},
describe Ohai::System, "plugin docker" do
let(:plugin) { get_plugin("docker") }
+ before do
+ plugin[:virtualization] = Mash.new
+ plugin[:virtualization][:systems] = Mash.new
+ allow(plugin).to receive(:collect_os).and_return(:linux)
+ end
+
context "without docker installed" do
it "does not create a docker attribute" do
- plugin[:virtualization] = Mash.new
- plugin[:virtualization][:systems] = Mash.new
plugin.run
expect(plugin).not_to have_key(:docker)
end
@@ -88,8 +93,6 @@ describe Ohai::System, "plugin docker" do
context "with docker installed" do
it "creates a docker attribute with correct data" do
- plugin[:virtualization] = Mash.new
- plugin[:virtualization][:systems] = Mash.new
plugin[:virtualization][:systems][:docker] = "host"
allow(plugin).to receive(:shell_out).with("docker info --format '{{json .}}'").and_return(mock_shell_out(0, docker_output, ""))
plugin.run
diff --git a/spec/unit/plugins/grub2_spec.rb b/spec/unit/plugins/grub2_spec.rb
new file mode 100644
index 00000000..03fae9cd
--- /dev/null
+++ b/spec/unit/plugins/grub2_spec.rb
@@ -0,0 +1,51 @@
+#
+# Author:: Davide Cavalca <dcavalca@fb.com>
+# Copyright:: Copyright (c) 2020 Facebook
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "spec_helper"
+
+describe Ohai::System, "grub2 plugin" do
+ let(:plugin) { get_plugin("grub2") }
+
+ before do
+ allow(plugin).to receive(:collect_os).and_return(:linux)
+ end
+
+ it "populates grub2 if grub2-editenv is found" do
+ editenv_out = <<-EDITENV_OUT
+saved_entry=f4fd6be6243646e1a76a42d50f219818-5.2.9-229
+boot_success=1
+kernelopts=root=UUID=6db0ffcd-70ec-4333-86c3-873a9e2a0d77 ro
+ EDITENV_OUT
+ allow(plugin).to receive(:which).with("grub2-editenv").and_return("/bin/grub2-editenv")
+ allow(plugin).to receive(:shell_out).with("/bin/grub2-editenv list").and_return(mock_shell_out(0, editenv_out, ""))
+ plugin.run
+ expect(plugin[:grub2].to_hash).to eq({
+ "environment" => {
+ "saved_entry" => "f4fd6be6243646e1a76a42d50f219818-5.2.9-229",
+ "boot_success" => "1",
+ "kernelopts" => "root=UUID=6db0ffcd-70ec-4333-86c3-873a9e2a0d77 ro",
+ },
+ })
+ end
+
+ it "does not populate grub2 if grub2-editenv is not found" do
+ allow(plugin).to receive(:which).with("grub2-editenv").and_return(false)
+ plugin.run
+ expect(plugin[:grub2]).to be(nil)
+ end
+end
diff --git a/spec/unit/plugins/linode_spec.rb b/spec/unit/plugins/linode_spec.rb
index 75d1a933..a591b564 100644
--- a/spec/unit/plugins/linode_spec.rb
+++ b/spec/unit/plugins/linode_spec.rb
@@ -20,7 +20,12 @@ require "spec_helper"
describe Ohai::System, "plugin linode" do
let(:plugin) { get_plugin("linode") }
+ let(:apt_sources) { "# \n\n# deb cdrom:[Ubuntu-Server 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731)]/ focal main restricted\n\n#deb cdrom:[Ubuntu-Server 20.04.1 LTS _Focal Fossa_ - Release amd64 (20200731)]/ focal main restricted\n\n# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to\n# newer versions of the distribution.\ndeb http://mirrors.linode.com/ubuntu/ focal main restricted\n# deb-src http://mirrors.linode.com/ubuntu/ focal main restricted\n\n## Major bug fix updates produced after the final release of the\n## distribution.\ndeb http://mirrors.linode.com/ubuntu/ focal-updates main restricted\n# deb-src http://mirrors.linode.com/ubuntu/ focal-updates main restricted\n\n## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu\n## team. Also, please note that software in universe WILL NOT receive any\n## review or updates from the Ubuntu security team.\ndeb http://mirrors.linode.com/ubuntu/ focal universe\n# deb-src http://mirrors.linode.com/ubuntu/ focal universe\ndeb http://mirrors.linode.com/ubuntu/ focal-updates universe\n# deb-src http://mirrors.linode.com/ubuntu/ focal-updates universe\n\n## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu \n## team, and may not be under a free licence. Please satisfy yourself as to \n## your rights to use the software. Also, please note that software in \n## multiverse WILL NOT receive any review or updates from the Ubuntu\n## security team.\ndeb http://mirrors.linode.com/ubuntu/ focal multiverse\n# deb-src http://mirrors.linode.com/ubuntu/ focal multiverse\ndeb http://mirrors.linode.com/ubuntu/ focal-updates multiverse\n# deb-src http://mirrors.linode.com/ubuntu/ focal-updates multiverse\n\n## N.B. software from this repository may not have been tested as\n## extensively as that contained in the main release, although it includes\n## newer versions of some applications which may provide useful features.\n## Also, please note that software in backports WILL NOT receive any review\n## or updates from the Ubuntu security team.\ndeb http://mirrors.linode.com/ubuntu/ focal-backports main restricted universe multiverse\n# deb-src http://mirrors.linode.com/ubuntu/ focal-backports main restricted universe multiverse\n\n## Uncomment the following two lines to add software from Canonical's\n## 'partner' repository.\n## This software is not part of Ubuntu, but is offered by Canonical and the\n## respective vendors as a service to Ubuntu users.\n# deb http://archive.canonical.com/ubuntu focal partner\n# deb-src http://archive.canonical.com/ubuntu focal partner\n\ndeb http://security.ubuntu.com/ubuntu focal-security main restricted\n# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted\ndeb http://security.ubuntu.com/ubuntu focal-security universe\n# deb-src http://security.ubuntu.com/ubuntu focal-security universe\ndeb http://security.ubuntu.com/ubuntu focal-security multiverse\n# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse\n\n# This system was installed using small removable media\n# (e.g. netinst, live or single CD). The matching \"deb cdrom\"\n# entries were disabled at the end of the installation process.\n# For information about how to configure apt package sources,\n# see the sources.list(5) manual.\n" }
+
before do
+ allow(plugin).to receive(:collect_os).and_return(:linux)
+ allow(plugin).to receive(:file_exist?).with("/etc/apt/sources.list").and_return(false)
+ plugin[:domain] = "nope.example.com"
plugin[:network] = {
"interfaces" => {
"eth0" => {
@@ -69,17 +74,13 @@ describe Ohai::System, "plugin linode" do
end
- context "without linode kernel" do
- before do
- plugin[:kernel] = { "release" => "3.5.2-x86_64" }
- end
-
+ context "without linode domain or apt data" do
it_behaves_like "!linode"
end
- context "with linode kernel" do
+ context "with linode domain" do
before do
- plugin[:kernel] = { "release" => "3.5.2-x86_64-linode24" }
+ plugin[:domain] = "members.linode.com"
end
it_behaves_like "linode"
@@ -116,6 +117,15 @@ describe Ohai::System, "plugin linode" do
end
+ describe "with linode apt sources" do
+ before do
+ allow(plugin).to receive(:file_exist?).with("/etc/apt/sources.list").and_return(true)
+ allow(plugin).to receive(:file_read).with("/etc/apt/sources.list").and_return(apt_sources)
+ end
+
+ it_behaves_like "linode"
+ end
+
describe "with linode hint file" do
before do
allow(plugin).to receive(:hint?).with("linode").and_return({})
diff --git a/spec/unit/plugins/linux/network_spec.rb b/spec/unit/plugins/linux/network_spec.rb
index 978160bb..744fafa8 100644
--- a/spec/unit/plugins/linux/network_spec.rb
+++ b/spec/unit/plugins/linux/network_spec.rb
@@ -720,7 +720,7 @@ describe Ohai::System, "Linux Network Plugin" do
end
it "detects the ipv6 addresses of an ethernet subinterface" do
- %w{ 1111:2222:3333:4444::2 1111:2222:3333:4444::3 }.each do |addr|
+ %w{1111:2222:3333:4444::2 1111:2222:3333:4444::3}.each do |addr|
expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"].keys).to include(addr)
expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"][addr]["scope"]).to eq("Global")
expect(plugin["network"]["interfaces"]["eth0.11"]["addresses"][addr]["prefixlen"]).to eq("64")
diff --git a/spec/unit/plugins/linux/selinux_spec.rb b/spec/unit/plugins/linux/selinux_spec.rb
index 6f8ceef4..dd642b30 100644
--- a/spec/unit/plugins/linux/selinux_spec.rb
+++ b/spec/unit/plugins/linux/selinux_spec.rb
@@ -26,35 +26,35 @@ describe Ohai::System, "Linux selinux plugin" do
end
it "populates selinux if sestatus is found" do
- sestatus_out = <<-SESTATUS_OUT
-SELinux status: enabled
-SELinuxfs mount: /sys/fs/selinux
-SELinux root directory: /etc/selinux
-Loaded policy name: test
-Current mode: permissive
-Mode from config file: permissive
-Policy MLS status: disabled
-Policy deny_unknown status: allowed
-Max kernel policy version: 31
+ sestatus_out = <<~SESTATUS_OUT
+ SELinux status: enabled
+ SELinuxfs mount: /sys/fs/selinux
+ SELinux root directory: /etc/selinux
+ Loaded policy name: test
+ Current mode: permissive
+ Mode from config file: permissive
+ Policy MLS status: disabled
+ Policy deny_unknown status: allowed
+ Max kernel policy version: 31
-Policy booleans:
-secure_mode_policyload off
+ Policy booleans:
+ secure_mode_policyload off
-Process contexts:
-Current context: user_u:base_r:admin_t
-Init context: system_u:system_r:init_t
-/usr/sbin/sshd system_u:base_r:base_t
+ Process contexts:
+ Current context: user_u:base_r:admin_t
+ Init context: system_u:system_r:init_t
+ /usr/sbin/sshd system_u:base_r:base_t
-File contexts:
-Controlling terminal: system_u:object_r:file_t
-/etc/passwd user_u:object_r:file_t
-/etc/shadow user_u:object_r:file_t
-/bin/bash user_u:object_r:file_t
-/bin/login user_u:object_r:file_t
-/bin/sh user_u:object_r:file_t -> user_u:object_r:file_t
-/sbin/agetty user_u:object_r:file_t
-/sbin/init user_u:object_r:file_t -> user_u:object_r:init_exec_t
-/usr/sbin/sshd user_u:object_r:file_t
+ File contexts:
+ Controlling terminal: system_u:object_r:file_t
+ /etc/passwd user_u:object_r:file_t
+ /etc/shadow user_u:object_r:file_t
+ /bin/bash user_u:object_r:file_t
+ /bin/login user_u:object_r:file_t
+ /bin/sh user_u:object_r:file_t -> user_u:object_r:file_t
+ /sbin/agetty user_u:object_r:file_t
+ /sbin/init user_u:object_r:file_t -> user_u:object_r:init_exec_t
+ /usr/sbin/sshd user_u:object_r:file_t
SESTATUS_OUT
allow(plugin).to receive(:which).with("sestatus").and_return("/usr/sbin/sestatus")
allow(plugin).to receive(:shell_out).with("/usr/sbin/sestatus -v -b").and_return(mock_shell_out(0, sestatus_out, ""))
diff --git a/spec/unit/plugins/packages_spec.rb b/spec/unit/plugins/packages_spec.rb
index 0406aaac..cc658bff 100644
--- a/spec/unit/plugins/packages_spec.rb
+++ b/spec/unit/plugins/packages_spec.rb
@@ -190,10 +190,10 @@ describe Ohai::System, "plugin packages" do
"Publisher" => "nxsec.com",
"InstallDate" => "20150511",
},
- { "DisplayName" => "Chef Development Kit v0.7.0",
- "DisplayVersion" => "0.7.0.1",
- "Publisher" => "\"Chef Software, Inc. <maintainers@chef.io>\"",
- "InstallDate" => "20150925" }]
+ { "DisplayName" => "Chef Development Kit v0.7.0",
+ "DisplayVersion" => "0.7.0.1",
+ "Publisher" => "\"Chef Software, Inc. <maintainers@chef.io>\"",
+ "InstallDate" => "20150925" }]
end
shared_examples "windows_package_plugin" do
diff --git a/spec/unit/plugins/scaleway_spec.rb b/spec/unit/plugins/scaleway_spec.rb
index 1869322a..238cd51d 100644
--- a/spec/unit/plugins/scaleway_spec.rb
+++ b/spec/unit/plugins/scaleway_spec.rb
@@ -21,6 +21,7 @@ describe Ohai::System, "plugin scaleway" do
let(:plugin) { get_plugin("scaleway") }
before do
+ allow(plugin).to receive(:collect_os).and_return(:linux)
allow(plugin).to receive(:hint?).with("scaleway").and_return(false)
allow(plugin).to receive(:file_exist?).with("/proc/cmdline").and_return(false)
end
diff --git a/spec/unit/plugins/shard_spec.rb b/spec/unit/plugins/shard_spec.rb
index f0da5fb5..b0f3b154 100644
--- a/spec/unit/plugins/shard_spec.rb
+++ b/spec/unit/plugins/shard_spec.rb
@@ -119,7 +119,7 @@ describe Ohai::System, "shard plugin" do
let(:os) { "aix" }
it "provides a shard with a default-safe set of sources" do
- # Note: this is different than the other defaults.
+ # NOTE: this is different than the other defaults.
expect(subject).to eq(253499154)
end
end
diff --git a/spec/unit/plugins/solaris2/network_spec.rb b/spec/unit/plugins/solaris2/network_spec.rb
index 07151ce7..9bbf300c 100644
--- a/spec/unit/plugins/solaris2/network_spec.rb
+++ b/spec/unit/plugins/solaris2/network_spec.rb
@@ -177,7 +177,7 @@ describe Ohai::System, "Solaris2.X network plugin" do
end
it "finds the flags for a PHYSRUNNING interface" do
- expect(@plugin[:network][:interfaces]["net1:1"][:flags]).to eq(%w{ UP BROADCAST RUNNING MULTICAST IPv4 PHYSRUNNING })
+ expect(@plugin[:network][:interfaces]["net1:1"][:flags]).to eq(%w{UP BROADCAST RUNNING MULTICAST IPv4 PHYSRUNNING})
end
it "finds the default interface for a solaris 11 zone" do