winrm 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/changelog.md +3 -0
- data/lib/winrm/exceptions.rb +0 -9
- data/lib/winrm/shells/base.rb +12 -14
- data/lib/winrm/shells/retryable.rb +10 -1
- data/lib/winrm/version.rb +1 -1
- data/tests/spec/shells/base_spec.rb +2 -2
- metadata +2 -3
- data/lib/winrm/shells/suppressible.rb +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46a0806843f652f3d0b8d8858eb87cf0365d8e4d
|
4
|
+
data.tar.gz: 76f409feeda643970222972be8c571e2905a6fb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd17e956aa071c63ab65c0a9db69bada2a256b735ee4c9e2b63b32a16920357749bc814b32b15dd3ad61e777d77144fa73eea1e851c23347e0486ded69ffd47b
|
7
|
+
data.tar.gz: 119346b0543a18a8715f90b2c318df0bf98cbdeeae16d8afd7ffd70f73c6690b620e8c94d541e4a0798dc490c395f5e4feee7d12c8e83fddf64970560781602d
|
data/changelog.md
CHANGED
data/lib/winrm/exceptions.rb
CHANGED
@@ -15,15 +15,6 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
module WinRM
|
18
|
-
NETWORK_EXCEPTIONS = lambda do
|
19
|
-
[
|
20
|
-
Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED, Errno::ETIMEDOUT,
|
21
|
-
Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH, ::WinRM::WinRMWSManFault,
|
22
|
-
::WinRM::WinRMHTTPTransportError, ::WinRM::WinRMAuthorizationError,
|
23
|
-
HTTPClient::KeepAliveDisconnected, HTTPClient::ConnectTimeoutError
|
24
|
-
].freeze
|
25
|
-
end
|
26
|
-
|
27
18
|
# WinRM base class for errors
|
28
19
|
class WinRMError < StandardError; end
|
29
20
|
|
data/lib/winrm/shells/base.rb
CHANGED
@@ -15,7 +15,6 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require_relative 'retryable'
|
18
|
-
require_relative 'suppressible'
|
19
18
|
require_relative '../http/transport'
|
20
19
|
require_relative '../wsmv/cleanup_command'
|
21
20
|
require_relative '../wsmv/close_shell'
|
@@ -32,16 +31,14 @@ module WinRM
|
|
32
31
|
TOO_MANY_COMMANDS = '2150859174'.freeze
|
33
32
|
ERROR_OPERATION_ABORTED = '995'.freeze
|
34
33
|
SHELL_NOT_FOUND = '2150858843'.freeze
|
35
|
-
ERROR_READING_REGISTRY_KEY = '2147943418'.freeze
|
36
34
|
|
37
35
|
FAULTS_FOR_RESET = [
|
38
|
-
|
39
|
-
|
36
|
+
'2150858843', # Shell has been closed
|
37
|
+
'2147943418', # Error reading registry key
|
40
38
|
TOO_MANY_COMMANDS, # Maximum commands per user exceeded
|
41
39
|
].freeze
|
42
40
|
|
43
41
|
include Retryable
|
44
|
-
include Suppressible
|
45
42
|
|
46
43
|
# Create a new Cmd shell
|
47
44
|
# @param connection_opts [ConnectionOpts] The WinRM connection options
|
@@ -89,10 +86,10 @@ module WinRM
|
|
89
86
|
# Closes the shell if one is open
|
90
87
|
def close
|
91
88
|
return unless shell_id
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
begin
|
90
|
+
self.class.close_shell(connection_opts, transport, shell_id)
|
91
|
+
rescue WinRMWSManFault => e
|
92
|
+
raise unless [ERROR_OPERATION_ABORTED, SHELL_NOT_FOUND].include?(e.fault_code)
|
96
93
|
end
|
97
94
|
remove_finalizer
|
98
95
|
@shell_id = nil
|
@@ -156,11 +153,12 @@ module WinRM
|
|
156
153
|
shell_uri: shell_uri,
|
157
154
|
shell_id: shell_id,
|
158
155
|
command_id: command_id)
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
156
|
+
transport.send_request(cleanup_msg.build)
|
157
|
+
rescue WinRMWSManFault => e
|
158
|
+
raise unless [ERROR_OPERATION_ABORTED, SHELL_NOT_FOUND].include?(e.fault_code)
|
159
|
+
rescue WinRMHTTPTransportError => t
|
160
|
+
# dont let the cleanup raise so we dont lose any errors from the command
|
161
|
+
logger.info("[WinRM] #{t.status_code} returned in cleanup with error: #{t.message}")
|
164
162
|
end
|
165
163
|
|
166
164
|
def open
|
@@ -21,12 +21,21 @@ module WinRM
|
|
21
21
|
module Shells
|
22
22
|
# Shell mixin for retrying an operation
|
23
23
|
module Retryable
|
24
|
+
RETRYABLE_EXCEPTIONS = lambda do
|
25
|
+
[
|
26
|
+
Errno::EACCES, Errno::EADDRINUSE, Errno::ECONNREFUSED, Errno::ETIMEDOUT,
|
27
|
+
Errno::ECONNRESET, Errno::ENETUNREACH, Errno::EHOSTUNREACH, ::WinRM::WinRMWSManFault,
|
28
|
+
::WinRM::WinRMHTTPTransportError, ::WinRM::WinRMAuthorizationError,
|
29
|
+
HTTPClient::KeepAliveDisconnected, HTTPClient::ConnectTimeoutError
|
30
|
+
].freeze
|
31
|
+
end
|
32
|
+
|
24
33
|
# Retries the operation a specified number of times with a delay between
|
25
34
|
# @param retries [Integer] The number of times to retry
|
26
35
|
# @param delay [Integer] The number of seconds to wait between retry attempts
|
27
36
|
def retryable(retries, delay)
|
28
37
|
yield
|
29
|
-
rescue *
|
38
|
+
rescue *RETRYABLE_EXCEPTIONS.call
|
30
39
|
raise unless (retries -= 1) > 0
|
31
40
|
sleep(delay)
|
32
41
|
retry
|
data/lib/winrm/version.rb
CHANGED
@@ -213,11 +213,11 @@ describe DummyShell do
|
|
213
213
|
expect(subject.shell_id).to be(nil)
|
214
214
|
end
|
215
215
|
|
216
|
-
context 'when
|
216
|
+
context 'when shell was not found' do
|
217
217
|
it 'does not raise' do
|
218
218
|
subject.run(command, arguments)
|
219
219
|
expect(DummyShell).to receive(:close_shell)
|
220
|
-
.and_raise(
|
220
|
+
.and_raise(WinRM::WinRMWSManFault.new('oops', '2150858843'))
|
221
221
|
expect { subject.close }.not_to raise_error
|
222
222
|
end
|
223
223
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: winrm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Wanek
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-
|
14
|
+
date: 2017-05-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: gssapi
|
@@ -271,7 +271,6 @@ files:
|
|
271
271
|
- lib/winrm/shells/power_shell.rb
|
272
272
|
- lib/winrm/shells/retryable.rb
|
273
273
|
- lib/winrm/shells/shell_factory.rb
|
274
|
-
- lib/winrm/shells/suppressible.rb
|
275
274
|
- lib/winrm/version.rb
|
276
275
|
- lib/winrm/wsmv/base.rb
|
277
276
|
- lib/winrm/wsmv/cleanup_command.rb
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2017 Matt Wrock <matt@mattwrock.com>
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
require_relative '../exceptions'
|
18
|
-
|
19
|
-
module WinRM
|
20
|
-
module Shells
|
21
|
-
# Shell mixin for suppressing a network exception
|
22
|
-
module Suppressible
|
23
|
-
# performs an operation and suppresses any network exceptions
|
24
|
-
def suppressible
|
25
|
-
yield
|
26
|
-
rescue *WinRM::NETWORK_EXCEPTIONS.call => e
|
27
|
-
logger.info("[WinRM] Exception suppressed: #{e.message}")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|