Class: WinRM::Shells::Base
- Inherits:
-
Object
- Object
- WinRM::Shells::Base
- Includes:
- Retryable
- Defined in:
- lib/winrm/shells/base.rb
Overview
Base class for remote shell
Direct Known Subclasses
Constant Summary collapse
- TOO_MANY_COMMANDS =
'2150859174'.freeze
- ERROR_OPERATION_ABORTED =
'995'.freeze
- FAULTS_FOR_RESET =
[ '2150858843', # Shell has been closed '2147943418', # Error reading registry key TOO_MANY_COMMANDS, # Maximum commands per user exceeded ].freeze
Constants included from Retryable
Retryable::RETRYABLE_EXCEPTIONS
Instance Attribute Summary collapse
-
#connection_opts ⇒ ConnectionOpts
readonly
Connection options of the shell.
-
#logger ⇒ Logger
readonly
Logger used for diagnostic messages.
-
#shell_id ⇒ String
readonly
Shell id of the currently opn shell or nil if shell is closed.
-
#shell_opts ⇒ Hash
readonly
Options targeted for the created shell.
-
#shell_uri ⇒ String
readonly
Uri that SOAP calls use to identify shell type.
-
#transport ⇒ WinRM::HTTP::HttpTransport
readonly
Transport used to talk with endpoint.
Instance Method Summary collapse
-
#close ⇒ Object
Closes the shell if one is open.
-
#initialize(connection_opts, transport, logger, shell_opts = {}) ⇒ Base
constructor
Create a new Cmd shell.
-
#run(command, arguments = [], &block) {|standard, standard| ... } ⇒ Object
Runs the specified command with optional arguments.
Methods included from Retryable
Constructor Details
#initialize(connection_opts, transport, logger, shell_opts = {}) ⇒ Base
Create a new Cmd shell
47 48 49 50 51 52 |
# File 'lib/winrm/shells/base.rb', line 47 def initialize(connection_opts, transport, logger, shell_opts = {}) @connection_opts = connection_opts @transport = transport @logger = logger @shell_opts = shell_opts end |
Instance Attribute Details
#connection_opts ⇒ ConnectionOpts (readonly)
Returns connection options of the shell.
61 62 63 |
# File 'lib/winrm/shells/base.rb', line 61 def connection_opts @connection_opts end |
#logger ⇒ Logger (readonly)
Returns logger used for diagnostic messages.
67 68 69 |
# File 'lib/winrm/shells/base.rb', line 67 def logger @logger end |
#shell_id ⇒ String (readonly)
Returns shell id of the currently opn shell or nil if shell is closed.
55 56 57 |
# File 'lib/winrm/shells/base.rb', line 55 def shell_id @shell_id end |
#shell_opts ⇒ Hash (readonly)
Returns Options targeted for the created shell.
70 71 72 |
# File 'lib/winrm/shells/base.rb', line 70 def shell_opts @shell_opts end |
#shell_uri ⇒ String (readonly)
Returns uri that SOAP calls use to identify shell type.
58 59 60 |
# File 'lib/winrm/shells/base.rb', line 58 def shell_uri @shell_uri end |
#transport ⇒ WinRM::HTTP::HttpTransport (readonly)
Returns transport used to talk with endpoint.
64 65 66 |
# File 'lib/winrm/shells/base.rb', line 64 def transport @transport end |
Instance Method Details
#close ⇒ Object
Closes the shell if one is open
86 87 88 89 90 91 |
# File 'lib/winrm/shells/base.rb', line 86 def close return unless shell_id self.class.close_shell(connection_opts, transport, shell_id) remove_finalizer @shell_id = nil end |
#run(command, arguments = [], &block) {|standard, standard| ... } ⇒ Object
Runs the specified command with optional arguments
79 80 81 82 83 |
# File 'lib/winrm/shells/base.rb', line 79 def run(command, arguments = [], &block) with_command_shell(command, arguments) do |shell, cmd| response_reader.read_output((shell, cmd), &block) end end |