Class: VolumeVisualizer::ZFS::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/volume_visualizer/zfs/pool.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pool_name) ⇒ Pool

Returns a new instance of Pool.



16
17
18
# File 'lib/volume_visualizer/zfs/pool.rb', line 16

def initialize(pool_name)
  @pool_name = pool_name
end

Instance Attribute Details

#pool_nameObject (readonly)

Returns the value of attribute pool_name.



4
5
6
# File 'lib/volume_visualizer/zfs/pool.rb', line 4

def pool_name
  @pool_name
end

Class Method Details

.query_command(pool_name = "tank") ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/volume_visualizer/zfs/pool.rb', line 6

def self.query_command(pool_name = "tank")
  attrs = ATTRS.collect { |a| a.to_s.gsub("_","") }.join(",")
  command = "zfs list -t all -H -r -o #{attrs} #{pool_name}"
  if ENV["USER"] != "root"
    command = "sudo " + command
  else
    command
  end
end

Instance Method Details

#dataObject



20
21
22
23
# File 'lib/volume_visualizer/zfs/pool.rb', line 20

def data
  STDERR.puts "reading ZFS data"
  File.popen(Pool.query_command pool_name).readlines
end