From 00167c1cb1e235395e5f4b76b969f12c6297f173 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Mon, 6 May 2019 15:32:39 +0300 Subject: [PATCH] Add exception for deleting an object in use Change-Id: I636fda84ac8d273d83f6682fd7adb472ac0ae0ba --- vmware_nsxlib/v3/client.py | 3 ++- vmware_nsxlib/v3/exceptions.py | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vmware_nsxlib/v3/client.py b/vmware_nsxlib/v3/client.py index d088cd1c..c9047251 100644 --- a/vmware_nsxlib/v3/client.py +++ b/vmware_nsxlib/v3/client.py @@ -37,7 +37,8 @@ def http_error_to_exception(status_code, error_code): requests.codes.BAD_REQUEST: {'60508': exceptions.NsxIndexingInProgress, '60514': exceptions.NsxSearchTimeout, - '500045': exceptions.NsxPendingDelete}, + '500045': exceptions.NsxPendingDelete, + '500030': exceptions.ResourceInUse}, 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 d8292ac2..f74547ec 100644 --- a/vmware_nsxlib/v3/exceptions.py +++ b/vmware_nsxlib/v3/exceptions.py @@ -196,4 +196,9 @@ class NsxPendingDelete(NsxLibException): class APITransactionAborted(ServerBusy): - message = _("API transaction aborted as MP cluster is reconfiguring.") + message = _("API transaction aborted as MP cluster is reconfiguring") + + +class ResourceInUse(ManagerError): + message = _("The object cannot be deleted as either it has children or it " + "is being referenced by other objects")