From 3bc62dd32defaa16ded539cbf4365f83c7323b6a Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Thu, 29 Oct 2020 15:03:27 -0700 Subject: Gather zpool disks even if we use labels/guids We were expecting the disk name for each device in the pool, but it's actually better to add them by disk id or guid. That entirely breaks out regex so use -L on linux to make sure we get the underlying disk. Signed-off-by: Tim Smith --- lib/ohai/plugins/zpools.rb | 4 +++- spec/unit/plugins/zpools_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ohai/plugins/zpools.rb b/lib/ohai/plugins/zpools.rb index 0bf40a73..e27bf610 100644 --- a/lib/ohai/plugins/zpools.rb +++ b/lib/ohai/plugins/zpools.rb @@ -65,7 +65,9 @@ Ohai.plugin(:Zpools) do if platform_family == "solaris2" command = "su adm -c \"zpool status #{pool}\"" else - command = "zpool status #{pool}" + # -L is used to give us real device names not label or uuid + # for example sda instead of ata-WDC_WD60EZAZ-00SF3B0_WD-WX32D203UXYK + command = "zpool status #{pool} -L" end so = shell_out(command) diff --git a/spec/unit/plugins/zpools_spec.rb b/spec/unit/plugins/zpools_spec.rb index 5ed5a559..931689b7 100644 --- a/spec/unit/plugins/zpools_spec.rb +++ b/spec/unit/plugins/zpools_spec.rb @@ -71,8 +71,8 @@ describe Ohai::System, "zpools plugin" do allow(plugin).to receive(:platform_family).and_return("rhel") allow(plugin).to receive(:collect_os).and_return(:linux) allow(plugin).to receive(:shell_out).with("zpool list -H -o name,size,alloc,free,cap,dedup,health,version").and_return(mock_shell_out(0, zpool_out, "")) - allow(plugin).to receive(:shell_out).with("zpool status rpool").and_return(mock_shell_out(0, zpool_status_rpool, "")) - allow(plugin).to receive(:shell_out).with("zpool status tank").and_return(mock_shell_out(0, zpool_status_tank, "")) + allow(plugin).to receive(:shell_out).with("zpool status rpool -L").and_return(mock_shell_out(0, zpool_status_rpool, "")) + allow(plugin).to receive(:shell_out).with("zpool status tank -L").and_return(mock_shell_out(0, zpool_status_tank, "")) end it "Has entries for both zpools" do -- cgit v1.2.1