diff options
Diffstat (limited to 'share/common/msapi/extsys.py')
-rw-r--r-- | share/common/msapi/extsys.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/share/common/msapi/extsys.py b/share/common/msapi/extsys.py index e1534523..9b65072e 100644 --- a/share/common/msapi/extsys.py +++ b/share/common/msapi/extsys.py @@ -12,6 +12,7 @@ import json import logging import re +from django.core.cache import cache from common.exceptions import VimDriverNewtonException from common.utils import restcall @@ -22,6 +23,12 @@ logger = logging.getLogger(__name__) def get_vim_by_id(vim_id): + # try to load from cache + cachedviminfostr = cache.get("VIMINFOCACHE_"+vim_id) + if cachedviminfostr: + viminfo = json.loads(cachedviminfostr) + return viminfo + cloud_owner,cloud_region_id = decode_vim_id(vim_id) if cloud_owner and cloud_region_id: @@ -74,6 +81,8 @@ def get_vim_by_id(vim_id): viminfo['openstack_region_id'] = tmp_viminfo.get("cloud-epa-caps") \ if tmp_viminfo.get("cloud-epa-caps") else cloud_region_id + # cache the viminfo for 24 hour + cache.set("VIMINFOCACHE_"+vim_id, json.dumps(viminfo), 3600*24) return viminfo return None |