Sha256: 66816d929252dd799dcd7224b12c7c254ba427e74db39cde25348814d5859270

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

require 'elecksee/helpers/base'

class Lxc
  class OverlayDirectory
    
    attr_reader :name
    attr_reader :tmp_dir

    include Helpers
    
    def initialize(name, args={})
      @name = name
      @tmp_dir = args[:tmp_dir] || '/tmp/lxc/ephemerals'
      create
    end

    def overlay_path
      File.join(tmp_dir, 'virt-overlays', name)
    end
    alias_method :target_path, :overlay_path

    def create
      unless(File.directory?(overlay_path))
        FileUtils.mkdir_p(overlay_path)
      end
    end

    def destroy
      if(File.directory?(overlay_path))
        command("rm -rf #{overlay_path}", :sudo => true)
      end
    end
    
  end

  # Clone directory does the same as the overlay, just in
  # a persistent place
  class CloneDirectory < OverlayDirectory
    def initialize(name, args={})
      args[:tmp_dir] = args[:dir] if args[:dir]
      args[:tmp_dir] || '/var/lib/lxc'
      super
    end

    def overlay_path
      File.join(tmp_dir, name)
    end
    alias_method :target_path, :overlay_path
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
elecksee-1.0.22 lib/elecksee/storage/overlay_directory.rb
elecksee-1.0.20 lib/elecksee/storage/overlay_directory.rb
elecksee-1.0.18 lib/elecksee/storage/overlay_directory.rb
elecksee-1.0.16 lib/elecksee/storage/overlay_directory.rb
elecksee-1.0.14 lib/elecksee/storage/overlay_directory.rb
elecksee-1.0.12 lib/elecksee/storage/overlay_directory.rb
elecksee-1.0.10 lib/elecksee/storage/overlay_directory.rb