summaryrefslogtreecommitdiffstats
path: root/share/newton_base/registration
diff options
context:
space:
mode:
authorYun Huang <yun.huang@windriver.com>2018-06-04 09:57:45 +0800
committerYun Huang <yun.huang@windriver.com>2018-06-04 10:02:40 +0800
commit38f78f4fdf3874ca780f12ab1816650476013d3a (patch)
treeca7ef9f2855a73357961400a01a029cb134662be /share/newton_base/registration
parent889735bc51e90217ea6540ecc5d62337434cff6c (diff)
Fix registration limitation on tenant discovery
Populate the tenant information from token response Change-Id: I52092d2c3021f54b4b6915373f14e4f45547f6d5 Issue-ID: MULTICLOUD-168 Signed-off-by: Yun Huang <yun.huang@windriver.com>
Diffstat (limited to 'share/newton_base/registration')
-rw-r--r--share/newton_base/registration/registration.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/share/newton_base/registration/registration.py b/share/newton_base/registration/registration.py
index 67004390..4e536b8b 100644
--- a/share/newton_base/registration/registration.py
+++ b/share/newton_base/registration/registration.py
@@ -126,7 +126,27 @@ class Registry(APIView):
self._logger.error("VimDriverNewtonException: status:%s, response:%s" % (e.http_status, e.content))
return
except HttpError as e:
- self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
+ if e.http_status == status.HTTP_403_FORBIDDEN:
+ ### get the tenant information from the token response
+ try:
+ ### get tenant info from the session
+ tmp_auth_state = VimDriverUtils.get_auth_state(session)
+ tmp_auth_info = json.loads(tmp_auth_state)
+ tmp_auth_data = tmp_auth_info['body']
+ tenant = tmp_auth_data['token']['project']
+ tenant_info = {
+ 'tenant-id': tenant['id'],
+ 'tenant-name': tenant['name'],
+ }
+
+ self._update_resoure(
+ cloud_owner, cloud_region_id, tenant['id'],
+ tenant_info, "tenant")
+
+ except Exception as ex:
+ self._logger.error(traceback.format_exc())
+ else:
+ self._logger.error("HttpError: status:%s, response:%s" % (e.http_status, e.response.json()))
return
except Exception as e:
self._logger.error(traceback.format_exc())