From 0515d9a61eee7aaeeb29b8c21881c44de6249efd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 10 Jul 2011 21:41:52 -0700 Subject: [PATCH] Add more logging but default to it off for now until we add more later --- lib/vagrant/environment.rb | 2 +- lib/vagrant/ssh.rb | 13 ++++++++++--- lib/vagrant/vm.rb | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 2e4b6cc4e..042a95d17 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -303,7 +303,7 @@ module Vagrant elsif ENV["VAGRANT_LOG"] output = ENV["VAGRANT_LOG"] else - output = log_path.join("#{Time.now.to_i}.log") + output = nil #log_path.join("#{Time.now.to_i}.log") end # Create the logger and custom formatter diff --git a/lib/vagrant/ssh.rb b/lib/vagrant/ssh.rb index b12d03afc..c55236c09 100644 --- a/lib/vagrant/ssh.rb +++ b/lib/vagrant/ssh.rb @@ -57,6 +57,7 @@ module Vagrant # (GH-51). As a workaround, we fork and wait. On all other platforms, # we simply exec. command = "ssh #{command_options.join(" ")} #{options[:username]}@#{options[:host]}".strip + env.logger.info("ssh") { "Invoking SSH: #{command}" } safe_exec(command) end @@ -76,6 +77,8 @@ module Vagrant session, options = @current_session if !session || options != opts + env.logger.info("ssh") { "Connecting to SSH: #{env.config.ssh.host} #{opts[:port]}" } + # The exceptions which are acceptable to retry on during # attempts to connect to SSH exceptions = [Errno::ECONNREFUSED, Net::SSH::Disconnect] @@ -94,6 +97,8 @@ module Vagrant # Save the new session along with the options which created it @current_session = [session, opts] + else + env.logger.info("ssh") { "Using cached SSH session: #{session}" } end # Yield our session for executing @@ -143,11 +148,14 @@ module Vagrant # Windows systems don't have this issue return if Util::Platform.windows? + env.logger.info("ssh") { "Checking key permissions: #{key_path}" } + stat = File.stat(key_path) if stat.owned? && file_perms(key_path) != "600" - File.chmod(0600, key_path) + env.logger.info("ssh") { "Attempting to correct key permissions to 0600" } + File.chmod(0600, key_path) raise Errors::SSHKeyBadPermissions, :key_path => key_path if file_perms(key_path) != "600" end rescue Errno::EPERM @@ -168,8 +176,7 @@ module Vagrant # `config.ssh.forwarded_port_key`. def port(opts={}) # Check if port was specified in options hash - pnum = opts[:port] - return pnum if pnum + return opts[:port] if opts[:port] # Check if a port was specified in the config return env.config.ssh.port if env.config.ssh.port diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index 5002ede19..879ccf953 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -51,6 +51,7 @@ module Vagrant # **This method should never be called manually.** def load_system!(system=nil) system ||= env.config.vm.system + env.logger.info("vm: #{name}") { "Loading system: #{system}" } if system.is_a?(Class) raise Errors::VMSystemError, :_key => :invalid_class, :system => system.to_s if !(system <= Systems::Base)