From 7707d8a6cac19ee6532fa9d1a345740c3afc0c07 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Thu, 13 Apr 2017 20:47:40 -0700 Subject: [PATCH 1/4] Merge pull request #989 from jaymzh/mdadm [mdadm] Fill in member devices --- lib/ohai/plugins/linux/mdadm.rb | 13 ++++++++++--- spec/unit/plugins/linux/mdadm_spec.rb | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/ohai/plugins/linux/mdadm.rb b/lib/ohai/plugins/linux/mdadm.rb index 0075750a4..7133913a5 100644 --- a/lib/ohai/plugins/linux/mdadm.rb +++ b/lib/ohai/plugins/linux/mdadm.rb @@ -1,6 +1,8 @@ # # Author:: Tim Smith +# Author:: Phil Dibowitz # 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"); @@ -52,15 +54,19 @@ 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 @@ -68,6 +74,7 @@ def create_raid_device_mash(stdout) # 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 diff --git a/spec/unit/plugins/linux/mdadm_spec.rb b/spec/unit/plugins/linux/mdadm_spec.rb index 2e8b533d4..a2f0403ff 100644 --- a/spec/unit/plugins/linux/mdadm_spec.rb +++ b/spec/unit/plugins/linux/mdadm_spec.rb @@ -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 From 46f1f2443ce5d3f992e44506901dae6c114bb716 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 8 May 2017 16:55:02 -0700 Subject: [PATCH 2/4] Ping to Chefstyle 0.4.0 We used this during the 8.23 release and it avoids having to redo all the chefstyle fixes which fail specs at the moment Signed-off-by: Tim Smith --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 4bcd5f6db..aebcfd92f 100644 --- a/Gemfile +++ b/Gemfile @@ -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" From 7a8ee94b700c08498350b8c11dd60735db9564eb Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 8 May 2017 17:04:41 -0700 Subject: [PATCH 3/4] Backport the additional plugin path logic from Ohai 13 This was done in 3 different PRs that reworked the entire config logic. Porting this back to 12 brings us 1 step closer to killing the ohai cookbook and fixes an enormous pain point for anyone trying to install their own Ohai plugins Signed-off-by: Tim Smith --- lib/ohai/config.rb | 2 +- lib/ohai/loader.rb | 2 +- spec/unit/loader_spec.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ohai/config.rb b/lib/ohai/config.rb index f7e1f5187..3722f848b 100644 --- a/lib/ohai/config.rb +++ b/lib/ohai/config.rb @@ -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 diff --git a/lib/ohai/loader.rb b/lib/ohai/loader.rb index 0468a6ded..8ecd3192d 100644 --- a/lib/ohai/loader.rb +++ b/lib/ohai/loader.rb @@ -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 diff --git a/spec/unit/loader_spec.rb b/spec/unit/loader_spec.rb index bfe2aa83a..7ee9bd1a7 100644 --- a/spec/unit/loader_spec.rb +++ b/spec/unit/loader_spec.rb @@ -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 From e29a222d4f480596970ff8d5b96b6295dd19606d Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Thu, 15 Dec 2016 08:58:17 -0800 Subject: [PATCH 4/4] Bump version to 8.24.0 Signed-off-by: Tim Smith --- CHANGELOG.md | 15 ++++++++++++++- lib/ohai/version.rb | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b681a417..7f4ef306f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/ohai/version.rb b/lib/ohai/version.rb index 235639b06..f7eb9381f 100644 --- a/lib/ohai/version.rb +++ b/lib/ohai/version.rb @@ -18,5 +18,5 @@ module Ohai OHAI_ROOT = File.expand_path(File.dirname(__FILE__)) - VERSION = "8.23.0" + VERSION = "8.24.0" end