Add InvalidLicense exception

This exception happens when the user's license expires on NSX and
a patch call is made. This is supported with NSX 3.1.0 and beyond

Change-Id: Ifb2dd824128720bd25d0053faab57cbbb6c7f04f
This commit is contained in:
Gautam Verma 2020-07-31 18:18:05 +00:00
parent 60ebf809d4
commit 849d2c0e5a
3 changed files with 9 additions and 1 deletions

View File

@ -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):

View File

@ -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}

View File

@ -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")