From a4a11df7e2cb470f6080f518780e061cfae6bf1e Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Sun, 25 Mar 2018 12:28:38 +0300 Subject: [PATCH] Add exception for policy deleted objects For the NSX policy manager, if an object was deleted, it cannot be recreated immediately with the same name/path, and should wait until it is permanently deleted from the backend. This patch adds the error code and exception for this case. Change-Id: Icaa41ada29209b476963a8cee4362f211ef02c66 --- vmware_nsxlib/v3/client.py | 3 ++- vmware_nsxlib/v3/exceptions.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/vmware_nsxlib/v3/client.py b/vmware_nsxlib/v3/client.py index 8f4234e4..fb5d5339 100644 --- a/vmware_nsxlib/v3/client.py +++ b/vmware_nsxlib/v3/client.py @@ -35,7 +35,8 @@ def http_error_to_exception(status_code, error_code): {'202': exceptions.BackendResourceNotFound, 'default': exceptions.ResourceNotFound}, requests.codes.BAD_REQUEST: - {'60508': exceptions.NsxIndexingInProgress}, + {'60508': exceptions.NsxIndexingInProgress, + '500045': exceptions.NsxPendingDelete}, requests.codes.CONFLICT: exceptions.StaleRevision, requests.codes.PRECONDITION_FAILED: exceptions.StaleRevision, requests.codes.INTERNAL_SERVER_ERROR: diff --git a/vmware_nsxlib/v3/exceptions.py b/vmware_nsxlib/v3/exceptions.py index dad5a150..749c8ebd 100644 --- a/vmware_nsxlib/v3/exceptions.py +++ b/vmware_nsxlib/v3/exceptions.py @@ -145,3 +145,9 @@ class NsxSearchInvalidQuery(NsxLibException): class NsxIndexingInProgress(NsxLibException): message = _("Bad Request due to indexing is in progress, please retry " "after sometime") + + +class NsxPendingDelete(NsxLibException): + message = _("An object with the same name is marked for deletion. Either " + "use another path or wait for the purge cycle to permanently " + "remove the deleted object")