From 6680858184ab679c06b4e15076287b763f03d807 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Sat, 21 Sep 2013 01:32:15 -0300 Subject: [PATCH] Improve logging and add some TODOs that have been around for a while --- lib/vagrant-lxc/action.rb | 3 ++- lib/vagrant-lxc/action/clear_forwarded_ports.rb | 4 ++++ lib/vagrant-lxc/action/setup_package_files.rb | 1 + lib/vagrant-lxc/driver.rb | 3 ++- lib/vagrant-lxc/driver/cli.rb | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-lxc/action.rb b/lib/vagrant-lxc/action.rb index cd0c081..fdb486c 100644 --- a/lib/vagrant-lxc/action.rb +++ b/lib/vagrant-lxc/action.rb @@ -119,7 +119,7 @@ module Vagrant Vagrant::Action::Builder.new.tap do |b| b.use Vagrant::Action::Builtin::Call, Created do |env, b2| if env[:result] - # TODO: Remove this on / after 0.4 + # TODO: Check vagrant version and use only if lower than 1.X b2.use Disconnect b2.use ClearForwardedPorts b2.use RemoveTemporaryFiles @@ -145,6 +145,7 @@ module Vagrant next end + # TODO: Use Vagrant's built in action b2.use Vagrant::Action::Builtin::Call, DestroyConfirm do |env2, b3| if env2[:result] b3.use Vagrant::Action::Builtin::ConfigValidate diff --git a/lib/vagrant-lxc/action/clear_forwarded_ports.rb b/lib/vagrant-lxc/action/clear_forwarded_ports.rb index 8a7b339..48dbe5b 100644 --- a/lib/vagrant-lxc/action/clear_forwarded_ports.rb +++ b/lib/vagrant-lxc/action/clear_forwarded_ports.rb @@ -18,7 +18,10 @@ module Vagrant system "pkill -TERM -P #{pid}" end + @logger.info "Removing redir pids files" remove_redir_pids + else + @logger.info "No redir pids found" end @app.call env @@ -33,6 +36,7 @@ module Vagrant end def is_redir_pid?(pid) + @logger.debug "Checking if #{pid} is a redir process with `ps -o cmd= #{pid}`" `ps -o cmd= #{pid}`.strip.chomp =~ /redir/ end diff --git a/lib/vagrant-lxc/action/setup_package_files.rb b/lib/vagrant-lxc/action/setup_package_files.rb index 8743861..a770604 100644 --- a/lib/vagrant-lxc/action/setup_package_files.rb +++ b/lib/vagrant-lxc/action/setup_package_files.rb @@ -45,6 +45,7 @@ module Vagrant box_dir = @env[:machine].box.directory FileUtils.cp box_dir.join('lxc-template').to_s, @env['package.directory'].to_s FileUtils.cp box_dir.join('metadata.json').to_s, @env['package.directory'].to_s + # TODO: Update built-on metadata.json if (conf = box_dir.join('lxc.conf')).exist? FileUtils.cp conf.to_s, @env['package.directory'].to_s end diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 7fc4d0c..6ae6b58 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -151,12 +151,13 @@ module Vagrant template_name = "vagrant-tmp-#{@container_name}" tmp_template_path = templates_path.join("lxc-#{template_name}").to_s - @logger.debug 'Copying LXC template into place' + @logger.info 'Copying LXC template into place' @sudo_wrapper.run('cp', path, tmp_template_path) @sudo_wrapper.run('chmod', '+x', tmp_template_path) yield template_name ensure + @logger.info 'Removing LXC template' @sudo_wrapper.run('rm', tmp_template_path) end diff --git a/lib/vagrant-lxc/driver/cli.rb b/lib/vagrant-lxc/driver/cli.rb index bdbee19..c963ac7 100644 --- a/lib/vagrant-lxc/driver/cli.rb +++ b/lib/vagrant-lxc/driver/cli.rb @@ -99,6 +99,7 @@ module Vagrant end unless last_state == target_state + # TODO: Raise an user friendly message raise TargetStateNotReached.new target_state, last_state end end