mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
Remove winrm connection cache (only useful when running against one host). Also fixes #10391.
This commit is contained in:
parent
5675982b0f
commit
7ba2950c5a
1 changed files with 0 additions and 12 deletions
|
@ -18,8 +18,6 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
|
||||||
import imp
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
@ -44,10 +42,6 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
_winrm_cache = {
|
|
||||||
# 'user:pwhash@host:port': <protocol instance>
|
|
||||||
}
|
|
||||||
|
|
||||||
def vvvvv(msg, host=None):
|
def vvvvv(msg, host=None):
|
||||||
verbose(msg, host=host, caplevel=4)
|
verbose(msg, host=host, caplevel=4)
|
||||||
|
|
||||||
|
@ -84,10 +78,6 @@ class Connection(object):
|
||||||
vvv("ESTABLISH WINRM CONNECTION FOR USER: %s on PORT %s TO %s" % \
|
vvv("ESTABLISH WINRM CONNECTION FOR USER: %s on PORT %s TO %s" % \
|
||||||
(self.user, port, self.host), host=self.host)
|
(self.user, port, self.host), host=self.host)
|
||||||
netloc = '%s:%d' % (self.host, port)
|
netloc = '%s:%d' % (self.host, port)
|
||||||
cache_key = '%s:%s@%s:%d' % (self.user, hashlib.md5(self.password).hexdigest(), self.host, port)
|
|
||||||
if cache_key in _winrm_cache:
|
|
||||||
vvvv('WINRM REUSE EXISTING CONNECTION: %s' % cache_key, host=self.host)
|
|
||||||
return _winrm_cache[cache_key]
|
|
||||||
exc = None
|
exc = None
|
||||||
for transport, scheme in self.transport_schemes['http' if port == 5985 else 'https']:
|
for transport, scheme in self.transport_schemes['http' if port == 5985 else 'https']:
|
||||||
if transport == 'kerberos' and (not HAVE_KERBEROS or not '@' in self.user):
|
if transport == 'kerberos' and (not HAVE_KERBEROS or not '@' in self.user):
|
||||||
|
@ -104,7 +94,6 @@ class Connection(object):
|
||||||
realm=realm)
|
realm=realm)
|
||||||
try:
|
try:
|
||||||
protocol.send_message('')
|
protocol.send_message('')
|
||||||
_winrm_cache[cache_key] = protocol
|
|
||||||
return protocol
|
return protocol
|
||||||
except WinRMTransportError, exc:
|
except WinRMTransportError, exc:
|
||||||
err_msg = str(exc)
|
err_msg = str(exc)
|
||||||
|
@ -116,7 +105,6 @@ class Connection(object):
|
||||||
if code == 401:
|
if code == 401:
|
||||||
raise errors.AnsibleError("the username/password specified for this server was incorrect")
|
raise errors.AnsibleError("the username/password specified for this server was incorrect")
|
||||||
elif code == 411:
|
elif code == 411:
|
||||||
_winrm_cache[cache_key] = protocol
|
|
||||||
return protocol
|
return protocol
|
||||||
vvvv('WINRM CONNECTION ERROR: %s' % err_msg, host=self.host)
|
vvvv('WINRM CONNECTION ERROR: %s' % err_msg, host=self.host)
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue