diff options
author | Tim Smith <tsmith@chef.io> | 2017-11-08 13:24:26 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-08 13:24:26 -0800 |
commit | 0eeee400bf838357953ac342f66491cc67a6430e (patch) | |
tree | d73f08f97e6fb9bf6a5abcf60a323c19d2436fac | |
parent | 629ae2a25a43ef6625b53aa9ba54dc32fca9cc78 (diff) | |
parent | 405d4bfbf7c3f366eaa327c1d1f593fa880a6fea (diff) | |
download | ohai-0eeee400bf838357953ac342f66491cc67a6430e.tar.gz |
Merge pull request #1084 from jaymzh/mdadm
[mdadm] Support arrays more than 10 disks
-rw-r--r-- | lib/ohai/plugins/linux/mdadm.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/linux/mdadm_spec.rb | 14 |
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/ohai/plugins/linux/mdadm.rb b/lib/ohai/plugins/linux/mdadm.rb index 4def6c50..bd4d780b 100644 --- a/lib/ohai/plugins/linux/mdadm.rb +++ b/lib/ohai/plugins/linux/mdadm.rb @@ -67,7 +67,7 @@ Ohai.plugin(:Mdadm) do # drop the 'raid' too members.shift unless members.empty? - devices[device] = members.map { |s| s.match(/(.+)\[\d\]/)[1] } + devices[device] = members.map { |s| s.match(/(.+)\[\d+\]/)[1] } end end diff --git a/spec/unit/plugins/linux/mdadm_spec.rb b/spec/unit/plugins/linux/mdadm_spec.rb index 9b6f9e0c..a3feeba1 100644 --- a/spec/unit/plugins/linux/mdadm_spec.rb +++ b/spec/unit/plugins/linux/mdadm_spec.rb @@ -106,6 +106,20 @@ MD ) end + it "should detect member devices even if there are multi-digit numbers" do + new_mdstat = double("/proc/mdstat2") + allow(new_mdstat).to receive(:each). + and_yield("Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10]"). + and_yield("md0 : active raid10 sdj[2010] sdi[99] sdh[5] sdg[4] sdf[3] sde[2] sdd[1] sdc[0]"). + and_yield(" 2929893888 blocks super 1.2 256K chunks 2 near-copies [6/6] [UUUUUU]") + allow(File).to receive(:open).with("/proc/mdstat").and_return(new_mdstat) + + @plugin.run + expect(@plugin[:mdadm][:md0][:members].sort).to eq( + %w{sdc sdd sde sdf sdg sdh sdi sdj} + ) + end + it "should detect member devices even if mdstat has extra entries" do new_mdstat = double("/proc/mdstat2") allow(new_mdstat).to receive(:each). |