Class: Vagrant::LXC::Action::Create

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-lxc/action/create.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Create

Returns a new instance of Create.



5
6
7
# File 'lib/vagrant-lxc/action/create.rb', line 5

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-lxc/action/create.rb', line 9

def call(env)
  container_name = "#{env[:root_path].basename.to_s}_#{env[:machine].name}"
  container_name.gsub!(/[^-a-z0-9_]/i, "")
  container_name << "-#{Time.now.to_i}"

  env[:machine].provider.driver.create(
    container_name,
    env[:lxc_template_src],
    env[:lxc_template_config],
    env[:lxc_template_opts]
  )

  env[:machine].id = container_name

  @app.call env
end