Class: Lxc::OverlayMount
- Inherits:
-
Object
- Object
- Lxc::OverlayMount
- Includes:
- Helpers
- Defined in:
- lib/elecksee/storage/overlay_mount.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#overlay ⇒ Object
readonly
Returns the value of attribute overlay.
-
#overlay_type ⇒ Object
readonly
Returns the value of attribute overlay_type.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ OverlayMount
constructor
A new instance of OverlayMount.
- #mount ⇒ Object
- #mounted? ⇒ Boolean
- #unmount ⇒ Object
Methods included from Helpers
#command, #detect_home, #log, #run_command, #sudo
Constructor Details
#initialize(args = {}) ⇒ OverlayMount
Returns a new instance of OverlayMount.
13 14 15 16 17 18 19 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 13 def initialize(args={}) validate!(args) @base = args[:base] @overlay = args[:overlay] @target = args[:target] @overlay_type = args[:overlay_type] || 'overlayfs' end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
8 9 10 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 8 def base @base end |
#overlay ⇒ Object (readonly)
Returns the value of attribute overlay.
9 10 11 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 9 def @overlay end |
#overlay_type ⇒ Object (readonly)
Returns the value of attribute overlay_type.
11 12 13 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 11 def @overlay_type end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
10 11 12 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 10 def target @target end |
Instance Method Details
#mount ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 21 def mount unless(mounted?) case when 'aufs' cmd = "mount -t aufs -o br=#{}=rw:#{base}=ro,noplink none #{target}" when 'overlayfs' cmd = "mount -t overlayfs -oupperdir=#{},lowerdir=#{base} none #{target}" else raise "Invalid overlay type provided: #{}" end command(cmd, :sudo => true) true end end |
#mounted? ⇒ Boolean
36 37 38 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 36 def mounted? command("mount").stdout.include?(target) end |
#unmount ⇒ Object
40 41 42 43 44 45 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 40 def unmount if(mounted?) command("umount #{target}", :sudo => true, :allow_failure => true) true end end |