From 369f9fe4e053815477adb367140480f02ca357df Mon Sep 17 00:00:00 2001 From: Bin Yang Date: Tue, 11 Sep 2018 08:14:32 +0000 Subject: Return the default tenant in case of no privilege Change-Id: Ic4b2e6bb787ba4075a906e70c28ef42289255345 Issue-ID: MULTICLOUD-356 Signed-off-by: Bin Yang --- share/newton_base/proxy/services.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'share/newton_base/proxy/services.py') diff --git a/share/newton_base/proxy/services.py b/share/newton_base/proxy/services.py index 6aa1bbce..36ae9840 100644 --- a/share/newton_base/proxy/services.py +++ b/share/newton_base/proxy/services.py @@ -269,7 +269,28 @@ class GetTenants(Services): return Response(headers={'X-Subject-Token': tmp_auth_token}, data={'tenants': content['projects'],'tenants_links':[]}, status=resp.status_code) else: - return resp + viminfo = VimDriverUtils.get_vim_info(vimid) + session = VimDriverUtils.get_session( + viminfo, tenant_name=viminfo['tenant']) + 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'] + content = {'projects': [ + { + 'is_domain': False, + 'description': 'tenant info provisioned by VIM onborading', + 'enabled': True, + 'domain_id': viminfo['domain'], + 'parent_id': 'default', + 'id': tenant['id'], + 'name': tenant['name'] + } + ]} + return Response(headers={'X-Subject-Token': tmp_auth_token}, data={'tenants': content['projects'],'tenants_links':[]}, + status=status.HTTP_200_OK) + + # return resp def head(self, request, vimid="", servicetype="", requri=""): self._logger.warn("wrong request with vimid, servicetype, requri> %s,%s,%s" -- cgit 1.2.3-korg