From 14f769ee0d2254091bacf6f69b8653bebf188739 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 5 Apr 2013 02:28:25 -0300 Subject: [PATCH] Remove support for setting target rootfs path --- README.md | 2 -- development/Vagrantfile | 2 -- lib/vagrant-lxc/action/create.rb | 4 +--- lib/vagrant-lxc/config.rb | 7 ------- lib/vagrant-lxc/driver.rb | 4 ++-- lib/vagrant-lxc/driver/cli.rb | 8 ++------ spec/unit/driver/cli_spec.rb | 14 +------------- spec/unit/driver_spec.rb | 4 +--- 8 files changed, 7 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index caabfad..2129bbb 100644 --- a/README.md +++ b/README.md @@ -64,8 +64,6 @@ Vagrant.configure("2") do |config| config.vm.synced_folder "/tmp", "/host_tmp" config.vm.provider :lxc do |lxc| - # Set the folder where container's rootfs will be stored when created - lxc.target_rootfs_path = '/path/to/container/rootfs' # Same as 'customize ["modifyvm", :id, "--memory", "1024"]' for VirtualBox lxc.start_opts << 'lxc.cgroup.memory.limit_in_bytes=400M' # Limits swap size diff --git a/development/Vagrantfile b/development/Vagrantfile index 42af709..78ef71d 100644 --- a/development/Vagrantfile +++ b/development/Vagrantfile @@ -64,8 +64,6 @@ Vagrant.configure("2") do |config| lxc_config.vm.provider :lxc do |lxc| # Required to boot nested containers lxc.start_opts << 'lxc.aa_profile=unconfined' - # Change this to override the path where the rootfs gets stored - # lxc.target_rootfs_path = '/path/to/vagrant-lxc-dev-box-rootfs' end end diff --git a/lib/vagrant-lxc/action/create.rb b/lib/vagrant-lxc/action/create.rb index 941f65c..0a0ec8d 100644 --- a/lib/vagrant-lxc/action/create.rb +++ b/lib/vagrant-lxc/action/create.rb @@ -10,9 +10,7 @@ module Vagrant base_name = env[:root_path].basename.to_s base_name.gsub!(/[^-a-z0-9_]/i, "") - target_rootfs_path = env[:machine].provider_config.target_rootfs_path - - machine_id = env[:machine].provider.driver.create(base_name, target_rootfs_path, env[:machine].box.metadata) + machine_id = env[:machine].provider.driver.create(base_name, env[:machine].box.metadata) env[:machine].id = machine_id env[:just_created] = true @app.call env diff --git a/lib/vagrant-lxc/config.rb b/lib/vagrant-lxc/config.rb index 4e5edb4..ee9d2f1 100644 --- a/lib/vagrant-lxc/config.rb +++ b/lib/vagrant-lxc/config.rb @@ -6,15 +6,8 @@ module Vagrant # @return [Array] attr_reader :start_opts - # Base directory to store container's rootfs - # - # Defaults to nil, which means it will be stored wherever the lxc template - # tells it to be stored - attr_accessor :target_rootfs_path - def initialize @start_opts = [] - @target_rootfs_path = nil end end end diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 58e4102..aeee82d 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -39,7 +39,7 @@ module Vagrant Pathname.new(base_path.join('config').read.match(/^lxc\.rootfs\s+=\s+(.+)$/)[1]) end - def create(base_name, target_rootfs_path, metadata = {}) + def create(base_name, metadata = {}) @logger.debug('Creating container using lxc-create...') @name = "#{base_name}-#{SecureRandom.hex(6)}" @@ -50,7 +50,7 @@ module Vagrant ) @cli.name = @name - @cli.create(metadata.fetch('template-name'), target_rootfs_path, meta_opts) + @cli.create(metadata.fetch('template-name'), meta_opts) @name end diff --git a/lib/vagrant-lxc/driver/cli.rb b/lib/vagrant-lxc/driver/cli.rb index 519d44a..ac7a00b 100644 --- a/lib/vagrant-lxc/driver/cli.rb +++ b/lib/vagrant-lxc/driver/cli.rb @@ -31,18 +31,14 @@ module Vagrant end end - def create(template, target_rootfs_path, template_opts = {}) + def create(template, template_opts = {}) extra = template_opts.to_a.flatten extra.unshift '--' unless extra.empty? - rootfs_args = target_rootfs_path ? - ['-B', 'dir', '--dir', target_rootfs_path] : - [] - run :create, '--template', template, '--name', @name, - *(rootfs_args + extra) + *extra end def destroy diff --git a/spec/unit/driver/cli_spec.rb b/spec/unit/driver/cli_spec.rb index 35e77d5..2c364a5 100644 --- a/spec/unit/driver/cli_spec.rb +++ b/spec/unit/driver/cli_spec.rb @@ -33,12 +33,9 @@ describe Vagrant::LXC::Driver::CLI do before do subject.stub(:run) { |*args| @run_args = args } - subject.create(template, rootfs, template_args) + subject.create(template, template_args) end - context 'when no rootfs is passed' do - let(:rootfs) { nil } - it 'issues a lxc-create with provided template, container name and hash of arguments' do subject.should have_received(:run).with( :create, @@ -49,15 +46,6 @@ describe Vagrant::LXC::Driver::CLI do '--other', 'value' ) end - end - - context 'when the rootfs is passed' do - let(:rootfs) { 'rootfs_path' } - - it 'issues a lxc-create with the right rootfs arguments' do - @run_args.join(' ').should =~ /-B dir --dir #{rootfs}/ - end - end end describe 'destroy' do diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index 4f63236..30d6495 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -37,7 +37,6 @@ describe Vagrant::LXC::Driver do let(:suffix) { 'random-suffix' } let(:template_name) { 'template-name' } let(:rootfs_tarball) { '/path/to/cache/rootfs.tar.gz' } - let(:target_rootfs) { '/path/to/rootfs' } let(:public_key_path) { Vagrant.source_root.join('keys', 'vagrant.pub').expand_path.to_s } let(:cli) { fire_double('Vagrant::LXC::Driver::CLI', :create => true, :name= => true) } @@ -45,14 +44,13 @@ describe Vagrant::LXC::Driver do before do SecureRandom.stub(hex: suffix) - subject.create base_name, target_rootfs, 'template-name' => template_name, 'rootfs-tarball' => rootfs_tarball, 'template-opts' => { '--foo' => 'bar'} + subject.create base_name, 'template-name' => template_name, 'rootfs-tarball' => rootfs_tarball, 'template-opts' => { '--foo' => 'bar'} end it 'creates container with the right arguments' do cli.should have_received(:name=).with("#{base_name}-#{suffix}") cli.should have_received(:create).with( template_name, - target_rootfs, '--auth-key' => public_key_path, '--tarball' => rootfs_tarball, '--foo' => 'bar'