From 6dcb118f866d5b4ff9ee0d5a46c7a3ae5655a242 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Tue, 12 Mar 2013 15:29:18 -0300 Subject: [PATCH] Fix LXC_START_LOG_FILE support --- README.md | 5 ++--- lib/vagrant-lxc/container.rb | 6 ++---- lib/vagrant-lxc/container/cli.rb | 3 ++- spec/unit/container_spec.rb | 4 ++-- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 94edafc..95ddb0f 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,7 @@ if you are working on a mac or windows host ;) ## Development -If you know what you'll be doing and want to develop from your physical machine, -just sing that same old song: +If want to develop from your physical machine, just sing that same old song: ``` git clone git://github.com/fgrehm/vagrant-lxc.git --recurse @@ -104,7 +103,7 @@ bundle install bundle exec rake # to run all specs ``` -To rebuild and add the provided quantal64 box: +To build the provided quantal64 box: ``` bundle exec rake boxes:quantal64:build diff --git a/lib/vagrant-lxc/container.rb b/lib/vagrant-lxc/container.rb index 036b951..45976f5 100644 --- a/lib/vagrant-lxc/container.rb +++ b/lib/vagrant-lxc/container.rb @@ -44,7 +44,6 @@ module Vagrant end def create(metadata = {}) - # FIXME: Ruby 1.8 users dont have SecureRandom @logger.debug('Creating container using lxc-create...') @name = SecureRandom.hex(6) @@ -72,7 +71,6 @@ module Vagrant end end - # http://blog.smartlogicsolutions.com/2009/06/04/mount-options-to-improve-ext4-file-system-performance/ config.start_opts << "lxc.mount.entry=#{folder[:hostpath]} #{guestpath} none bind 0 0" end end @@ -82,10 +80,10 @@ module Vagrant opts = config.start_opts.dup if ENV['LXC_START_LOG_FILE'] - opts.merge!('-o' => ENV['LXC_START_LOG_FILE'], '-l' => 'DEBUG') + extra = ['-o', ENV['LXC_START_LOG_FILE'], '-l', 'DEBUG'] end - @cli.transition_to(:running) { |c| c.start(opts) } + @cli.transition_to(:running) { |c| c.start(opts, (extra || nil)) } end def halt diff --git a/lib/vagrant-lxc/container/cli.rb b/lib/vagrant-lxc/container/cli.rb index 2939233..5dd1c5a 100644 --- a/lib/vagrant-lxc/container/cli.rb +++ b/lib/vagrant-lxc/container/cli.rb @@ -46,8 +46,9 @@ module Vagrant run :destroy, '--name', @name end - def start(configs = []) + def start(configs = [], extra_opts = []) configs = configs.map { |conf| ["-s", conf] }.flatten + configs += extra_opts if extra_opts run :start, '-d', '--name', @name, *configs end diff --git a/spec/unit/container_spec.rb b/spec/unit/container_spec.rb index 471c613..1399dfc 100644 --- a/spec/unit/container_spec.rb +++ b/spec/unit/container_spec.rb @@ -70,7 +70,7 @@ describe Vagrant::LXC::Container do end describe 'start' do - let(:config) { mock(:config, start_opts: {'a' => '1', 'b' => '2'}) } + let(:config) { mock(:config, start_opts: ['a=1', 'b=2']) } let(:name) { 'container-name' } let(:cli) { fire_double('Vagrant::LXC::Container::CLI', start: true) } @@ -81,7 +81,7 @@ describe Vagrant::LXC::Container do end it 'starts container with configured lxc settings' do - cli.should_receive(:start).with('a' => '1', 'b' => '2') + cli.should_receive(:start).with(['a=1', 'b=2'], nil) subject.start(config) end