diff --git a/vmware_nsxlib/tests/unit/v3/test_client.py b/vmware_nsxlib/tests/unit/v3/test_client.py index 05d04d78..a698a65b 100644 --- a/vmware_nsxlib/tests/unit/v3/test_client.py +++ b/vmware_nsxlib/tests/unit/v3/test_client.py @@ -314,6 +314,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(requests.codes.FORBIDDEN, 505) + self.assertEqual(exc, nsxlib_exc.InvalidLicense) + class NsxV3JSONClientTestCase(nsxlib_testcase.NsxClientTestCase): diff --git a/vmware_nsxlib/v3/client.py b/vmware_nsxlib/v3/client.py index 96031aab..f411bf15 100644 --- a/vmware_nsxlib/v3/client.py +++ b/vmware_nsxlib/v3/client.py @@ -92,7 +92,8 @@ def http_error_to_exception(status_code, error_code): '607': exceptions.APITransactionAborted}, requests.codes.FORBIDDEN: {'98': exceptions.BadXSRFToken, - '403': exceptions.InvalidCredentials}, + '403': exceptions.InvalidCredentials, + '505': exceptions.InvalidLicense}, requests.codes.TOO_MANY_REQUESTS: exceptions.TooManyRequests, requests.codes.SERVICE_UNAVAILABLE: exceptions.ServiceUnavailable} diff --git a/vmware_nsxlib/v3/exceptions.py b/vmware_nsxlib/v3/exceptions.py index d4401121..30bed5ee 100644 --- a/vmware_nsxlib/v3/exceptions.py +++ b/vmware_nsxlib/v3/exceptions.py @@ -155,6 +155,10 @@ class InvalidCredentials(ManagerError): message = _("Failed to authenticate with NSX: %(msg)s") +class InvalidLicense(ManagerError): + message = _("No valid License to configure NSX resources: %(msg)s") + + class BadJSONWebTokenProviderRequest(NsxLibException): message = _("Bad or expired JSON web token request from provider: %(msg)s")