Class: Lxc::Storage::OverlayMount
- Inherits:
-
Object
- Object
- Lxc::Storage::OverlayMount
- Includes:
- Helpers
- Defined in:
- lib/elecksee/storage/overlay_mount.rb
Overview
Overlay mount backed storage
Instance Attribute Summary collapse
-
#base ⇒ String
readonly
Base path to overlay.
-
#overlay ⇒ String
readonly
Path to overlay storage.
-
#overlay_type ⇒ String
readonly
Type of overlay to implement.
-
#target ⇒ String
readonly
Path to mount overlay.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ OverlayMount
constructor
Create new instance.
-
#mount ⇒ TrueClass, FalseClass
Mount the overlay.
- #mounted? ⇒ TrueClass, FalseClass
-
#unmount ⇒ TrueClass, FalseClass
Unmount the overlay.
Methods included from Helpers
#child_process_command, #detect_home, #log, #mixlib_shellout_command, #run_command, #sudo
Constructor Details
#initialize(args = {}) ⇒ OverlayMount
Note:
:overlay_type defaults to overlayfs
Create new instance
27 28 29 30 31 32 33 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 27 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 ⇒ String (readonly)
Returns base path to overlay.
11 12 13 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 11 def base @base end |
#overlay ⇒ String (readonly)
Returns path to overlay storage.
13 14 15 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 13 def @overlay end |
#overlay_type ⇒ String (readonly)
Returns type of overlay to implement.
17 18 19 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 17 def @overlay_type end |
#target ⇒ String (readonly)
Returns path to mount overlay.
15 16 17 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 15 def target @target end |
Instance Method Details
#mount ⇒ TrueClass, FalseClass
Mount the overlay
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 38 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 else false end end |
#mounted? ⇒ TrueClass, FalseClass
56 57 58 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 56 def mounted? command("mount").stdout.include?(target) end |
#unmount ⇒ TrueClass, FalseClass
Unmount the overlay
63 64 65 66 67 68 69 70 |
# File 'lib/elecksee/storage/overlay_mount.rb', line 63 def unmount if(mounted?) command("umount #{target}", :sudo => true, :allow_failure => true) true else false end end |