Class: OsCtl::Lib::Zfs::PropertyReader
- Inherits:
-
Object
- Object
- OsCtl::Lib::Zfs::PropertyReader
- Includes:
- Utils::Log, Utils::System
- Defined in:
- lib/libosctl/zfs/property_reader.rb
Overview
Read selected dataset properties into DatasetTree
Instance Method Summary collapse
Methods included from Utils::System
#repeat_on_failure, #syscmd, #zfs
Methods included from Utils::Log
Instance Method Details
#read(dataset_names, properties, type: 'filesystem', recursive: false, ignore_error: false) ⇒ Zfs::DatasetTree
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/libosctl/zfs/property_reader.rb', line 13 def read(dataset_names, properties, type: 'filesystem', recursive: false, ignore_error: false) tree = Zfs::DatasetTree.new return tree if dataset_names.empty? zfs_opts = [ '-Hp', '-o', 'name,property,value', '-t', type ] zfs_opts << '-r' if recursive zfs_opts << properties.join(',') zfs( :get, zfs_opts.join(' '), dataset_names.join(' '), { stderr: false, valid_rcs: ignore_error ? :all : [0] } ).output.strip.split("\n").each do |line| dataset, prop, val = line.split("\t") tree.add_property(dataset, prop, val) end tree end |