Support bundling lxc config files with base boxes

This commit is contained in:
Fabio Rehm 2013-06-06 00:04:59 -03:00
parent 75a2d0c65d
commit 5c2973108b
4 changed files with 17 additions and 3 deletions

View file

@ -14,6 +14,7 @@ module Vagrant
env[:machine].provider.driver.create(
container_name,
env[:lxc_template_src],
env[:lxc_template_config],
env[:lxc_template_opts]
)

View file

@ -22,6 +22,10 @@ module Vagrant
@env[:lxc_template_opts] = template_opts
@env[:lxc_template_src] = template_src
if template_config_file.exist?
@env[:lxc_template_config] = template_config_file.to_s
end
@app.call env
end
@ -29,6 +33,10 @@ module Vagrant
@template_src ||= @box.directory.join('lxc-template').to_s
end
def template_config_file
@template_config_file ||= @box.directory.join('lxc.conf')
end
def template_opts
@template_opts ||= @box.metadata.fetch('template-opts', {}).dup.merge!(
'--tarball' => rootfs_tarball,

View file

@ -33,12 +33,12 @@ module Vagrant
Pathname.new(base_path.join('rootfs'))
end
def create(name, template_path, template_options = {})
def create(name, template_path, config_file, template_options = {})
@cli.name = @container_name = name
import_template(template_path) do |template_name|
@logger.debug "Creating container..."
@cli.create template_name, template_options
@cli.create template_name, config_file, template_options
end
end

View file

@ -46,13 +46,18 @@ module Vagrant
end
end
def create(template, template_opts = {})
def create(template, config_file, template_opts = {})
if config_file
config_opts = ['-f', config_file]
end
extra = template_opts.to_a.flatten
extra.unshift '--' unless extra.empty?
run :create,
'--template', template,
'--name', @name,
*(config_opts),
*extra
end