Class: TasteTester::SSH
- Inherits:
-
Object
- Object
- TasteTester::SSH
- Includes:
- BetweenMeals::Util, Logging
- Defined in:
- lib/taste_tester/ssh.rb
Overview
Thin ssh wrapper
Instance Attribute Summary collapse
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #add(string) ⇒ Object (also: #<<)
-
#initialize(host, timeout = 5, tunnel = false) ⇒ SSH
constructor
A new instance of SSH.
- #run ⇒ Object
- #run! ⇒ Object
Methods included from Logging
#formatter, formatterproc=, logger, #logger, use_log_formatter=, verbosity=
Constructor Details
#initialize(host, timeout = 5, tunnel = false) ⇒ SSH
Returns a new instance of SSH.
25 26 27 28 29 30 |
# File 'lib/taste_tester/ssh.rb', line 25 def initialize(host, timeout = 5, tunnel = false) @host = host @timeout = timeout @tunnel = tunnel @cmds = [] end |
Instance Attribute Details
#output ⇒ Object (readonly)
Returns the value of attribute output.
23 24 25 |
# File 'lib/taste_tester/ssh.rb', line 23 def output @output end |
Instance Method Details
#add(string) ⇒ Object Also known as: <<
32 33 34 |
# File 'lib/taste_tester/ssh.rb', line 32 def add(string) @cmds << string end |
#run ⇒ Object
38 39 40 |
# File 'lib/taste_tester/ssh.rb', line 38 def run @status, @output = exec(cmd, logger) end |
#run! ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/taste_tester/ssh.rb', line 42 def run! @status, @output = exec!(cmd, logger) rescue => e # rubocop:disable LineLength error = <<-MSG SSH returned error while connecting to #{TasteTester::Config.user}@#{@host} The host might be broken or your SSH access is not working properly Try doing #{TasteTester::Config.ssh_command} -v #{TasteTester::Config.user}@#{@host} and come back once that works MSG # rubocop:enable LineLength error.lines.each { |x| logger.error x.strip } logger.error(e.) exit(1) end |