Skip to content

Commit

Permalink
Merge 62af806 into 3fa1fa7
Browse files Browse the repository at this point in the history
  • Loading branch information
mcassaniti committed Jan 4, 2017
2 parents 3fa1fa7 + 62af806 commit f7131a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion winrm/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def __init__(
read_timeout_sec=DEFAULT_READ_TIMEOUT_SEC,
operation_timeout_sec=DEFAULT_OPERATION_TIMEOUT_SEC,
kerberos_hostname_override=None,
proxies=None,
):
"""
@param string endpoint: the WinRM webservice endpoint
Expand All @@ -47,6 +48,7 @@ def __init__(
@param int read_timeout_sec: maximum seconds to wait before an HTTP connect/read times out (default 30). This value should be slightly higher than operation_timeout_sec, as the server can block *at least* that long. # NOQA
@param int operation_timeout_sec: maximum allowed time in seconds for any single wsman HTTP operation (default 20). Note that operation timeouts while receiving output (the only wsman operation that should take any significant time, and where these timeouts are expected) will be silently retried indefinitely. # NOQA
@param string kerberos_hostname_override: the hostname to use for the kerberos exchange (defaults to the hostname in the endpoint URL)
@param dict proxies: A dictionary of proxies to pass onto Python requests (default is to use environment variables)
"""

if operation_timeout_sec >= read_timeout_sec or operation_timeout_sec < 1:
Expand All @@ -65,7 +67,8 @@ def __init__(
server_cert_validation=server_cert_validation,
kerberos_delegation=kerberos_delegation,
kerberos_hostname_override=kerberos_hostname_override,
auth_method=transport)
auth_method=transport,
proxies=proxies)

self.username = username
self.password = password
Expand Down
10 changes: 6 additions & 4 deletions winrm/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def __init__(
cert_key_pem=None, read_timeout_sec=None, server_cert_validation='validate',
kerberos_delegation=False,
kerberos_hostname_override=None,
auth_method='auto'):
auth_method='auto',
proxies=None):
self.endpoint = endpoint
self.username = username
self.password = password
Expand All @@ -72,6 +73,7 @@ def __init__(
self.read_timeout_sec = read_timeout_sec
self.server_cert_validation = server_cert_validation
self.kerberos_hostname_override = kerberos_hostname_override
self.proxies = {} if proxies is None else proxies

if self.server_cert_validation not in [None, 'validate', 'ignore']:
raise WinRMError('invalid server_cert_validation mode: %s' % self.server_cert_validation)
Expand Down Expand Up @@ -122,12 +124,12 @@ def build_session(self):

session.verify = self.server_cert_validation == 'validate'

# configure proxies from HTTP/HTTPS_PROXY envvars
# configure proxies from HTTP/HTTPS_PROXY envvars and from given proxy values
session.trust_env = True
settings = session.merge_environment_settings(url=self.endpoint, proxies={}, stream=None,
settings = session.merge_environment_settings(url=self.endpoint, proxies=self.proxies, stream=None,
verify=None, cert=None)

# we're only applying proxies from env, other settings are ignored
# Applying proxy settings
session.proxies = settings['proxies']

if self.auth_method == 'kerberos':
Expand Down

0 comments on commit f7131a5

Please sign in to comment.