26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/wildcloud/keeper/isolators/lxc.rb', line 26
def start(options)
@id = options[:id]
@target_path = File.join(config['paths']['mounts'], "#{@id}")
@config_file = File.join(config['paths']['config'], "#{@id}.config")
@fstab_file = File.join(config['paths']['config'], "#{@id}.fstab")
vm_config = ERB.new(File.read(File.expand_path('../../templates/app.config', __FILE__))).result(binding)
vm_fstab = ERB.new(File.read(File.expand_path('../../templates/app.fstab', __FILE__))).result(binding)
FileUtils.mkdir_p(config['paths']['config'])
File.open(@config_file, 'w') { |file| file.write(vm_config) }
File.open(@fstab_file, 'w') { |file| file.write(vm_fstab) }
run("lxc-create -f #{@config_file} -n #{@id}")
run("lxc-start -d -n #{@id}")
end
|