From 787dbca5b34310c3aed260c66b43e439fca90713 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 30 Aug 2021 01:48:54 -0700 Subject: [PATCH] Add MP610 error code to retryable errors Erro code 610 is thrown when a NSX transaction is stopped. The transaction should be retried by the client. This change ensures erro 610 is handled with APITransactionAborted exception and therefore retried. Change-Id: Ice1d712f78ffb5e9ea12fc485e3d4ac52167f678 --- vmware_nsxlib/tests/unit/v3/test_client.py | 3 +++ vmware_nsxlib/v3/client.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/vmware_nsxlib/tests/unit/v3/test_client.py b/vmware_nsxlib/tests/unit/v3/test_client.py index c2836f93..fce1aebf 100644 --- a/vmware_nsxlib/tests/unit/v3/test_client.py +++ b/vmware_nsxlib/tests/unit/v3/test_client.py @@ -315,6 +315,9 @@ class NsxV3RESTClientTestCase(nsxlib_testcase.NsxClientTestCase): exc = client.http_error_to_exception(500, 607) self.assertEqual(exc, nsxlib_exc.APITransactionAborted) + exc = client.http_error_to_exception(500, 610) + self.assertEqual(exc, nsxlib_exc.APITransactionAborted) + exc = client.http_error_to_exception(requests.codes.FORBIDDEN, 505) self.assertEqual(exc, nsxlib_exc.InvalidLicense) diff --git a/vmware_nsxlib/v3/client.py b/vmware_nsxlib/v3/client.py index 31918402..55ca03cc 100644 --- a/vmware_nsxlib/v3/client.py +++ b/vmware_nsxlib/v3/client.py @@ -98,7 +98,8 @@ def http_error_to_exception(status_code, error_code, related_error_codes=None): requests.codes.INTERNAL_SERVER_ERROR: {'98': exceptions.CannotConnectToServer, '99': exceptions.ClientCertificateNotTrusted, - '607': exceptions.APITransactionAborted}, + '607': exceptions.APITransactionAborted, + '610': exceptions.APITransactionAborted}, requests.codes.FORBIDDEN: {'98': exceptions.BadXSRFToken, '403': exceptions.InvalidCredentials,