Class: Datacenter::Shell::Remote
- Inherits:
-
Object
- Object
- Datacenter::Shell::Remote
- Defined in:
- lib/datacenter/shell.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(*args) ⇒ Remote
constructor
A new instance of Remote.
- #open ⇒ Object
- #run(command) ⇒ Object
Constructor Details
#initialize(*args) ⇒ Remote
Returns a new instance of Remote.
40 41 42 |
# File 'lib/datacenter/shell.rb', line 40 def initialize(*args) = args end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
38 39 40 |
# File 'lib/datacenter/shell.rb', line 38 def end |
Class Method Details
.open(*args, &block) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/datacenter/shell.rb', line 63 def self.open(*args, &block) shell = new *args shell.open block.call shell shell.close end |
Instance Method Details
#close ⇒ Object
56 57 58 59 60 61 |
# File 'lib/datacenter/shell.rb', line 56 def close if @session @session.close @session = nil end end |
#open ⇒ Object
52 53 54 |
# File 'lib/datacenter/shell.rb', line 52 def open @session = Net::SSH.start * unless @session end |
#run(command) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/datacenter/shell.rb', line 44 def run(command) if @session @session.exec!(command).strip else Net::SSH.start(*) { |ssh| ssh.exec! command }.to_s.strip end end |