Method: Beaker::SshConnection#close

Defined in:
lib/beaker/ssh_connection.rb

#closeObject

closes this SshConnection



124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/beaker/ssh_connection.rb', line 124

def close
  begin
    if @ssh and not @ssh.closed?
      @ssh.close
    else
      @logger.warn("ssh.close: connection is already closed, no action needed")
    end
  rescue *RETRYABLE_EXCEPTIONS => e
    @logger.warn "Attemped ssh.close, (caught #{e.class.name} - #{e.message})."
  rescue => e
    @logger.warn "ssh.close threw unexpected Error: #{e.class.name} - #{e.message}.  Shutting down, and re-raising error below"
    @ssh.shutdown!
    raise e
  ensure
    @ssh = nil
    @logger.debug("ssh connection to #{@hostname} has been terminated")
  end
end