Skip to content

Get pool data however the state (resp. status) #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/puppet/provider/zpool/zpool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,21 @@ def process_zpool_data(pool_array)
end

def get_pool_data
# https://docs.oracle.com/cd/E19082-01/817-2271/gbcve/index.html
# we could also use zpool iostat -v mypool for a (little bit) cleaner output
# https://openzfs.github.io/openzfs-docs/msg/index.html
# https://docs.oracle.com/cd/E19120-01/open.solaris/817-2271/gbcve/index.html
zpool_opts = case Facter.value(:kernel)
# use full device names ("-P") on Linux/ZOL to prevent
# mismatches between creation and display paths:
# Do not use the 'scripted mode' ("-H") to maintain
# compatibility with non-OpenZFS targets.
#
# Use full device names ("-P") on Linux (OpenZFS) to
# prevent mismatches between creation and display paths:
when 'Linux'
'-P'
else
''
end
out = execute("zpool status #{zpool_opts} #{@resource[:pool]}", failonfail: false, combine: false)
zpool_data = out.lines.select { |line| line.index("\t") == 0 }.map { |l| l.strip.split("\s")[0] }
zpool_data.shift
out = execute("zpool iostat -v #{zpool_opts} #{@resource[:pool]}", failonfail: false, combine: false)
zpool_data = out.lines.reject { |line| line.strip.empty? }[3..-2].map { |line| line.strip.split("\s")[0] }
zpool_data
end

Expand Down