diff options
author | Saravanan D <saravanand@outlook.com> | 2022-03-15 17:25:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-15 17:25:54 -0700 |
commit | cbc8437f9f8e1b7a60af061dc68882185b5e20b3 (patch) | |
tree | c6d2640f8c4aee9ed5ade8892395a0a1943d2903 | |
parent | 996b52b8017f1378e4c29b4faeb9ed90db1e9579 (diff) | |
download | ohai-cbc8437f9f8e1b7a60af061dc68882185b5e20b3.tar.gz |
[mdadm] Record array UUID (#1742)
Useful to have the UUID of the arrays to assemble them when the need arises
Signed-off-by: Saravanan D <saravanand@fb.com>
-rw-r--r-- | lib/ohai/plugins/linux/mdadm.rb | 2 | ||||
-rw-r--r-- | spec/unit/plugins/linux/mdadm_spec.rb | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/ohai/plugins/linux/mdadm.rb b/lib/ohai/plugins/linux/mdadm.rb index f7bfc528..b20d99bb 100644 --- a/lib/ohai/plugins/linux/mdadm.rb +++ b/lib/ohai/plugins/linux/mdadm.rb @@ -35,6 +35,8 @@ Ohai.plugin(:Mdadm) do device_mash[:size] = Regexp.last_match[1].to_f when /State\s+: ([a-z]+)/ device_mash[:state] = Regexp.last_match[1] + when /UUID\s+: ([0-9a-z:]+)/ + device_mash[:UUID] = Regexp.last_match[1] when /Total Devices\s+: ([0-9]+)/ device_mash[:device_counts][:total] = Regexp.last_match[1].to_i when /Raid Devices\s+: ([0-9]+)/ diff --git a/spec/unit/plugins/linux/mdadm_spec.rb b/spec/unit/plugins/linux/mdadm_spec.rb index b7b67b83..7a778173 100644 --- a/spec/unit/plugins/linux/mdadm_spec.rb +++ b/spec/unit/plugins/linux/mdadm_spec.rb @@ -91,6 +91,11 @@ describe Ohai::System, "Linux Mdadm Plugin" do expect(@plugin[:mdadm][:md0][:version]).to eq(1.2) end + it "detects raid UUID" do + @plugin.run + expect(@plugin[:mdadm][:md0][:UUID]).to eq("5ed74d5b:70bfe21d:8cd57792:c1e13d65") + end + device_counts = { raid: 6, total: 6, active: 6, working: 6, failed: 0, spare: 0 } device_counts.each_pair do |item, expected_value| it "detects device count of \"#{item}\"" do |