summaryrefslogtreecommitdiffstats
path: root/share/common/msapi/extsys.py
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2018-05-16 11:37:59 +0800
committerBin Yang <bin.yang@windriver.com>2018-05-16 11:37:59 +0800
commit2ab29f278f8a27d329fffe49a9feb065ca4abb61 (patch)
tree2ecff88ceb20d61a6ffc259e657995abc9e9ff74 /share/common/msapi/extsys.py
parentb1d581f77eee6b1a592518ac7dca81448974cc02 (diff)
Change the AAI call for query cloud region
This is to break the single AAI call into two to reduce the data exchanged in case cloud region assoicated with so many child objects Change-Id: I8d23764be1da82d8298f84cbe1a95427dc26c333 Issue-ID: MULTICLOUD-232 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share/common/msapi/extsys.py')
-rw-r--r--share/common/msapi/extsys.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/share/common/msapi/extsys.py b/share/common/msapi/extsys.py
index 99824ef2..626a38fc 100644
--- a/share/common/msapi/extsys.py
+++ b/share/common/msapi/extsys.py
@@ -24,8 +24,9 @@ def get_vim_by_id(vim_id):
cloud_owner,cloud_region_id = decode_vim_id(vim_id)
if cloud_owner and cloud_region_id:
+ # get cloud region without depth
retcode, content, status_code = \
- restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s?depth=1"
+ restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s"
% (cloud_owner,cloud_region_id),"GET")
if retcode != 0:
logger.error("Status code is %s, detail is %s.", status_code, content)
@@ -34,18 +35,20 @@ def get_vim_by_id(vim_id):
status_code, content)
tmp_viminfo = json.JSONDecoder().decode(content)
- #assume esr-system-info-id is composed by {cloud-owner} _ {cloud-region-id}
-# retcode2,content2,status_code2 = \
-# restcall.req_to_aai(("/cloud-infrastructure/cloud-regions/cloud-region/%(owner)s/%(region)s"
-# "/esr-system-info-list/esr-system-info/%(owner)s_%(region)s" % {
-# "owner": cloud_owner, "region": cloud_region_id}), "GET")
-# if retcode2 != 0:
-# logger.error("Status code is %s, detail is %s.", status_code, content)
-# raise VimDriverNewtonException(
-# "Failed to query ESR system with id (%s:%s,%s)." % (vim_id,cloud_owner,cloud_region_id),
-# status_code2, content2)
-# tmp_authinfo = json.JSONDecoder().decode(content2)
- tmp_authinfo = tmp_viminfo['esr-system-info-list']['esr-system-info'][0] if tmp_viminfo else None
+ # get esr-system-info under this cloud region
+ retcode2, content2, status_code2 = \
+ restcall.req_to_aai("/cloud-infrastructure/cloud-regions/cloud-region/%s/%s/esr-system-info-list"
+ % (cloud_owner,cloud_region_id),"GET")
+ if retcode2 != 0:
+ logger.error("Status code is %s, detail is %s.", status_code2, content2)
+ raise VimDriverNewtonException(
+ "Failed to query esr info for VIM with id (%s:%s,%s)." % (vim_id,cloud_owner,cloud_region_id),
+ status_code2, content2)
+ tmp_authinfo = json.JSONDecoder().decode(content2)
+
+ # get the first auth info by default
+ tmp_authinfo = tmp_authinfo['esr-system-info'][0] if tmp_authinfo \
+ and tmp_authinfo.get('esr-system-info', None) else None
#convert vim information
if tmp_viminfo and tmp_authinfo: