Class: IFD_Ssh
- Inherits:
-
Object
- Object
- IFD_Ssh
- Defined in:
- lib/helper/ssh_helper.rb
Class Method Summary collapse
- .connect_to_server_with_credential(host_name, table) ⇒ Object
- .exec_command(command) ⇒ Object
- .print_output ⇒ Object
- .store_result_string(name) ⇒ Object
- .verify_output(string) ⇒ Object
Class Method Details
.connect_to_server_with_credential(host_name, table) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/helper/ssh_helper.rb', line 4 def self.connect_to_server_with_credential(host_name,table) hostname = Utils.check_dynamic_value host_name @keys = [] @auth_methods ||= %w(password) session = table.hashes.first session_keys = Array.new(@keys) session_auth_methods = Array.new(@auth_methods) if session["keyfile"] session_keys << session["keyfile"] session_auth_methods << "publickey" end @SSHconnection = Net::SSH.start(hostname, session["username"], :password => session["password"], :auth_methods => session_auth_methods, :keys => session_keys) end |
.exec_command(command) ⇒ Object
21 22 23 24 |
# File 'lib/helper/ssh_helper.rb', line 21 def self.exec_command(command) command = Utils.check_dynamic_value command @output = @SSHconnection.exec!(command) end |
.print_output ⇒ Object
26 27 28 |
# File 'lib/helper/ssh_helper.rb', line 26 def self.print_output p @output end |
.store_result_string(name) ⇒ Object
35 36 37 38 |
# File 'lib/helper/ssh_helper.rb', line 35 def self.store_result_string(name) $context_value = Utils.bind_with_dyn_vars(@output) Utils.set_var(name, '$context_value') end |
.verify_output(string) ⇒ Object
30 31 32 33 |
# File 'lib/helper/ssh_helper.rb', line 30 def self.verify_output(string) string = Utils.check_dynamic_value(string) IFD_Assertion.assert_string_equal(string, @output.strip) end |