Fix LXC_START_LOG_FILE support

This commit is contained in:
Fabio Rehm 2013-03-12 15:29:18 -03:00
parent fa49c75eb8
commit 6dcb118f86
4 changed files with 8 additions and 10 deletions

View file

@ -94,8 +94,7 @@ if you are working on a mac or windows host ;)
## Development ## Development
If you know what you'll be doing and want to develop from your physical machine, If want to develop from your physical machine, just sing that same old song:
just sing that same old song:
``` ```
git clone git://github.com/fgrehm/vagrant-lxc.git --recurse git clone git://github.com/fgrehm/vagrant-lxc.git --recurse
@ -104,7 +103,7 @@ bundle install
bundle exec rake # to run all specs 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 bundle exec rake boxes:quantal64:build

View file

@ -44,7 +44,6 @@ module Vagrant
end end
def create(metadata = {}) def create(metadata = {})
# FIXME: Ruby 1.8 users dont have SecureRandom
@logger.debug('Creating container using lxc-create...') @logger.debug('Creating container using lxc-create...')
@name = SecureRandom.hex(6) @name = SecureRandom.hex(6)
@ -72,7 +71,6 @@ module Vagrant
end end
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" config.start_opts << "lxc.mount.entry=#{folder[:hostpath]} #{guestpath} none bind 0 0"
end end
end end
@ -82,10 +80,10 @@ module Vagrant
opts = config.start_opts.dup opts = config.start_opts.dup
if ENV['LXC_START_LOG_FILE'] 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 end
@cli.transition_to(:running) { |c| c.start(opts) } @cli.transition_to(:running) { |c| c.start(opts, (extra || nil)) }
end end
def halt def halt

View file

@ -46,8 +46,9 @@ module Vagrant
run :destroy, '--name', @name run :destroy, '--name', @name
end end
def start(configs = []) def start(configs = [], extra_opts = [])
configs = configs.map { |conf| ["-s", conf] }.flatten configs = configs.map { |conf| ["-s", conf] }.flatten
configs += extra_opts if extra_opts
run :start, '-d', '--name', @name, *configs run :start, '-d', '--name', @name, *configs
end end

View file

@ -70,7 +70,7 @@ describe Vagrant::LXC::Container do
end end
describe 'start' do 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(:name) { 'container-name' }
let(:cli) { fire_double('Vagrant::LXC::Container::CLI', start: true) } let(:cli) { fire_double('Vagrant::LXC::Container::CLI', start: true) }
@ -81,7 +81,7 @@ describe Vagrant::LXC::Container do
end end
it 'starts container with configured lxc settings' do 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) subject.start(config)
end end