summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorMark Vanderwiel <vanderwl@us.ibm.com>2016-01-28 10:52:45 -0600
committerMark Vanderwiel <vanderwl@us.ibm.com>2016-01-28 10:52:45 -0600
commit5903ffff8a56481e124aa4fe8144c16348f6f8b9 (patch)
treeb9455bb9f4bd06bf4e4465472a303954d44a326f /openstackclient/common
parent636b4de6df77923424f7cac62322b546d65a5269 (diff)
downloadpython-openstackclient-5903ffff8a56481e124aa4fe8144c16348f6f8b9.tar.gz
Allow wait_for_delete to work for all clients
Allow the exception and error status strings to be passed in such that other plugins can make use of this function. There is a comment in find_resource: The exception to catch here is dependent on which client library the manager passed in belongs to. Eventually this should be pulled from a common set of client exceptions. Since I think that is a long ways off, this change will work now and also work when a common exception is defined and used. Change-Id: Iab56cd1166028caed4f1e657e0b1ee81af3f48d8
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/utils.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py
index 3ae30c8f..2860608d 100644
--- a/openstackclient/common/utils.py
+++ b/openstackclient/common/utils.py
@@ -331,6 +331,8 @@ def wait_for_status(status_f,
def wait_for_delete(manager,
res_id,
status_field='status',
+ error_status=['error'],
+ exception_name=['NotFound'],
sleep_time=5,
timeout=300,
callback=None):
@@ -341,6 +343,8 @@ def wait_for_delete(manager,
:param status_field: the status attribute in the returned resource object,
this is used to check for error states while the resource is being
deleted
+ :param error_status: a list of status strings for error
+ :param exception_name: a list of exception strings for deleted case
:param sleep_time: wait this long between checks (seconds)
:param timeout: check until this long (seconds)
:param callback: called per sleep cycle, useful to display progress; this
@@ -357,12 +361,12 @@ def wait_for_delete(manager,
# handle a NotFound exception here without parsing the message
res = manager.get(res_id)
except Exception as ex:
- if type(ex).__name__ == 'NotFound':
+ if type(ex).__name__ in exception_name:
return True
raise
status = getattr(res, status_field, '').lower()
- if status == 'error':
+ if status in error_status:
return False
if callback: