From 96b8c4985905b1673e2c920301c8764dae093f07 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Thu, 14 May 2015 12:43:47 +0200 Subject: [PATCH] do not copy the lxc template instead use the full path --- lib/vagrant-lxc/driver.rb | 41 +++------------------------------------ spec/unit/driver_spec.rb | 2 +- 2 files changed, 4 insertions(+), 39 deletions(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 9fe09932..a7d960fb 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -79,10 +79,8 @@ def config_string def create(name, backingstore, backingstore_options, 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, backingstore, backingstore_options, config_file, template_options - end + @logger.debug "Creating container..." + @cli.create template_path, backingstore, backingstore_options, config_file, template_options end def share_folders(folders) @@ -92,7 +90,7 @@ def share_folders(folders) end def share_folder(host_path, guest_path, mount_options = nil) - guest_path = guest_path.gsub(/^\//, '').gsub(' ', '\\\040') + guest_path = guest_path.gsub(/^\//, '').gsub(' ', '\\\040') mount_options = Array(mount_options || ['bind', 'create=dir']) host_path = host_path.to_s.gsub(' ', '\\\040') @customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"] @@ -239,39 +237,6 @@ def write_config(contents) @sudo_wrapper.run 'chown', 'root:root', base_path.join('config').to_s end end - - def import_template(path) - template_name = "vagrant-tmp-#{@container_name}" - tmp_template_path = templates_path.join("lxc-#{template_name}").to_s - - @logger.info 'Copying LXC template into place' - @sudo_wrapper.run('cp', path, tmp_template_path) - @sudo_wrapper.run('chmod', '+x', tmp_template_path) - - yield template_name - ensure - @logger.info 'Removing LXC template' - if tmp_template_path - @sudo_wrapper.run('rm', tmp_template_path) - end - end - - TEMPLATES_PATH_LOOKUP = %w( - /usr/share/lxc/templates - /usr/lib/lxc/templates - /usr/lib64/lxc/templates - /usr/local/lib/lxc/templates - ) - def templates_path - return @templates_path if @templates_path - - path = TEMPLATES_PATH_LOOKUP.find { |candidate| File.directory?(candidate) } - if !path - raise Errors::TemplatesDirMissing.new paths: TEMPLATES_PATH_LOOKUP.inspect - end - - @templates_path = Pathname(path) - end end end end diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index 0aed4b5d..571c2bf9 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -54,7 +54,7 @@ it 'creates container with the right arguments' do expect(cli).to have_received(:create).with( - template_name, + template_path, backingstore, backingstore_opts, config_file,