Class: Bifrossht::Connection::Exec
- Defined in:
- lib/bifrossht/connection/exec.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#initialize, #match, #name, #skip_probe
Constructor Details
This class inherits a constructor from Bifrossht::Connection::Base
Instance Method Details
#connect(target) ⇒ Object
27 28 29 30 31 |
# File 'lib/bifrossht/connection/exec.rb', line 27 def connect(target) cmd = command(target) Logger.debug("executing: #{cmd}") exec cmd end |
#probe(target) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bifrossht/connection/exec.rb', line 4 def probe(target) cmd = command(target) Logger.debug("probing command: #{cmd}") in_r, in_w = IO.pipe io = IO.popen(['sh', '-c', cmd, in: in_w, err: '/dev/null']) in_w.close ready = IO.select([io], nil, nil, timeout) if ready = io.readline else Logger.debug('probe timed out!') end Process.kill('TERM', io.pid) in_r.close io.close return true if =~ /^SSH-/ false rescue EOFError false end |