diff options
author | 2019-12-17 03:06:39 +0000 | |
---|---|---|
committer | 2019-12-17 03:06:39 +0000 | |
commit | 34c5c84a17dee7a821eb1f3b18eadb0598150cdf (patch) | |
tree | 35fc2370d24ffdb87359113097f58ebcf3e01e55 /share/common/utils/restcall.py | |
parent | 01fce901541f9cc1cd79482ad5f54fc3c3b10256 (diff) |
Bypass cache for LCM of cloud region
Cache only the resource uri without query string.
Bypass the cache for LCM of a cloud region,which enhance the resilience
in case mismatch between AAI and cache
Change-Id: I57fd7981753d5959757401cea69f6fabd1874e25
Issue-ID: MULTICLOUD-968
Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share/common/utils/restcall.py')
-rw-r--r-- | share/common/utils/restcall.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/share/common/utils/restcall.py b/share/common/utils/restcall.py index 464dd65f..9e204564 100644 --- a/share/common/utils/restcall.py +++ b/share/common/utils/restcall.py @@ -139,11 +139,15 @@ def req_to_aai(resource, method, content='', appid=settings.MULTICLOUD_APP_ID, n # hook to flush cache if method.upper() in ["PUT", "POST", "PATCH", "DELETE"]: aai_cache.flush_cache_by_url(resource) - elif method.upper() in ["GET"] and not nocache: - content = aai_cache.get_cache_by_url(resource) - # logger.debug("cached resource: %s, %s" % (resource, content)) - if content: - return content + elif method.upper() in ["GET"]: + if not nocache: + content = aai_cache.get_cache_by_url(resource) + # logger.debug("cached resource: %s, %s" % (resource, content)) + if content: + return content + else: + # flush possible cached data blindly + aai_cache.flush_cache_by_url(resource) ret, resp_body, resp_status = _call_req( settings.AAI_BASE_URL, settings.AAI_USERNAME, settings.AAI_PASSWORD, rest_no_auth, |