Class: Distem::Node::FileSystemForge

Inherits:
Forge
  • Object
show all
Defined in:
lib/distem/node/filesystemforge.rb

Overview

Allows to modify filesystem physical resources to fit with the virtual resources specifications

Constant Summary

PATH_DEFAULT_CONFIGFILE =

The directory to save container configuration files

"/tmp/distem/config/"
PATH_DEFAULT_ROOTFS_UNIQUE =

The directory used to save virtual nodes unique filesystem directories&files

"/tmp/distem/rootfs-unique/"
PATH_DEFAULT_ROOTFS_SHARED =

The directory used to save virtual nodes unique filesystem directories&files

"/tmp/distem/rootfs-shared/"

Instance Attribute Summary

Attributes inherited from Forge

#algorithm, #resource

Instance Method Summary (collapse)

Methods inherited from Forge

#undo

Constructor Details

- (FileSystemForge) initialize(vnode)

Create a new FileSystemForge specifying the virtual node resource to modify

Attributes

  • vnode The VNode object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/distem/node/filesystemforge.rb', line 20

def initialize(vnode)
  super(vnode.filesystem,nil)

  unless File.exist?(PATH_DEFAULT_CONFIGFILE)
    Lib::Shell.run("mkdir -p #{PATH_DEFAULT_CONFIGFILE}")
  end

  rootfsfile = Lib::FileManager.download(@resource.image)
  uniquefspath = File.join(PATH_DEFAULT_ROOTFS_UNIQUE,@resource.vnode.name)

  block = Proc.new { |filepath,mode|
    Lib::Shell.run("rm -Rf #{filepath}") if File.exist?(filepath)
    Lib::Shell.run("mkdir #{(mode ? "-m #{mode}" : '')} -p #{filepath}")
  }

  block.call(File.join(uniquefspath,'proc'),755)
  block.call(File.join(uniquefspath,'sys'),755)
  block.call(File.join(uniquefspath,'dev','pts'),744)
  # Not necessary at the moment
  #block.call(File.join(uniquefspath,'dev','shm'),1777)
  #block.call(File.join(uniquefspath,'home','my'),755)

  if @resource.shared
    sharedfspath = File.join(PATH_DEFAULT_ROOTFS_SHARED,
      Lib::FileManager.file_hash(rootfsfile))
    sharedfspath = Lib::FileManager.extract(rootfsfile,sharedfspath,false,false)
    raise InvalidResourceError 'rootfs_image' unless sharedfspath

    @resource.sharedpath = sharedfspath
    @resource.path = uniquefspath
  else
    uniquefspath = Lib::FileManager.extract(rootfsfile,uniquefspath,true,vnode.filesystem.cow)
    raise InvalidResourceError 'rootfs_image' unless uniquefspath
    @resource.path = uniquefspath
  end
end

Instance Method Details

- (Object) apply

:nodoc:



57
58
# File 'lib/distem/node/filesystemforge.rb', line 57

def apply() # :nodoc:
end