vagrant-lxc-ng/lib/vagrant-lxc/action/create.rb
2014-02-02 18:03:33 -02:00

34 lines
925 B
Ruby

module Vagrant
module LXC
module Action
class Create
def initialize(app, env)
@app = app
end
def call(env)
if env[:machine].provider_config.use_machine_name
container_name = env[:machine].name.to_s
elsif env[:machine].provider_config.container_name
container_name = env[:machine].provider_config.container_name
else
container_name = "#{env[:root_path].basename}_#{env[:machine].name}"
container_name.gsub!(/[^-a-z0-9_]/i, "")
container_name << "-#{Time.now.to_i}"
end
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
end
end
end
end