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!(
|
metadata.merge!(
|
||||||
'template-name' => "vagrant-#{box.name}-#{template_name}",
|
'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
|
'after-create-script' => after_create
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,15 @@ module Vagrant
|
||||||
public_key = Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s
|
public_key = Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s
|
||||||
|
|
||||||
# TODO: Handle errors
|
# 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
|
@name
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,8 @@ describe Vagrant::LXC::Action::HandleBoxMetadata do
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prepends box directory to tar-cache' do
|
it 'sets box directory as lxc-cache-path' do
|
||||||
metadata['tar-cache'].should == "#{box.directory.to_s}/#{tar_cache}"
|
metadata['lxc-cache-path'].should == box.directory.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prepends box directory to after-create-script' do
|
it 'prepends box directory to after-create-script' do
|
||||||
|
|
|
@ -79,12 +79,13 @@ describe Vagrant::LXC::Container do
|
||||||
let(:name) { 'random-container-name' }
|
let(:name) { 'random-container-name' }
|
||||||
let(:template_name) { 'template-name' }
|
let(:template_name) { 'template-name' }
|
||||||
let(:tar_cache_path) { '/path/to/tar/cache' }
|
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 }
|
let(:public_key_path) { Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
subject.stub(lxc: true)
|
subject.stub(lxc: true)
|
||||||
SecureRandom.stub(hex: name)
|
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
|
end
|
||||||
|
|
||||||
it 'calls lxc-create with the right arguments' do
|
it 'calls lxc-create with the right arguments' do
|
||||||
|
@ -94,6 +95,7 @@ describe Vagrant::LXC::Container do
|
||||||
'--name', name,
|
'--name', name,
|
||||||
'--',
|
'--',
|
||||||
'-S', public_key_path,
|
'-S', public_key_path,
|
||||||
|
'--cache-path', lxc_cache,
|
||||||
'-T', tar_cache_path
|
'-T', tar_cache_path
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue