From ea8317083b42d4e8fdf8f729b26d3d408f326b82 Mon Sep 17 00:00:00 2001 From: Daryl Walleck Date: Wed, 23 Apr 2014 23:46:53 -0500 Subject: [PATCH] Added error handling for WinRM connections * Added handling for WinRMTransportErrors on initial connections Change-Id: I47f7fafe6d8e8071041cdde7f0578b3acbdfa67d --- cafe/engine/clients/winrm_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cafe/engine/clients/winrm_client.py b/cafe/engine/clients/winrm_client.py index fbd66e1..d7befc4 100644 --- a/cafe/engine/clients/winrm_client.py +++ b/cafe/engine/clients/winrm_client.py @@ -18,6 +18,7 @@ import time # WinRM package is not currently pip installable, so will not expect # it be installed unless explicitly needed try: + from winrm.exceptions import WinRMTransportError from winrm.protocol import Protocol except: raise Exception("Dependency 'winrm' missing.") @@ -158,7 +159,10 @@ class WinRMClient(BaseWinRMClient): '{retries} to {host}.'.format( iteration=iteration, retries=retries, 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(): return True time.sleep(cooldown)