Class: Zfs::Dataset
- Inherits:
-
Object
- Object
- Zfs::Dataset
- Defined in:
- lib/zfstools/dataset.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Class Method Summary collapse
Instance Method Summary collapse
- #==(dataset) ⇒ Object
- #contains_db!(kind) ⇒ Object
-
#initialize(name, properties = {}, options = {}) ⇒ Dataset
constructor
A new instance of Dataset.
Constructor Details
#initialize(name, properties = {}, options = {}) ⇒ Dataset
Returns a new instance of Dataset.
6 7 8 9 10 11 12 |
# File 'lib/zfstools/dataset.rb', line 6 def initialize(name, properties={}, ={}) @name = name @properties = properties if ["mysql","postgresql"].include? properties[snapshot_property] self.contains_db!(properties[snapshot_property]) end end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
5 6 7 |
# File 'lib/zfstools/dataset.rb', line 5 def db @db end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/zfstools/dataset.rb', line 3 def name @name end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
4 5 6 |
# File 'lib/zfstools/dataset.rb', line 4 def properties @properties end |
Class Method Details
.list(pool = nil, properties = []) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/zfstools/dataset.rb', line 23 def self.list(pool=nil, properties=[]) datasets = [] cmd_properties = ["name"] + properties cmd="zfs list -H -t filesystem,volume -o #{cmd_properties.join(",")} -s name" cmd += " -r #{pool}" if pool puts cmd if $debug IO.popen cmd do |io| io.readlines.each do |line| values = line.split name = values.shift dataset_properties = {} properties.each_with_index do |property_name, i| value = values[i] next if value == '-' dataset_properties[property_name] = value end datasets << self.new(name, dataset_properties) end end datasets end |
Instance Method Details
#==(dataset) ⇒ Object
14 15 16 |
# File 'lib/zfstools/dataset.rb', line 14 def ==(dataset) dataset.equal?(self) || (dataset && dataset.name == @name) end |
#contains_db!(kind) ⇒ Object
18 19 20 21 |
# File 'lib/zfstools/dataset.rb', line 18 def contains_db!(kind) @db = kind self end |