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)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Entry



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

def initialize(fs, mountpoint, type, opts, automount, dataset: nil, temp: false)
  @fs = fs
  @mountpoint = mountpoint
  @type = type
  @opts = opts
  @automount = automount
  @dataset = dataset
  @temp = temp
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

#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



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

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



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

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

#fsObject



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

def fs
  dataset ? dataset.private_path : @fs
end

#lxc_mountpointObject



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

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