2013-03-03 05:24:05 +00:00
|
|
|
module Vagrant
|
|
|
|
module LXC
|
|
|
|
module Action
|
2013-04-02 00:05:19 +00:00
|
|
|
class Create
|
|
|
|
def initialize(app, env)
|
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
2013-03-03 05:24:05 +00:00
|
|
|
def call(env)
|
2013-07-22 01:46:42 +00:00
|
|
|
container_name = "#{env[:root_path].basename.to_s}_#{env[:machine].name}"
|
2013-04-05 06:10:38 +00:00
|
|
|
container_name.gsub!(/[^-a-z0-9_]/i, "")
|
|
|
|
container_name << "-#{Time.now.to_i}"
|
|
|
|
|
|
|
|
env[:machine].provider.driver.create(
|
|
|
|
container_name,
|
|
|
|
env[:lxc_template_src],
|
2013-06-06 03:04:59 +00:00
|
|
|
env[:lxc_template_config],
|
2013-04-05 06:10:38 +00:00
|
|
|
env[:lxc_template_opts]
|
|
|
|
)
|
|
|
|
|
|
|
|
env[:machine].id = container_name
|
2013-03-29 05:17:34 +00:00
|
|
|
|
2013-03-03 05:24:05 +00:00
|
|
|
@app.call env
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|