Class: OsCtld::Mount::Entry
- Inherits:
-
Object
- Object
- OsCtld::Mount::Entry
- Defined in:
- lib/osctld/mount/entry.rb
Constant Summary collapse
- PARAMS =
%i[fs mountpoint type opts automount dataset temp].freeze
Instance Attribute Summary collapse
-
#automount ⇒ Object
(also: #automount?)
readonly
Returns the value of attribute automount.
-
#dataset ⇒ Object
readonly
Returns the value of attribute dataset.
-
#in_config ⇒ Object
(also: #in_config?)
readonly
Returns the value of attribute in_config.
-
#map_ids ⇒ Object
readonly
Returns the value of attribute map_ids.
-
#mountpoint ⇒ Object
readonly
Returns the value of attribute mountpoint.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#temp ⇒ Object
(also: #temp?)
readonly
Returns the value of attribute temp.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.load(ct, cfg) ⇒ Object
Load from config.
Instance Method Summary collapse
-
#dump ⇒ Object
Dump to config.
- #dup(new_ct) ⇒ Object
-
#export ⇒ Object
Export to client.
- #fs ⇒ Object
-
#initialize(fs, mountpoint, type, opts, automount, dataset: nil, map_ids: false, temp: false, in_config: false) ⇒ Entry
constructor
A new instance of Entry.
- #lxc_mountpoint ⇒ Object
Constructor Details
#initialize(fs, mountpoint, type, opts, automount, dataset: nil, map_ids: false, temp: false, in_config: false) ⇒ Entry
Returns a new instance of Entry.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/osctld/mount/entry.rb', line 25 def initialize(fs, mountpoint, type, opts, automount, dataset: nil, map_ids: false, temp: false, in_config: false) @fs = fs @mountpoint = mountpoint @type = type @opts = opts @automount = automount @dataset = dataset @map_ids = map_ids @temp = temp @in_config = in_config end |
Instance Attribute Details
#automount ⇒ Object (readonly) Also known as: automount?
Returns the value of attribute automount.
4 5 6 |
# File 'lib/osctld/mount/entry.rb', line 4 def automount @automount end |
#dataset ⇒ Object (readonly)
Returns the value of attribute dataset.
4 5 6 |
# File 'lib/osctld/mount/entry.rb', line 4 def dataset @dataset end |
#in_config ⇒ Object (readonly) Also known as: in_config?
Returns the value of attribute in_config.
4 5 6 |
# File 'lib/osctld/mount/entry.rb', line 4 def in_config @in_config end |
#map_ids ⇒ Object (readonly)
Returns the value of attribute map_ids.
4 5 6 |
# File 'lib/osctld/mount/entry.rb', line 4 def map_ids @map_ids end |
#mountpoint ⇒ Object (readonly)
Returns the value of attribute mountpoint.
4 5 6 |
# File 'lib/osctld/mount/entry.rb', line 4 def mountpoint @mountpoint end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
4 5 6 |
# File 'lib/osctld/mount/entry.rb', line 4 def opts @opts end |
#temp ⇒ Object (readonly) Also known as: temp?
Returns the value of attribute temp.
4 5 6 |
# File 'lib/osctld/mount/entry.rb', line 4 def temp @temp end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/osctld/mount/entry.rb', line 4 def type @type end |
Class Method Details
.load(ct, cfg) ⇒ Object
Load from config
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/osctld/mount/entry.rb', line 7 def self.load(ct, cfg) dataset = cfg['dataset'] && OsCtl::Lib::Zfs::Dataset.new( cfg['dataset'] == '/' ? ct.dataset.name : File.join(ct.dataset.name, cfg['dataset']), base: ct.dataset.name ) new( cfg['fs'], cfg['mountpoint'], cfg['type'], cfg['opts'], cfg['automount'], dataset:, map_ids: cfg.fetch('map_ids', !dataset.nil?), temp: cfg['temporary'] ) end |
Instance Method Details
#dump ⇒ Object
Dump to config
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/osctld/mount/entry.rb', line 62 def dump { 'fs' => dataset ? nil : fs, 'mountpoint' => mountpoint, 'type' => type, 'opts' => opts, 'automount' => automount, 'dataset' => dataset && dataset.relative_name, 'map_ids' => map_ids, 'temporary' => temp } end |
#dup(new_ct) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/osctld/mount/entry.rb', line 75 def dup(new_ct) ret = super() if dataset ret.instance_variable_set('@dataset', OsCtl::Lib::Zfs::Dataset.new( File.join(new_ct.dataset.name, dataset.relative_name).chomp('/'), base: new_ct.dataset.name )) end ret end |
#export ⇒ Object
Export to client
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/osctld/mount/entry.rb', line 48 def export { fs:, mountpoint:, type:, opts:, automount:, dataset: dataset && dataset.relative_name, map_ids: map_ids, temporary: temp } end |
#fs ⇒ Object
37 38 39 |
# File 'lib/osctld/mount/entry.rb', line 37 def fs dataset ? dataset.private_path : @fs end |
#lxc_mountpoint ⇒ Object
41 42 43 44 45 |
# File 'lib/osctld/mount/entry.rb', line 41 def lxc_mountpoint ret = String.new(mountpoint) ret.slice!(0) while ret.start_with?('/') ret end |