Class: TrainPlugins::WinRM::Connection
- Inherits:
-
Train::Plugins::Transport::BaseConnection
- Object
- Train::Plugins::Transport::BaseConnection
- TrainPlugins::WinRM::Connection
- Defined in:
- lib/train-winrm/connection.rb
Overview
Instance Attribute Summary collapse
-
#hostname ⇒ Object
readonly
rubocop:disable Metrics/ClassLength.
Instance Method Summary collapse
- #close ⇒ Object
- #download(remotes, local) ⇒ Object
-
#initialize(options) ⇒ Connection
constructor
A new instance of Connection.
- #login_command ⇒ Object
- #upload(locals, remote) ⇒ Object
- #uri ⇒ Object
- #wait_until_ready ⇒ Object
Constructor Details
#initialize(options) ⇒ Connection
Returns a new instance of Connection.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/train-winrm/connection.rb', line 44 def initialize() super() @hostname = @options.delete(:hostname) @rdp_port = @options.delete(:rdp_port) @connection_retries = @options.delete(:connection_retries) @connection_retry_sleep = @options.delete(:connection_retry_sleep) @max_wait_until_ready = @options.delete(:max_wait_until_ready) @operation_timeout = @options.delete(:operation_timeout) @shell_type = @options.delete(:winrm_shell_type) end |
Instance Attribute Details
#hostname ⇒ Object (readonly)
rubocop:disable Metrics/ClassLength
43 44 45 |
# File 'lib/train-winrm/connection.rb', line 43 def hostname @hostname end |
Instance Method Details
#close ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/train-winrm/connection.rb', line 56 def close return if @session.nil? session.close ensure @session = nil end |
#download(remotes, local) ⇒ Object
85 86 87 88 89 |
# File 'lib/train-winrm/connection.rb', line 85 def download(remotes, local) Array(remotes).each do |remote| file_manager.download(remote, local) end end |
#login_command ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/train-winrm/connection.rb', line 65 def login_command case RbConfig::CONFIG["host_os"] when /darwin/ login_command_for_mac when /mswin|msys|mingw|cygwin|bccwin|wince|emc/ login_command_for_windows when /linux/ login_command_for_linux else raise ActionFailed, "Remote login not supported in #{self.class} " \ "from host OS '#{RbConfig::CONFIG["host_os"]}'." end end |
#upload(locals, remote) ⇒ Object
81 82 83 |
# File 'lib/train-winrm/connection.rb', line 81 def upload(locals, remote) file_manager.upload(locals, remote) end |
#uri ⇒ Object
101 102 103 |
# File 'lib/train-winrm/connection.rb', line 101 def uri "winrm://#{[:user]}@#{[:endpoint]}:#{@rdp_port}" end |
#wait_until_ready ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/train-winrm/connection.rb', line 92 def wait_until_ready delay = 3 session( retry_limit: @max_wait_until_ready / delay, retry_delay: delay ) run_command_via_connection(PING_COMMAND.dup) end |