summaryrefslogtreecommitdiffstats
path: root/share/common/msapi/extsys.py
diff options
context:
space:
mode:
authorBin Yang <bin.yang@windriver.com>2020-02-27 22:22:47 +0800
committerBin Yang <bin.yang@windriver.com>2020-02-28 00:41:29 +0800
commitd41752458f677c7c1c5cd9b5a9c4af1990d116e8 (patch)
tree9faf3b251d0b293c8aba00887a78c2525c5bacad /share/common/msapi/extsys.py
parent12edd5178689ee14c39198c843a1b622755a4470 (diff)
Populate system info into cloud-extra-info
Change-Id: I9480169439d340fedf5b01fe03d6a8e2f3db8fcb Issue-ID: MULTICLOUD-830 Signed-off-by: Bin Yang <bin.yang@windriver.com>
Diffstat (limited to 'share/common/msapi/extsys.py')
-rw-r--r--share/common/msapi/extsys.py33
1 files changed, 19 insertions, 14 deletions
diff --git a/share/common/msapi/extsys.py b/share/common/msapi/extsys.py
index 88118aa8..49a2d321 100644
--- a/share/common/msapi/extsys.py
+++ b/share/common/msapi/extsys.py
@@ -46,13 +46,12 @@ def get_vim_by_id(vim_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:
+ if tmp_viminfo and tmp_authinfo and tmp_authinfo.get('esr-system-info'):
viminfo = {}
+ # get the first auth info by default
+ tmp_authinfo = tmp_authinfo['esr-system-info'][0]
+
viminfo['vimId'] = vim_id
viminfo['resource-version'] = tmp_viminfo.get('resource-version')
viminfo['cloud_owner'] = cloud_owner
@@ -62,16 +61,22 @@ def get_vim_by_id(vim_id):
viminfo['version'] = tmp_viminfo.get('cloud-region-version')
viminfo['cloud_extra_info'] = tmp_viminfo.get('cloud-extra-info')
- viminfo['userName'] = tmp_authinfo['user-name']
- viminfo['password'] = tmp_authinfo['password']
- viminfo['domain'] = tmp_authinfo.get('cloud-domain')
- viminfo['url'] = tmp_authinfo.get('service-url')
- viminfo['tenant'] = tmp_authinfo.get('default-tenant')
- viminfo['cacert'] = tmp_authinfo.get('ssl-cacert')
- viminfo['insecure'] = tmp_authinfo.get('ssl-insecure')
+ viminfo['userName'] = tmp_authinfo.get('user-name', "")
+ viminfo['password'] = tmp_authinfo.get('password', "")
+ viminfo['domain'] = tmp_authinfo.get('cloud-domain', "")
+ viminfo['url'] = tmp_authinfo.get('service-url', "")
+ viminfo['tenant'] = tmp_authinfo.get('default-tenant', "")
+ viminfo['cacert'] = tmp_authinfo.get('ssl-cacert', "")
+ viminfo['insecure'] = tmp_authinfo.get('ssl-insecure', True)
viminfo["complex-name"] = tmp_viminfo.get("complex-name")
- viminfo['openstack_region_id'] = tmp_viminfo.get("cloud-epa-caps") \
- if tmp_viminfo.get("cloud-epa-caps") else cloud_region_id
+ # move the openstack region id store location, but keep backward compatibility
+ viminfo['openstack_region_id'] = tmp_authinfo.get("openstack-region-id") \
+ or tmp_viminfo.get("cloud-epa-caps", cloud_region_id)
+ try:
+ viminfo['cloud_extra_info_json'] = json.loads(
+ viminfo.get('cloud_extra_info', {}))
+ except Exception:
+ pass
return viminfo
return None