Provide --cache-path to lxc templates on creation

This commit is contained in:
Fabio Rehm 2013-03-02 23:12:26 -03:00
parent 7e6781cd02
commit 274f7c7b8a
4 changed files with 15 additions and 5 deletions

View file

@ -23,7 +23,7 @@ module Vagrant
metadata.merge!(
'template-name' => "vagrant-#{box.name}-#{template_name}",
'tar-cache' => box.directory.join(metadata['tar-cache']).to_s,
'lxc-cache-path' => box.directory.to_s,
'after-create-script' => after_create
)

View file

@ -37,7 +37,15 @@ module Vagrant
public_key = Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s
# TODO: Handle errors
lxc :create, '--template', metadata['template-name'], '--name', @name, '--', '-S', public_key, '-T', metadata['tar-cache']
lxc :create,
# lxc-create options
'--template', metadata['template-name'],
'--name', @name,
'--',
# Template options
'-S', public_key,
'--cache-path', metadata['lxc-cache-path'],
'-T', metadata['tar-cache']
@name
end

View file

@ -19,8 +19,8 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do
subject.call(env)
end
it 'prepends box directory to tar-cache' do
metadata['tar-cache'].should == "#{box.directory.to_s}/#{tar_cache}"
it 'sets box directory as lxc-cache-path' do
metadata['lxc-cache-path'].should == box.directory.to_s
end
it 'prepends box directory to after-create-script' do

View file

@ -79,12 +79,13 @@ describe Vagrant::LXC::Container do
let(:name) { 'random-container-name' }
let(:template_name) { 'template-name' }
let(:tar_cache_path) { '/path/to/tar/cache' }
let(:lxc_cache) { '/path/to/cache' }
let(:public_key_path) { Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s }
before do
subject.stub(lxc: true)
SecureRandom.stub(hex: name)
subject.create 'template-name' => template_name, 'tar-cache' => tar_cache_path
subject.create 'template-name' => template_name, 'tar-cache' => tar_cache_path, 'lxc-cache-path' => lxc_cache
end
it 'calls lxc-create with the right arguments' do
@ -94,6 +95,7 @@ describe Vagrant::LXC::Container do
'--name', name,
'--',
'-S', public_key_path,
'--cache-path', lxc_cache,
'-T', tar_cache_path
)
end