Provide --cache-path to lxc templates on creation
This commit is contained in:
parent
7e6781cd02
commit
274f7c7b8a
4 changed files with 15 additions and 5 deletions
|
@ -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
|
||||
)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue