Merge "Added error handling for WinRM connections"
This commit is contained in:
@@ -18,6 +18,7 @@ import time
|
|||||||
# WinRM package is not currently pip installable, so will not expect
|
# WinRM package is not currently pip installable, so will not expect
|
||||||
# it be installed unless explicitly needed
|
# it be installed unless explicitly needed
|
||||||
try:
|
try:
|
||||||
|
from winrm.exceptions import WinRMTransportError
|
||||||
from winrm.protocol import Protocol
|
from winrm.protocol import Protocol
|
||||||
except:
|
except:
|
||||||
raise Exception("Dependency 'winrm' missing.")
|
raise Exception("Dependency 'winrm' missing.")
|
||||||
@@ -158,7 +159,10 @@ class WinRMClient(BaseWinRMClient):
|
|||||||
'{retries} to {host}.'.format(
|
'{retries} to {host}.'.format(
|
||||||
iteration=iteration, retries=retries,
|
iteration=iteration, retries=retries,
|
||||||
host=self.host))
|
host=self.host))
|
||||||
self.connect(username=self.username, password=self.password)
|
try:
|
||||||
|
self.connect(username=self.username, password=self.password)
|
||||||
|
except WinRMTransportError as exception:
|
||||||
|
self._log.error(exception.message)
|
||||||
if self.is_connected():
|
if self.is_connected():
|
||||||
return True
|
return True
|
||||||
time.sleep(cooldown)
|
time.sleep(cooldown)
|
||||||
|
|||||||
Reference in New Issue
Block a user