winrm 2.2.1 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/changelog.md +4 -0
- data/lib/winrm/connection_opts.rb +91 -91
- data/lib/winrm/exceptions.rb +85 -76
- data/lib/winrm/psrp/init_runspace_pool.xml.erb +224 -224
- data/lib/winrm/shells/base.rb +14 -12
- data/lib/winrm/shells/retryable.rb +36 -45
- data/lib/winrm/shells/suppressible.rb +31 -0
- data/lib/winrm/version.rb +1 -1
- data/tests/spec/shells/base_spec.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aea153848b3f833150520c7ccd2ff1ec940f0238
|
4
|
+
data.tar.gz: 0c4ab4320a28d135423de6ee6ea39a8e428cc069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97ea0581ac573fb208c5d2b43d3a71b926c2b65a05198a157e03c1538cf2169b8ff09ec0134188d0ae4703e2c4ae462a90e6409abf3eb98ee6292c48eef2bd9c
|
7
|
+
data.tar.gz: acb321d609e66cb79de65d900e6a7b62f1b3962d5975f10b57188dd2d2788a26667a2cd69bc06278d8972b825b54909bd2fd9fac75e19eae15c4abaf60cbccae
|
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
source 'https://rubygems.org'
|
3
|
-
gemspec
|
1
|
+
# encoding: UTF-8
|
2
|
+
source 'https://rubygems.org'
|
3
|
+
gemspec
|
data/changelog.md
CHANGED
@@ -1,91 +1,91 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2016 Shawn Neal <sneal@sneal.net>
|
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 'securerandom'
|
18
|
-
|
19
|
-
module WinRM
|
20
|
-
# WinRM connection options, provides defaults and validation.
|
21
|
-
class ConnectionOpts < Hash
|
22
|
-
DEFAULT_OPERATION_TIMEOUT = 60
|
23
|
-
DEFAULT_RECEIVE_TIMEOUT = DEFAULT_OPERATION_TIMEOUT + 10
|
24
|
-
DEFAULT_MAX_ENV_SIZE = 153600
|
25
|
-
DEFAULT_LOCALE = 'en-US'.freeze
|
26
|
-
DEFAULT_RETRY_DELAY = 10
|
27
|
-
DEFAULT_RETRY_LIMIT = 3
|
28
|
-
|
29
|
-
class << self
|
30
|
-
def create_with_defaults(overrides)
|
31
|
-
config = default.merge(overrides)
|
32
|
-
config = ensure_receive_timeout_is_greater_than_operation_timeout(config)
|
33
|
-
config.validate
|
34
|
-
config
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def ensure_receive_timeout_is_greater_than_operation_timeout(config)
|
40
|
-
if config[:receive_timeout] < config[:operation_timeout]
|
41
|
-
config[:receive_timeout] = config[:operation_timeout] + 10
|
42
|
-
end
|
43
|
-
config
|
44
|
-
end
|
45
|
-
|
46
|
-
def default
|
47
|
-
config = ConnectionOpts.new
|
48
|
-
config[:session_id] = SecureRandom.uuid.to_s.upcase
|
49
|
-
config[:transport] = :negotiate
|
50
|
-
config[:locale] = DEFAULT_LOCALE
|
51
|
-
config[:max_envelope_size] = DEFAULT_MAX_ENV_SIZE
|
52
|
-
config[:operation_timeout] = DEFAULT_OPERATION_TIMEOUT
|
53
|
-
config[:receive_timeout] = DEFAULT_RECEIVE_TIMEOUT
|
54
|
-
config[:retry_delay] = DEFAULT_RETRY_DELAY
|
55
|
-
config[:retry_limit] = DEFAULT_RETRY_LIMIT
|
56
|
-
config
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def validate
|
61
|
-
validate_required_fields
|
62
|
-
validate_data_types
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def validate_required_fields
|
68
|
-
raise 'endpoint is a required option' unless self[:endpoint]
|
69
|
-
if self[:client_cert]
|
70
|
-
raise 'path to client key is required' unless self[:client_key]
|
71
|
-
else
|
72
|
-
raise 'user is a required option' unless self[:user]
|
73
|
-
raise 'password is a required option' unless self[:password]
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def validate_data_types
|
78
|
-
validate_integer(:retry_limit)
|
79
|
-
validate_integer(:retry_delay)
|
80
|
-
validate_integer(:max_envelope_size)
|
81
|
-
validate_integer(:operation_timeout)
|
82
|
-
validate_integer(:receive_timeout, self[:operation_timeout])
|
83
|
-
end
|
84
|
-
|
85
|
-
def validate_integer(key, min = 0)
|
86
|
-
value = self[key]
|
87
|
-
raise "#{key} must be a Integer" unless value && value.is_a?(Integer)
|
88
|
-
raise "#{key} must be greater than #{min}" unless value > min
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2016 Shawn Neal <sneal@sneal.net>
|
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 'securerandom'
|
18
|
+
|
19
|
+
module WinRM
|
20
|
+
# WinRM connection options, provides defaults and validation.
|
21
|
+
class ConnectionOpts < Hash
|
22
|
+
DEFAULT_OPERATION_TIMEOUT = 60
|
23
|
+
DEFAULT_RECEIVE_TIMEOUT = DEFAULT_OPERATION_TIMEOUT + 10
|
24
|
+
DEFAULT_MAX_ENV_SIZE = 153600
|
25
|
+
DEFAULT_LOCALE = 'en-US'.freeze
|
26
|
+
DEFAULT_RETRY_DELAY = 10
|
27
|
+
DEFAULT_RETRY_LIMIT = 3
|
28
|
+
|
29
|
+
class << self
|
30
|
+
def create_with_defaults(overrides)
|
31
|
+
config = default.merge(overrides)
|
32
|
+
config = ensure_receive_timeout_is_greater_than_operation_timeout(config)
|
33
|
+
config.validate
|
34
|
+
config
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def ensure_receive_timeout_is_greater_than_operation_timeout(config)
|
40
|
+
if config[:receive_timeout] < config[:operation_timeout]
|
41
|
+
config[:receive_timeout] = config[:operation_timeout] + 10
|
42
|
+
end
|
43
|
+
config
|
44
|
+
end
|
45
|
+
|
46
|
+
def default
|
47
|
+
config = ConnectionOpts.new
|
48
|
+
config[:session_id] = SecureRandom.uuid.to_s.upcase
|
49
|
+
config[:transport] = :negotiate
|
50
|
+
config[:locale] = DEFAULT_LOCALE
|
51
|
+
config[:max_envelope_size] = DEFAULT_MAX_ENV_SIZE
|
52
|
+
config[:operation_timeout] = DEFAULT_OPERATION_TIMEOUT
|
53
|
+
config[:receive_timeout] = DEFAULT_RECEIVE_TIMEOUT
|
54
|
+
config[:retry_delay] = DEFAULT_RETRY_DELAY
|
55
|
+
config[:retry_limit] = DEFAULT_RETRY_LIMIT
|
56
|
+
config
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def validate
|
61
|
+
validate_required_fields
|
62
|
+
validate_data_types
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def validate_required_fields
|
68
|
+
raise 'endpoint is a required option' unless self[:endpoint]
|
69
|
+
if self[:client_cert]
|
70
|
+
raise 'path to client key is required' unless self[:client_key]
|
71
|
+
else
|
72
|
+
raise 'user is a required option' unless self[:user]
|
73
|
+
raise 'password is a required option' unless self[:password]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def validate_data_types
|
78
|
+
validate_integer(:retry_limit)
|
79
|
+
validate_integer(:retry_delay)
|
80
|
+
validate_integer(:max_envelope_size)
|
81
|
+
validate_integer(:operation_timeout)
|
82
|
+
validate_integer(:receive_timeout, self[:operation_timeout])
|
83
|
+
end
|
84
|
+
|
85
|
+
def validate_integer(key, min = 0)
|
86
|
+
value = self[key]
|
87
|
+
raise "#{key} must be a Integer" unless value && value.is_a?(Integer)
|
88
|
+
raise "#{key} must be greater than #{min}" unless value > min
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/winrm/exceptions.rb
CHANGED
@@ -1,76 +1,85 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
#
|
3
|
-
# Copyright 2010 Dan Wanek <dan.wanek@gmail.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
|
-
module WinRM
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
#
|
28
|
-
class
|
29
|
-
|
30
|
-
#
|
31
|
-
class
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright 2010 Dan Wanek <dan.wanek@gmail.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
|
+
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
|
+
# WinRM base class for errors
|
28
|
+
class WinRMError < StandardError; end
|
29
|
+
|
30
|
+
# Authorization Error
|
31
|
+
class WinRMAuthorizationError < WinRMError; end
|
32
|
+
|
33
|
+
# Shell creation error
|
34
|
+
class InvalidShellError < WinRMError; end
|
35
|
+
|
36
|
+
# Exitcode error
|
37
|
+
class InvalidExitCode < WinRMError; end
|
38
|
+
|
39
|
+
# Shell creation error
|
40
|
+
class InvalidTransportError < WinRMError
|
41
|
+
attr_reader :invalid_transport
|
42
|
+
|
43
|
+
def initialize(invalid_transport, valid_transports)
|
44
|
+
@invalid_transport = invalid_transport
|
45
|
+
super(
|
46
|
+
"Invalid transport '#{invalid_transport}' specified" \
|
47
|
+
", expected: #{valid_transports.join(', ')}."
|
48
|
+
)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# A Fault returned in the SOAP response. The XML node is a WSManFault
|
53
|
+
class WinRMWSManFault < WinRMError
|
54
|
+
attr_reader :fault_code
|
55
|
+
attr_reader :fault_description
|
56
|
+
|
57
|
+
def initialize(fault_description, fault_code)
|
58
|
+
@fault_description = fault_description
|
59
|
+
@fault_code = fault_code
|
60
|
+
super("[WSMAN ERROR CODE: #{fault_code}]: #{fault_description}")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# A Fault returned in the SOAP response. The XML node is a MSFT_WmiError
|
65
|
+
class WinRMWMIError < WinRMError
|
66
|
+
attr_reader :error_code
|
67
|
+
attr_reader :error
|
68
|
+
|
69
|
+
def initialize(error, error_code)
|
70
|
+
@error = error
|
71
|
+
@error_code = error_code
|
72
|
+
super("[WMI ERROR CODE: #{error_code}]: #{error}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# non-200 response without a SOAP fault
|
77
|
+
class WinRMHTTPTransportError < WinRMError
|
78
|
+
attr_reader :status_code
|
79
|
+
|
80
|
+
def initialize(msg, status_code = nil)
|
81
|
+
@status_code = status_code
|
82
|
+
super(msg + " (#{status_code}).")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -1,224 +1,224 @@
|
|
1
|
-
<Obj RefId="0">
|
2
|
-
<MS>
|
3
|
-
<I32 N="MinRunspaces">1</I32>
|
4
|
-
<I32 N="MaxRunspaces">1</I32>
|
5
|
-
<Obj N="PSThreadOptions" RefId="1">
|
6
|
-
<TN RefId="0">
|
7
|
-
<T>System.Management.Automation.Runspaces.PSThreadOptions</T>
|
8
|
-
<T>System.Enum</T>
|
9
|
-
<T>System.ValueType</T>
|
10
|
-
<T>System.Object</T>
|
11
|
-
</TN>
|
12
|
-
<ToString>Default</ToString>
|
13
|
-
<I32>0</I32>
|
14
|
-
</Obj>
|
15
|
-
<Obj N="ApartmentState" RefId="2">
|
16
|
-
<TN RefId="1">
|
17
|
-
<T>System.Threading.ApartmentState</T>
|
18
|
-
<T>System.Enum</T>
|
19
|
-
<T>System.ValueType</T>
|
20
|
-
<T>System.Object</T>
|
21
|
-
</TN>
|
22
|
-
<ToString>Unknown</ToString>
|
23
|
-
<I32>2</I32>
|
24
|
-
</Obj>
|
25
|
-
<Obj N="ApplicationArguments" RefId="3">
|
26
|
-
<TN RefId="2">
|
27
|
-
<T>System.Management.Automation.PSPrimitiveDictionary</T>
|
28
|
-
<T>System.Collections.Hashtable</T>
|
29
|
-
<T>System.Object</T>
|
30
|
-
</TN>
|
31
|
-
<DCT>
|
32
|
-
<En>
|
33
|
-
<S N="Key">PSVersionTable</S>
|
34
|
-
<Obj N="Value" RefId="4">
|
35
|
-
<TNRef RefId="2" />
|
36
|
-
<DCT>
|
37
|
-
<En>
|
38
|
-
<S N="Key">PSVersion</S>
|
39
|
-
<Version N="Value">5.0.11082.1000</Version>
|
40
|
-
</En>
|
41
|
-
<En>
|
42
|
-
<S N="Key">PSCompatibleVersions</S>
|
43
|
-
<Obj N="Value" RefId="5">
|
44
|
-
<TN RefId="3">
|
45
|
-
<T>System.Version[]</T>
|
46
|
-
<T>System.Array</T>
|
47
|
-
<T>System.Object</T>
|
48
|
-
</TN>
|
49
|
-
<LST>
|
50
|
-
<Version>1.0</Version>
|
51
|
-
<Version>2.0</Version>
|
52
|
-
<Version>3.0</Version>
|
53
|
-
<Version>4.0</Version>
|
54
|
-
<Version>5.0.11082.1000</Version>
|
55
|
-
</LST>
|
56
|
-
</Obj>
|
57
|
-
</En>
|
58
|
-
<En>
|
59
|
-
<S N="Key">CLRVersion</S>
|
60
|
-
<Version N="Value">4.0.30319.42000</Version>
|
61
|
-
</En>
|
62
|
-
<En>
|
63
|
-
<S N="Key">BuildVersion</S>
|
64
|
-
<Version N="Value">10.0.11082.1000</Version>
|
65
|
-
</En>
|
66
|
-
<En>
|
67
|
-
<S N="Key">WSManStackVersion</S>
|
68
|
-
<Version N="Value">3.0</Version>
|
69
|
-
</En>
|
70
|
-
<En>
|
71
|
-
<S N="Key">PSRemotingProtocolVersion</S>
|
72
|
-
<Version N="Value">2.3</Version>
|
73
|
-
</En>
|
74
|
-
<En>
|
75
|
-
<S N="Key">SerializationVersion</S>
|
76
|
-
<Version N="Value">1.1.0.1</Version>
|
77
|
-
</En>
|
78
|
-
</DCT>
|
79
|
-
</Obj>
|
80
|
-
</En>
|
81
|
-
</DCT>
|
82
|
-
</Obj>
|
83
|
-
<Obj N="HostInfo" RefId="6">
|
84
|
-
<MS>
|
85
|
-
<Obj N="_hostDefaultData" RefId="7">
|
86
|
-
<MS>
|
87
|
-
<Obj N="data" RefId="8">
|
88
|
-
<TN RefId="4">
|
89
|
-
<T>System.Collections.Hashtable</T>
|
90
|
-
<T>System.Object</T>
|
91
|
-
</TN>
|
92
|
-
<DCT>
|
93
|
-
<En>
|
94
|
-
<I32 N="Key">9</I32>
|
95
|
-
<Obj N="Value" RefId="9">
|
96
|
-
<MS>
|
97
|
-
<S N="T">System.String</S>
|
98
|
-
<S N="V">C:\dev\kitchen-vagrant</S>
|
99
|
-
</MS>
|
100
|
-
</Obj>
|
101
|
-
</En>
|
102
|
-
<En>
|
103
|
-
<I32 N="Key">8</I32>
|
104
|
-
<Obj N="Value" RefId="10">
|
105
|
-
<MS>
|
106
|
-
<S N="T">System.Management.Automation.Host.Size</S>
|
107
|
-
<Obj N="V" RefId="11">
|
108
|
-
<MS>
|
109
|
-
<I32 N="width">199</I32>
|
110
|
-
<I32 N="height">52</I32>
|
111
|
-
</MS>
|
112
|
-
</Obj>
|
113
|
-
</MS>
|
114
|
-
</Obj>
|
115
|
-
</En>
|
116
|
-
<En>
|
117
|
-
<I32 N="Key">7</I32>
|
118
|
-
<Obj N="Value" RefId="12">
|
119
|
-
<MS>
|
120
|
-
<S N="T">System.Management.Automation.Host.Size</S>
|
121
|
-
<Obj N="V" RefId="13">
|
122
|
-
<MS>
|
123
|
-
<I32 N="width">80</I32>
|
124
|
-
<I32 N="height">52</I32>
|
125
|
-
</MS>
|
126
|
-
</Obj>
|
127
|
-
</MS>
|
128
|
-
</Obj>
|
129
|
-
</En>
|
130
|
-
<En>
|
131
|
-
<I32 N="Key">6</I32>
|
132
|
-
<Obj N="Value" RefId="14">
|
133
|
-
<MS>
|
134
|
-
<S N="T">System.Management.Automation.Host.Size</S>
|
135
|
-
<Obj N="V" RefId="15">
|
136
|
-
<MS>
|
137
|
-
<I32 N="width">80</I32>
|
138
|
-
<I32 N="height">25</I32>
|
139
|
-
</MS>
|
140
|
-
</Obj>
|
141
|
-
</MS>
|
142
|
-
</Obj>
|
143
|
-
</En>
|
144
|
-
<En>
|
145
|
-
<I32 N="Key">5</I32>
|
146
|
-
<Obj N="Value" RefId="16">
|
147
|
-
<MS>
|
148
|
-
<S N="T">System.Management.Automation.Host.Size</S>
|
149
|
-
<Obj N="V" RefId="17">
|
150
|
-
<MS>
|
151
|
-
<I32 N="width">
|
152
|
-
<I32 N="height">9999</I32>
|
153
|
-
</MS>
|
154
|
-
</Obj>
|
155
|
-
</MS>
|
156
|
-
</Obj>
|
157
|
-
</En>
|
158
|
-
<En>
|
159
|
-
<I32 N="Key">4</I32>
|
160
|
-
<Obj N="Value" RefId="18">
|
161
|
-
<MS>
|
162
|
-
<S N="T">System.Int32</S>
|
163
|
-
<I32 N="V">25</I32>
|
164
|
-
</MS>
|
165
|
-
</Obj>
|
166
|
-
</En>
|
167
|
-
<En>
|
168
|
-
<I32 N="Key">3</I32>
|
169
|
-
<Obj N="Value" RefId="19">
|
170
|
-
<MS>
|
171
|
-
<S N="T">System.Management.Automation.Host.Coordinates</S>
|
172
|
-
<Obj N="V" RefId="20">
|
173
|
-
<MS>
|
174
|
-
<I32 N="x">0</I32>
|
175
|
-
<I32 N="y">9974</I32>
|
176
|
-
</MS>
|
177
|
-
</Obj>
|
178
|
-
</MS>
|
179
|
-
</Obj>
|
180
|
-
</En>
|
181
|
-
<En>
|
182
|
-
<I32 N="Key">2</I32>
|
183
|
-
<Obj N="Value" RefId="21">
|
184
|
-
<MS>
|
185
|
-
<S N="T">System.Management.Automation.Host.Coordinates</S>
|
186
|
-
<Obj N="V" RefId="22">
|
187
|
-
<MS>
|
188
|
-
<I32 N="x">0</I32>
|
189
|
-
<I32 N="y">9998</I32>
|
190
|
-
</MS>
|
191
|
-
</Obj>
|
192
|
-
</MS>
|
193
|
-
</Obj>
|
194
|
-
</En>
|
195
|
-
<En>
|
196
|
-
<I32 N="Key">1</I32>
|
197
|
-
<Obj N="Value" RefId="23">
|
198
|
-
<MS>
|
199
|
-
<S N="T">System.ConsoleColor</S>
|
200
|
-
<I32 N="V">0</I32>
|
201
|
-
</MS>
|
202
|
-
</Obj>
|
203
|
-
</En>
|
204
|
-
<En>
|
205
|
-
<I32 N="Key">0</I32>
|
206
|
-
<Obj N="Value" RefId="24">
|
207
|
-
<MS>
|
208
|
-
<S N="T">System.ConsoleColor</S>
|
209
|
-
<I32 N="V">7</I32>
|
210
|
-
</MS>
|
211
|
-
</Obj>
|
212
|
-
</En>
|
213
|
-
</DCT>
|
214
|
-
</Obj>
|
215
|
-
</MS>
|
216
|
-
</Obj>
|
217
|
-
<B N="_isHostNull">false</B>
|
218
|
-
<B N="_isHostUINull">false</B>
|
219
|
-
<B N="_isHostRawUINull">false</B>
|
220
|
-
<B N="_useRunspaceHost">false</B>
|
221
|
-
</MS>
|
222
|
-
</Obj>
|
223
|
-
</MS>
|
224
|
-
</Obj>
|
1
|
+
<Obj RefId="0">
|
2
|
+
<MS>
|
3
|
+
<I32 N="MinRunspaces">1</I32>
|
4
|
+
<I32 N="MaxRunspaces">1</I32>
|
5
|
+
<Obj N="PSThreadOptions" RefId="1">
|
6
|
+
<TN RefId="0">
|
7
|
+
<T>System.Management.Automation.Runspaces.PSThreadOptions</T>
|
8
|
+
<T>System.Enum</T>
|
9
|
+
<T>System.ValueType</T>
|
10
|
+
<T>System.Object</T>
|
11
|
+
</TN>
|
12
|
+
<ToString>Default</ToString>
|
13
|
+
<I32>0</I32>
|
14
|
+
</Obj>
|
15
|
+
<Obj N="ApartmentState" RefId="2">
|
16
|
+
<TN RefId="1">
|
17
|
+
<T>System.Threading.ApartmentState</T>
|
18
|
+
<T>System.Enum</T>
|
19
|
+
<T>System.ValueType</T>
|
20
|
+
<T>System.Object</T>
|
21
|
+
</TN>
|
22
|
+
<ToString>Unknown</ToString>
|
23
|
+
<I32>2</I32>
|
24
|
+
</Obj>
|
25
|
+
<Obj N="ApplicationArguments" RefId="3">
|
26
|
+
<TN RefId="2">
|
27
|
+
<T>System.Management.Automation.PSPrimitiveDictionary</T>
|
28
|
+
<T>System.Collections.Hashtable</T>
|
29
|
+
<T>System.Object</T>
|
30
|
+
</TN>
|
31
|
+
<DCT>
|
32
|
+
<En>
|
33
|
+
<S N="Key">PSVersionTable</S>
|
34
|
+
<Obj N="Value" RefId="4">
|
35
|
+
<TNRef RefId="2" />
|
36
|
+
<DCT>
|
37
|
+
<En>
|
38
|
+
<S N="Key">PSVersion</S>
|
39
|
+
<Version N="Value">5.0.11082.1000</Version>
|
40
|
+
</En>
|
41
|
+
<En>
|
42
|
+
<S N="Key">PSCompatibleVersions</S>
|
43
|
+
<Obj N="Value" RefId="5">
|
44
|
+
<TN RefId="3">
|
45
|
+
<T>System.Version[]</T>
|
46
|
+
<T>System.Array</T>
|
47
|
+
<T>System.Object</T>
|
48
|
+
</TN>
|
49
|
+
<LST>
|
50
|
+
<Version>1.0</Version>
|
51
|
+
<Version>2.0</Version>
|
52
|
+
<Version>3.0</Version>
|
53
|
+
<Version>4.0</Version>
|
54
|
+
<Version>5.0.11082.1000</Version>
|
55
|
+
</LST>
|
56
|
+
</Obj>
|
57
|
+
</En>
|
58
|
+
<En>
|
59
|
+
<S N="Key">CLRVersion</S>
|
60
|
+
<Version N="Value">4.0.30319.42000</Version>
|
61
|
+
</En>
|
62
|
+
<En>
|
63
|
+
<S N="Key">BuildVersion</S>
|
64
|
+
<Version N="Value">10.0.11082.1000</Version>
|
65
|
+
</En>
|
66
|
+
<En>
|
67
|
+
<S N="Key">WSManStackVersion</S>
|
68
|
+
<Version N="Value">3.0</Version>
|
69
|
+
</En>
|
70
|
+
<En>
|
71
|
+
<S N="Key">PSRemotingProtocolVersion</S>
|
72
|
+
<Version N="Value">2.3</Version>
|
73
|
+
</En>
|
74
|
+
<En>
|
75
|
+
<S N="Key">SerializationVersion</S>
|
76
|
+
<Version N="Value">1.1.0.1</Version>
|
77
|
+
</En>
|
78
|
+
</DCT>
|
79
|
+
</Obj>
|
80
|
+
</En>
|
81
|
+
</DCT>
|
82
|
+
</Obj>
|
83
|
+
<Obj N="HostInfo" RefId="6">
|
84
|
+
<MS>
|
85
|
+
<Obj N="_hostDefaultData" RefId="7">
|
86
|
+
<MS>
|
87
|
+
<Obj N="data" RefId="8">
|
88
|
+
<TN RefId="4">
|
89
|
+
<T>System.Collections.Hashtable</T>
|
90
|
+
<T>System.Object</T>
|
91
|
+
</TN>
|
92
|
+
<DCT>
|
93
|
+
<En>
|
94
|
+
<I32 N="Key">9</I32>
|
95
|
+
<Obj N="Value" RefId="9">
|
96
|
+
<MS>
|
97
|
+
<S N="T">System.String</S>
|
98
|
+
<S N="V">C:\dev\kitchen-vagrant</S>
|
99
|
+
</MS>
|
100
|
+
</Obj>
|
101
|
+
</En>
|
102
|
+
<En>
|
103
|
+
<I32 N="Key">8</I32>
|
104
|
+
<Obj N="Value" RefId="10">
|
105
|
+
<MS>
|
106
|
+
<S N="T">System.Management.Automation.Host.Size</S>
|
107
|
+
<Obj N="V" RefId="11">
|
108
|
+
<MS>
|
109
|
+
<I32 N="width">199</I32>
|
110
|
+
<I32 N="height">52</I32>
|
111
|
+
</MS>
|
112
|
+
</Obj>
|
113
|
+
</MS>
|
114
|
+
</Obj>
|
115
|
+
</En>
|
116
|
+
<En>
|
117
|
+
<I32 N="Key">7</I32>
|
118
|
+
<Obj N="Value" RefId="12">
|
119
|
+
<MS>
|
120
|
+
<S N="T">System.Management.Automation.Host.Size</S>
|
121
|
+
<Obj N="V" RefId="13">
|
122
|
+
<MS>
|
123
|
+
<I32 N="width">80</I32>
|
124
|
+
<I32 N="height">52</I32>
|
125
|
+
</MS>
|
126
|
+
</Obj>
|
127
|
+
</MS>
|
128
|
+
</Obj>
|
129
|
+
</En>
|
130
|
+
<En>
|
131
|
+
<I32 N="Key">6</I32>
|
132
|
+
<Obj N="Value" RefId="14">
|
133
|
+
<MS>
|
134
|
+
<S N="T">System.Management.Automation.Host.Size</S>
|
135
|
+
<Obj N="V" RefId="15">
|
136
|
+
<MS>
|
137
|
+
<I32 N="width">80</I32>
|
138
|
+
<I32 N="height">25</I32>
|
139
|
+
</MS>
|
140
|
+
</Obj>
|
141
|
+
</MS>
|
142
|
+
</Obj>
|
143
|
+
</En>
|
144
|
+
<En>
|
145
|
+
<I32 N="Key">5</I32>
|
146
|
+
<Obj N="Value" RefId="16">
|
147
|
+
<MS>
|
148
|
+
<S N="T">System.Management.Automation.Host.Size</S>
|
149
|
+
<Obj N="V" RefId="17">
|
150
|
+
<MS>
|
151
|
+
<I32 N="width">250</I32>
|
152
|
+
<I32 N="height">9999</I32>
|
153
|
+
</MS>
|
154
|
+
</Obj>
|
155
|
+
</MS>
|
156
|
+
</Obj>
|
157
|
+
</En>
|
158
|
+
<En>
|
159
|
+
<I32 N="Key">4</I32>
|
160
|
+
<Obj N="Value" RefId="18">
|
161
|
+
<MS>
|
162
|
+
<S N="T">System.Int32</S>
|
163
|
+
<I32 N="V">25</I32>
|
164
|
+
</MS>
|
165
|
+
</Obj>
|
166
|
+
</En>
|
167
|
+
<En>
|
168
|
+
<I32 N="Key">3</I32>
|
169
|
+
<Obj N="Value" RefId="19">
|
170
|
+
<MS>
|
171
|
+
<S N="T">System.Management.Automation.Host.Coordinates</S>
|
172
|
+
<Obj N="V" RefId="20">
|
173
|
+
<MS>
|
174
|
+
<I32 N="x">0</I32>
|
175
|
+
<I32 N="y">9974</I32>
|
176
|
+
</MS>
|
177
|
+
</Obj>
|
178
|
+
</MS>
|
179
|
+
</Obj>
|
180
|
+
</En>
|
181
|
+
<En>
|
182
|
+
<I32 N="Key">2</I32>
|
183
|
+
<Obj N="Value" RefId="21">
|
184
|
+
<MS>
|
185
|
+
<S N="T">System.Management.Automation.Host.Coordinates</S>
|
186
|
+
<Obj N="V" RefId="22">
|
187
|
+
<MS>
|
188
|
+
<I32 N="x">0</I32>
|
189
|
+
<I32 N="y">9998</I32>
|
190
|
+
</MS>
|
191
|
+
</Obj>
|
192
|
+
</MS>
|
193
|
+
</Obj>
|
194
|
+
</En>
|
195
|
+
<En>
|
196
|
+
<I32 N="Key">1</I32>
|
197
|
+
<Obj N="Value" RefId="23">
|
198
|
+
<MS>
|
199
|
+
<S N="T">System.ConsoleColor</S>
|
200
|
+
<I32 N="V">0</I32>
|
201
|
+
</MS>
|
202
|
+
</Obj>
|
203
|
+
</En>
|
204
|
+
<En>
|
205
|
+
<I32 N="Key">0</I32>
|
206
|
+
<Obj N="Value" RefId="24">
|
207
|
+
<MS>
|
208
|
+
<S N="T">System.ConsoleColor</S>
|
209
|
+
<I32 N="V">7</I32>
|
210
|
+
</MS>
|
211
|
+
</Obj>
|
212
|
+
</En>
|
213
|
+
</DCT>
|
214
|
+
</Obj>
|
215
|
+
</MS>
|
216
|
+
</Obj>
|
217
|
+
<B N="_isHostNull">false</B>
|
218
|
+
<B N="_isHostUINull">false</B>
|
219
|
+
<B N="_isHostRawUINull">false</B>
|
220
|
+
<B N="_useRunspaceHost">false</B>
|
221
|
+
</MS>
|
222
|
+
</Obj>
|
223
|
+
</MS>
|
224
|
+
</Obj>
|
data/lib/winrm/shells/base.rb
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
require_relative 'retryable'
|
18
|
+
require_relative 'suppressible'
|
18
19
|
require_relative '../http/transport'
|
19
20
|
require_relative '../wsmv/cleanup_command'
|
20
21
|
require_relative '../wsmv/close_shell'
|
@@ -31,14 +32,16 @@ module WinRM
|
|
31
32
|
TOO_MANY_COMMANDS = '2150859174'.freeze
|
32
33
|
ERROR_OPERATION_ABORTED = '995'.freeze
|
33
34
|
SHELL_NOT_FOUND = '2150858843'.freeze
|
35
|
+
ERROR_READING_REGISTRY_KEY = '2147943418'.freeze
|
34
36
|
|
35
37
|
FAULTS_FOR_RESET = [
|
36
|
-
|
37
|
-
|
38
|
+
SHELL_NOT_FOUND,
|
39
|
+
ERROR_READING_REGISTRY_KEY,
|
38
40
|
TOO_MANY_COMMANDS, # Maximum commands per user exceeded
|
39
41
|
].freeze
|
40
42
|
|
41
43
|
include Retryable
|
44
|
+
include Suppressible
|
42
45
|
|
43
46
|
# Create a new Cmd shell
|
44
47
|
# @param connection_opts [ConnectionOpts] The WinRM connection options
|
@@ -86,10 +89,10 @@ module WinRM
|
|
86
89
|
# Closes the shell if one is open
|
87
90
|
def close
|
88
91
|
return unless shell_id
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
92
|
+
suppressible do
|
93
|
+
retryable(connection_opts[:retry_limit], connection_opts[:retry_delay]) do
|
94
|
+
self.class.close_shell(connection_opts, transport, shell_id)
|
95
|
+
end
|
93
96
|
end
|
94
97
|
remove_finalizer
|
95
98
|
@shell_id = nil
|
@@ -153,12 +156,11 @@ module WinRM
|
|
153
156
|
shell_uri: shell_uri,
|
154
157
|
shell_id: shell_id,
|
155
158
|
command_id: command_id)
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
logger.info("[WinRM] #{t.status_code} returned in cleanup with error: #{t.message}")
|
159
|
+
suppressible do
|
160
|
+
retryable(connection_opts[:retry_limit], connection_opts[:retry_delay]) do
|
161
|
+
transport.send_request(cleanup_msg.build)
|
162
|
+
end
|
163
|
+
end
|
162
164
|
end
|
163
165
|
|
164
166
|
def open
|
@@ -1,45 +1,36 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Copyright 2016 Shawn Neal <sneal@sneal.net>
|
4
|
-
# Copyright 2015 Matt Wrock <matt@mattwrock.com>
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
require_relative '../exceptions'
|
19
|
-
|
20
|
-
module WinRM
|
21
|
-
module Shells
|
22
|
-
# Shell mixin for retrying an operation
|
23
|
-
module Retryable
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
yield
|
38
|
-
rescue *RETRYABLE_EXCEPTIONS.call
|
39
|
-
raise unless (retries -= 1) > 0
|
40
|
-
sleep(delay)
|
41
|
-
retry
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2016 Shawn Neal <sneal@sneal.net>
|
4
|
+
# Copyright 2015 Matt Wrock <matt@mattwrock.com>
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
|
18
|
+
require_relative '../exceptions'
|
19
|
+
|
20
|
+
module WinRM
|
21
|
+
module Shells
|
22
|
+
# Shell mixin for retrying an operation
|
23
|
+
module Retryable
|
24
|
+
# Retries the operation a specified number of times with a delay between
|
25
|
+
# @param retries [Integer] The number of times to retry
|
26
|
+
# @param delay [Integer] The number of seconds to wait between retry attempts
|
27
|
+
def retryable(retries, delay)
|
28
|
+
yield
|
29
|
+
rescue *WinRM::NETWORK_EXCEPTIONS.call
|
30
|
+
raise unless (retries -= 1) > 0
|
31
|
+
sleep(delay)
|
32
|
+
retry
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,31 @@
|
|
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
|
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 connection is refused' 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(Errno::ECONNREFUSED.new)
|
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.2
|
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-04-
|
14
|
+
date: 2017-04-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: gssapi
|
@@ -271,6 +271,7 @@ 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
|
274
275
|
- lib/winrm/version.rb
|
275
276
|
- lib/winrm/wsmv/base.rb
|
276
277
|
- lib/winrm/wsmv/cleanup_command.rb
|
@@ -379,7 +380,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
379
380
|
version: '0'
|
380
381
|
requirements: []
|
381
382
|
rubyforge_project:
|
382
|
-
rubygems_version: 2.6.
|
383
|
+
rubygems_version: 2.6.11
|
383
384
|
signing_key:
|
384
385
|
specification_version: 4
|
385
386
|
summary: Ruby library for Windows Remote Management
|