Check-in some TODOs and REFACTORs that have been around for a while
This commit is contained in:
parent
65d986c436
commit
35f2c6eaf5
3 changed files with 11 additions and 1 deletions
3
Gemfile
3
Gemfile
|
@ -2,7 +2,10 @@ source 'https://rubygems.org'
|
||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
|
# TODO: Group gems
|
||||||
|
|
||||||
gem 'rake'
|
gem 'rake'
|
||||||
|
# TODO: setup rake-notes
|
||||||
gem 'net-ssh'
|
gem 'net-ssh'
|
||||||
gem 'rspec'
|
gem 'rspec'
|
||||||
gem 'rspec-fire', require: 'rspec/fire'
|
gem 'rspec-fire', require: 'rspec/fire'
|
||||||
|
|
|
@ -122,9 +122,11 @@ module Vagrant
|
||||||
b.use CheckLXC
|
b.use CheckLXC
|
||||||
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
|
b.use Vagrant::Action::Builtin::Call, Created do |env, b2|
|
||||||
if env[:result]
|
if env[:result]
|
||||||
# TODO: If could not gracefully halt, force it
|
|
||||||
b2.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :stopped, :running do |env2, b3|
|
b2.use Vagrant::Action::Builtin::Call, Vagrant::Action::Builtin::GracefulHalt, :stopped, :running do |env2, b3|
|
||||||
if !env2[:result] && env2[:machine].provider.state.running?
|
if !env2[:result] && env2[:machine].provider.state.running?
|
||||||
|
# TODO: Container#halt is kinda graceful as well, if it doesn't
|
||||||
|
# or we can issue a lxc-stop. Might as well be handled by the
|
||||||
|
# container itself, who knows, we just need to handle it :P
|
||||||
env2[:machine].provider.container.halt
|
env2[:machine].provider.container.halt
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ require "vagrant-lxc/errors"
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module LXC
|
module LXC
|
||||||
|
# REFACTOR: Encapsulate lxc commands with name
|
||||||
class Container
|
class Container
|
||||||
# Include this so we can use `Subprocess` more easily.
|
# Include this so we can use `Subprocess` more easily.
|
||||||
include Vagrant::Util::Retryable
|
include Vagrant::Util::Retryable
|
||||||
|
@ -96,12 +97,16 @@ module Vagrant
|
||||||
def halt
|
def halt
|
||||||
lxc :shutdown, '--name', @name
|
lxc :shutdown, '--name', @name
|
||||||
wait_until :stopped
|
wait_until :stopped
|
||||||
|
# TODO: issue an lxc-stop if a timeout gets reached
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
lxc :destroy, '--name', @name
|
lxc :destroy, '--name', @name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# REFACTOR:
|
||||||
|
# transition_to :state do
|
||||||
|
# ... code ...
|
||||||
def wait_until(state)
|
def wait_until(state)
|
||||||
lxc :wait, '--name', @name, '--state', state.to_s.upcase
|
lxc :wait, '--name', @name, '--state', state.to_s.upcase
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue