Browse Source

Merge pull request #136 from aznashwan/conn-validation-error

Handle any connection validation errors in the worker.
Nashwan Azhari 5 năm trước cách đây
mục cha
commit
4be676de00
2 tập tin đã thay đổi với 8 bổ sung1 xóa
  1. 5 0
      coriolis/worker/rpc/server.py
  2. 3 1
      coriolis/wsman.py

+ 5 - 0
coriolis/worker/rpc/server.py

@@ -485,6 +485,11 @@ class WorkerServerEndpoint(object):
         except exception.ConnectionValidationException as ex:
             is_valid = False
             message = str(ex)
+        except Exception as ex:
+            is_valid = False
+            message = (
+                "An unexpected connection validation exception "
+                "ocurred: %s" % str(ex))
 
         return (is_valid, message)
 

+ 3 - 1
coriolis/wsman.py

@@ -5,6 +5,7 @@ import base64
 
 from oslo_log import log as logging
 from winrm import protocol
+from winrm import exceptions as winrm_exceptions
 
 from coriolis import exception
 from coriolis import utils
@@ -50,7 +51,8 @@ class WSManConnection(object):
     def disconnect(self):
         self._protocol = None
 
-    @utils.retry_on_error()
+    @utils.retry_on_error(
+        terminal_exceptions=[winrm_exceptions.InvalidCredentialsError])
     def _exec_command(self, cmd, args=[]):
         shell_id = self._protocol.open_shell(codepage=CODEPAGE_UTF8)
         try: