summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-10-30 13:32:55 -0700
committerTim Smith <tsmith84@gmail.com>2020-10-30 13:32:55 -0700
commit6e3c3ccd228feb8249be9f6cd338e7f23dd98b99 (patch)
treeb736da405a8389bf28a83ea11888b89d119f23a2
parente5ecdfd02cf2a21ef49a16a3551250ad05e922d4 (diff)
downloadohai-6e3c3ccd228feb8249be9f6cd338e7f23dd98b99.tar.gz
Properly detect NVME devices in ZFS zpools
Add another match in the zpool status regex and then update the existing unit test to have some NVME devices in it. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/plugins/zpools.rb2
-rw-r--r--spec/unit/plugins/zpools_spec.rb18
2 files changed, 10 insertions, 10 deletions
diff --git a/lib/ohai/plugins/zpools.rb b/lib/ohai/plugins/zpools.rb
index e27bf610..e0a1a99b 100644
--- a/lib/ohai/plugins/zpools.rb
+++ b/lib/ohai/plugins/zpools.rb
@@ -76,7 +76,7 @@ Ohai.plugin(:Zpools) do
# linux: http://rubular.com/r/J3wQC6E2lH
# solaris: http://rubular.com/r/FqOBzUQQ4p
# freebsd: http://rubular.com/r/RYkMNlytXl
- when /^\s+((sd|c|ad|da)[-_a-zA-Z0-9]+)\s+([-_a-zA-Z0-9]+)\s+(\d+)\s+(\d+)\s+(\d+)$/
+ when /^\s+((sd|c|ad|da|nvme)[-_a-zA-Z0-9]+)\s+([-_a-zA-Z0-9]+)\s+(\d+)\s+(\d+)\s+(\d+)$/
logger.trace("Plugin Zpools: Parsing zpool status line: #{line.chomp}")
pools[pool][:devices][$1] = Mash.new
pools[pool][:devices][$1][:state] = $3
diff --git a/spec/unit/plugins/zpools_spec.rb b/spec/unit/plugins/zpools_spec.rb
index 931689b7..511e6c1a 100644
--- a/spec/unit/plugins/zpools_spec.rb
+++ b/spec/unit/plugins/zpools_spec.rb
@@ -36,12 +36,12 @@ describe Ohai::System, "zpools plugin" do
sdg ONLINE 0 0 0
sdh ONLINE 0 0 0
raidz2-1 ONLINE 0 0 0
- sdi ONLINE 0 0 0
- sdj ONLINE 0 0 0
- sdk ONLINE 0 0 0
- sdl ONLINE 0 0 0
- sdm ONLINE 0 0 0
- sdn ONLINE 0 0 0
+ nvme0n1 ONLINE 0 0 0
+ nvme1n1 ONLINE 0 0 0
+ nvme2n1 ONLINE 0 0 0
+ nvme3n1 ONLINE 0 0 0
+ nvme4n1 ONLINE 0 0 0
+ nvme5n1 ONLINE 0 0 0
EOST
end
let(:zpool_out) do
@@ -117,10 +117,10 @@ describe Ohai::System, "zpools plugin" do
expect(plugin[:zpools][:tank][:health]).to match("ONLINE")
end
- it "Has the correct number of devices" do
+ it "Has the correct devices per zpool" do
plugin.run
- expect(plugin[:zpools][:rpool][:devices].keys.size).to match(2)
- expect(plugin[:zpools][:tank][:devices].keys.size).to match(12)
+ expect(plugin[:zpools][:rpool][:devices].keys).to match(%w{sda sdb})
+ expect(plugin[:zpools][:tank][:devices].keys).to match(%w{sdc sdd sde sdf sdg sdh nvme0n1 nvme1n1 nvme2n1 nvme3n1 nvme4n1 nvme5n1})
end
it "Won't have a version number" do