diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-10-29 15:03:27 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-10-29 15:10:21 -0700 |
commit | 3bc62dd32defaa16ded539cbf4365f83c7323b6a (patch) | |
tree | 8abe64e3e9b708fefd216756a0a165bd42773404 | |
parent | 7b700df35ec1d884ac6507016bf2319d70dffa36 (diff) | |
download | ohai-3bc62dd32defaa16ded539cbf4365f83c7323b6a.tar.gz |
Gather zpool disks even if we use labels/guidsmore_zpool
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 <tsmith@chef.io>
-rw-r--r-- | lib/ohai/plugins/zpools.rb | 4 | ||||
-rw-r--r-- | 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 |