diff --git a/vmware_nsxlib/v3/client.py b/vmware_nsxlib/v3/client.py index e1a1e05e..d5ea849f 100644 --- a/vmware_nsxlib/v3/client.py +++ b/vmware_nsxlib/v3/client.py @@ -46,7 +46,8 @@ def http_error_to_exception(status_code, error_code): requests.codes.CONFLICT: exceptions.StaleRevision, requests.codes.PRECONDITION_FAILED: exceptions.StaleRevision, requests.codes.INTERNAL_SERVER_ERROR: - {'99': exceptions.ClientCertificateNotTrusted, + {'98': exceptions.CannotConnectToServer, + '99': exceptions.ClientCertificateNotTrusted, '607': exceptions.APITransactionAborted}, requests.codes.FORBIDDEN: {'98': exceptions.BadXSRFToken}, @@ -323,7 +324,9 @@ class NSX3Client(JSONRESTClient): def _rest_call(self, url, **kwargs): if kwargs.get('with_retries', True): # Retry on "607: Persistence layer is currently reconfiguring" - retry_codes = [exceptions.APITransactionAborted] + # and on "98: Cannot connect to server" + retry_codes = [exceptions.APITransactionAborted, + exceptions.CannotConnectToServer] if self.rate_limit_retry: # If too many requests are handled by the nsx at the same time, # error "429: Too Many Requests" or "503: Server Unavailable" diff --git a/vmware_nsxlib/v3/exceptions.py b/vmware_nsxlib/v3/exceptions.py index 72984c70..0ef65ccf 100644 --- a/vmware_nsxlib/v3/exceptions.py +++ b/vmware_nsxlib/v3/exceptions.py @@ -216,10 +216,14 @@ class NsxOverlapVlan(NsxLibInvalidInput): "physical devices resulting in a conflict") -class APITransactionAborted(ServerBusy): +class APITransactionAborted(ManagerError): message = _("API transaction aborted as MP cluster is reconfiguring") +class CannotConnectToServer(ManagerError): + message = _("Cannot connect to server") + + class ResourceInUse(ManagerError): message = _("The object cannot be deleted as either it has children or it " "is being referenced by other objects")