Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Fix lxc-info state regex for recent lxc versions #217

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/vagrant-lxc/driver/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def version
end

def state
if @name && run(:info, '--name', @name, retryable: true) =~ /^state:[^A-Z]+([A-Z]+)$/
if @name && run(:info, '--name', @name, retryable: true) =~ /^[sS]tate:\s*[^A-Z]+([A-Z]+)$/
$1.downcase.to_sym
elsif @name
:unknown
Expand Down
18 changes: 18 additions & 0 deletions spec/unit/driver/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,24 @@
end
end

describe 'state-new' do
let(:name) { 'a-container' }
subject { described_class.new(sudo_wrapper, name) }

before do
subject.stub(:run).and_return("State: RUNNING\nPID: 2")
end

it 'calls lxc-info with the right arguments' do
subject.state
subject.should have_received(:run).with(:info, '--name', name, retryable: true)
end

it 'maps the output of lxc-info status out to a symbol' do
subject.state.should == :running
end
end

describe 'attach' do
let(:name) { 'a-running-container' }
let(:command) { ['ls', 'cat /tmp/file'] }
Expand Down