diff --git a/lib/vagrant-lxc/container.rb b/lib/vagrant-lxc/container.rb index 0806849..f292f90 100644 --- a/lib/vagrant-lxc/container.rb +++ b/lib/vagrant-lxc/container.rb @@ -42,7 +42,8 @@ module Vagrant end def halt - update!(:poweroff) + lxc :shutdown, '--name', @name + wait_until :stopped end def destroy diff --git a/spec/unit/container_spec.rb b/spec/unit/container_spec.rb index 954e462..86c1dbc 100644 --- a/spec/unit/container_spec.rb +++ b/spec/unit/container_spec.rb @@ -117,6 +117,26 @@ describe Vagrant::LXC::Container do end end + describe 'halt' do + let(:name) { 'random-container-name' } + + before do + subject.stub(lxc: true, wait_until: true) + subject.halt + end + + it 'calls lxc-shutdown with the right arguments' do + subject.should have_received(:lxc).with( + :shutdown, + '--name', name + ) + end + + it 'waits for container state to be STOPPED' do + subject.should have_received(:wait_until).with(:stopped) + end + end + describe 'state' do let(:name) { 'random-container-name' }