lib/vagrant/communication/ssh.rb in vagrantup-0.9.1 vs lib/vagrant/communication/ssh.rb in vagrantup-0.9.2
- old
+ new
@@ -69,10 +69,12 @@
opts = { :sudo => true }.merge(opts || {})
execute(command, opts, &block)
end
def upload(from, to)
+ @logger.debug("Uploading: #{from} to #{to}")
+
# Do an SCP-based upload...
connect do |connection|
scp = Net::SCP.new(connection)
scp.upload!(from, to)
end
@@ -100,11 +102,11 @@
end
# If the @connection is still around, then it is valid,
# and we use it.
if @connection
- @logger.info("Re-using SSH connection.")
+ @logger.debug("Re-using SSH connection.")
return yield @connection if block_given?
return
end
end
@@ -146,17 +148,15 @@
# own exception.
raise Errors::SSHAuthenticationFailed
rescue Errno::ECONNREFUSED
# This is raised if we failed to connect the max amount of times
raise Errors::SSHConnectionRefused
- ensure
- # Be sure the connection is always closed
- # connection.close if connection && !connection.closed?
end
# Executes the command on an SSH connection within a login shell.
def shell_execute(connection, command, sudo=false)
+ @logger.info("Execute: #{command} (sudo=#{sudo.inspect})")
exit_status = nil
# Determine the shell to execute. If we are using `sudo` then we
# need to wrap the shell in a `sudo` call.
shell = "#{@vm.config.ssh.shell} -l"
@@ -165,18 +165,29 @@
# Open the channel so we can execute or command
channel = connection.open_channel do |ch|
ch.exec(shell) do |ch2, _|
# Setup the channel callbacks so we can get data and exit status
ch2.on_data do |ch3, data|
- yield :stdout, data if block_given?
+ if block_given?
+ # Filter out the clear screen command
+ data.gsub!("\e[H", "")
+ @logger.debug("stdout: #{data}")
+ yield :stdout, data
+ end
end
ch2.on_extended_data do |ch3, type, data|
- yield :stderr, data if block_given?
+ if block_given?
+ # Filter out the clear screen command
+ data.gsub!("\e[H", "")
+ @logger.debug("stderr: #{data}")
+ yield :stderr, data
+ end
end
ch2.on_request("exit-status") do |ch3, data|
exit_status = data.read_long
+ @logger.debug("Exit status: #{exit_status}")
end
# Set the terminal
ch2.send_data "export TERM=vt100\n"