Skip to content

Commit

Permalink
Merge pull request #998 from chef/backports
Browse files Browse the repository at this point in the history
Additional backports + Release 8.24.0
  • Loading branch information
tas50 authored May 9, 2017
2 parents e6f91ac + e29a222 commit 3f59946
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 9 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Change Log

## [8.23.0](https://github.com/chef/ohai/tree/8.23.0) (2017-01-23)
## [8.24.0](https://github.com/chef/ohai/tree/v8.24.0) (2017-05-08)

[Full Changelog](https://github.com/chef/ohai/compare/v8.23.0...v8.24.0)

- base: Load additional ohai plugins from /etc/chef/ohai/plugins or C:\chef\ohai\plugins\
- ec2: Poll EC2 metadata from the new 2016 metadata API versions [#992](https://github.com/chef/ohai/pull/992) ([tas50](https://github.com/tas50))
- mdadm: Add a new 'members' attribute for member devices in the array [#989](https://github.com/chef/ohai/pull/989) ([jaymzh](https://github.com/jaymzh))
- dmi: Add DMI type 40,41, and 42 from the latest man page [#969](https://github.com/chef/ohai/pull/969) ([tas50](https://github.com/tas50))
- ec2: Gather availability_zone and region data [#964](https://github.com/chef/ohai/pull/964) ([webframp](https://github.com/webframp))
- scala: Fix scala detection when version output contains a warning [#959](https://github.com/chef/ohai/pull/959) ([tas50](https://github.com/tas50))
- lua: Fix lua detection on new versions of lua [#958](https://github.com/chef/ohai/pull/958) ([tas50](https://github.com/tas50))
- dmi: Rescue exception in DMI plugin to improve debug logs [#952](https://github.com/chef/ohai/pull/952) ([tas50](https://github.com/tas50))

## [v8.23.0](https://github.com/chef/ohai/tree/v8.23.0) (2017-01-24)

[Full Changelog](https://github.com/chef/ohai/compare/v8.22.1...v8.23.0)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ gemspec
group :development do
gem "sigar", :platform => "ruby"

gem "chefstyle"
gem "chefstyle", "0.4.0"
gem "overcommit", ">= 0.34.1"
gem "pry-byebug"
gem "pry-stack_explorer"
Expand Down
2 changes: 1 addition & 1 deletion lib/ohai/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def default_hints_path
end

def default_plugin_path
[ File.expand_path(File.join(File.dirname(__FILE__), "plugins")) ]
[ File.expand_path(File.join(File.dirname(__FILE__), "plugins")), ChefConfig::Config.platform_specific_path("/etc/chef/ohai/plugins") ]
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ohai/loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Loader
# Finds all the *.rb files under the configured paths in :plugin_path
def self.find_all_in(plugin_dir)
unless Dir.exist?(plugin_dir)
Ohai::Log.warn("The plugin path #{plugin_dir} does not exist. Skipping...")
Ohai::Log.info("The plugin path #{plugin_dir} does not exist. Skipping...")
return []
end

Expand Down
13 changes: 10 additions & 3 deletions lib/ohai/plugins/linux/mdadm.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#
# Author:: Tim Smith <[email protected]>
# Author:: Phil Dibowitz <[email protected]>
# Copyright:: Copyright (c) 2013-2014, Limelight Networks, Inc.
# Copyright:: Copyright (c) 2017 Facebook, Inc.
# Plugin:: mdadm
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -52,22 +54,27 @@ def create_raid_device_mash(stdout)
collect_data(:linux) do
# gather a list of all raid arrays
if File.exist?("/proc/mdstat")
devices = []
devices = {}
File.open("/proc/mdstat").each do |line|
devices << Regexp.last_match[1] if line =~ /(md[0-9]+)/
if line =~ /(md[0-9]+)/
device = Regexp.last_match[1]
pieces = line.split(/\s+/)
devices[device] = pieces[4..-1].map { |s| s.match(/(.+)\[\d\]/)[1] }
end
end

# create the mdadm mash and gather individual information if devices are present
unless devices.empty?
mdadm Mash.new
devices.sort.each do |device|
devices.keys.sort.each do |device|
mdadm[device] = Mash.new

# gather detailed information on the array
so = shell_out("mdadm --detail /dev/#{device}")

# if the mdadm command was sucessful pass so.stdout to create_raid_device_mash to grab the tidbits we want
mdadm[device] = create_raid_device_mash(so.stdout) if so.stdout
mdadm[device]["members"] = devices[device]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ohai/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@

module Ohai
OHAI_ROOT = File.expand_path(File.dirname(__FILE__))
VERSION = "8.23.0"
VERSION = "8.24.0"
end
2 changes: 1 addition & 1 deletion spec/unit/loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@

describe "when plugin directory does not exist" do
it "logs an invalid plugin path warning" do
expect(Ohai::Log).to receive(:warn).with(/The plugin path.*does not exist/)
expect(Ohai::Log).to receive(:info).with(/The plugin path.*does not exist/)
allow(Dir).to receive(:exist?).with("/bogus/dir").and_return(false)
Ohai::Loader::PluginFile.find_all_in("/bogus/dir")
end
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/plugins/linux/mdadm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@
end
end

it "should detect member devies" do
@plugin.run
expect(@plugin[:mdadm][:md0][:members].sort).to eq(
%w{sdc sdd sde sdf sdg sdh}
)
end
end

end

0 comments on commit 3f59946

Please sign in to comment.