diff options
author | fujinhua <fu.jinhua@zte.com.cn> | 2018-11-24 13:16:40 +0800 |
---|---|---|
committer | Fu Jinhua <fu.jinhua@zte.com.cn> | 2018-11-24 05:25:26 +0000 |
commit | 097605916d5fc2d8bec4629838657f2b50f1753c (patch) | |
tree | cc1fff04efa1c438fae10fb22e59eb24ad9e33d6 | |
parent | 83fd23578ce2b5accee89a7cd6441c8e37b88f59 (diff) |
Add retry when delete vim res failed
Change-Id: Iab5c6783fa6cc89761b72972b080ad3554455c64
Issue-ID: VFC-1163
Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
(cherry picked from commit 962b48bfee74f301000b2afae937dcb45ab9ec1c)
-rw-r--r-- | lcm/lcm/pub/vimapi/api.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lcm/lcm/pub/vimapi/api.py b/lcm/lcm/pub/vimapi/api.py index 1679a564..b46bbf4b 100644 --- a/lcm/lcm/pub/vimapi/api.py +++ b/lcm/lcm/pub/vimapi/api.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import time from multiprocessing import Lock from lcm.pub.msapi.aai import delete_aai_flavor @@ -32,10 +33,14 @@ def call(vim_id, tenant_id, res, method, data=''): vim_id=vim_id, tenant_id="/" + tenant_id if tenant_id else "", res=res) - ret = req_by_msb(url, method, data) - if ret[0] > 0: - raise VimException(ret[1], ret[2]) - return json.JSONDecoder().decode(ret[1]) if ret[1] else {} + for i in range(10): + ret = req_by_msb(url, method, data) + if ret[0] > 0: + if ret[2] == '409' and "InUse" in ret[1] and method == "DELETE": + time.sleep(5) + continue + raise VimException(ret[1], ret[2]) + return json.JSONDecoder().decode(ret[1]) if ret[1] else {} ###################################################################### |