Class: OsCtld::Mount::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/mount/entry.rb

Constant Summary collapse

PARAMS =
%i[fs mountpoint type opts automount dataset temp].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fs, mountpoint, type, opts, automount, dataset: nil, temp: false, in_config: false) ⇒ Entry

Returns a new instance of Entry.



22
23
24
25
26
27
28
29
30
31
# File 'lib/osctld/mount/entry.rb', line 22

def initialize(fs, mountpoint, type, opts, automount, dataset: nil, temp: false, in_config: false)
  @fs = fs
  @mountpoint = mountpoint
  @type = type
  @opts = opts
  @automount = automount
  @dataset = dataset
  @temp = temp
  @in_config = in_config
end

Instance Attribute Details

#automountObject (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

#datasetObject (readonly)

Returns the value of attribute dataset.



4
5
6
# File 'lib/osctld/mount/entry.rb', line 4

def dataset
  @dataset
end

#in_configObject (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

#mountpointObject (readonly)

Returns the value of attribute mountpoint.



4
5
6
# File 'lib/osctld/mount/entry.rb', line 4

def mountpoint
  @mountpoint
end

#optsObject (readonly)

Returns the value of attribute opts.



4
5
6
# File 'lib/osctld/mount/entry.rb', line 4

def opts
  @opts
end

#tempObject (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

#typeObject (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
# File 'lib/osctld/mount/entry.rb', line 7

def self.load(ct, cfg)
  new(
    cfg['fs'],
    cfg['mountpoint'],
    cfg['type'],
    cfg['opts'],
    cfg['automount'],
    dataset: cfg['dataset'] && OsCtl::Lib::Zfs::Dataset.new(
      File.join(ct.dataset.name, cfg['dataset']),
      base: ct.dataset.name
    ),
    temp: cfg['temporary']
  )
end

Instance Method Details

#dumpObject

Dump to config



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/osctld/mount/entry.rb', line 57

def dump
  {
    'fs' => dataset ? nil : fs,
    'mountpoint' => mountpoint,
    'type' => type,
    'opts' => opts,
    'automount' => automount,
    'dataset' => dataset && dataset.relative_name,
    'temporary' => temp
  }
end

#exportObject

Export to client



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/osctld/mount/entry.rb', line 44

def export
  {
    fs:,
    mountpoint:,
    type:,
    opts:,
    automount:,
    dataset: dataset && dataset.relative_name,
    temporary: temp
  }
end

#fsObject



33
34
35
# File 'lib/osctld/mount/entry.rb', line 33

def fs
  dataset ? dataset.private_path : @fs
end

#lxc_mountpointObject



37
38
39
40
41
# File 'lib/osctld/mount/entry.rb', line 37

def lxc_mountpoint
  ret = String.new(mountpoint)
  ret.slice!(0) while ret.start_with?('/')
  ret
end