Getting a extra details from the keystone project table using keystone client.

asked 2016-05-11 22:33:32 -0500

itsme gravatar image

updated 2016-05-11 23:31:46 -0500

I have implemented the following code for getting the extra details from the keystone project table using keystone client.

from openstack_dashboard import api as napi
from openstack_dashboard.api import keystone

.
.
.

        tenant =  napi.keystone.tenant_get(self.request, request.user.tenant_id)
        self.tenant_timezone = tenant.__dict__.get("timezone")

But this seems to be working fine for the user having admin role.

But this doesn't working fine for user who doesn't have admin role.

Giving the error which is as follows:

2016-05-12 03:19:29.506673 tenant id get over
2016-05-12 03:19:29.507766 Unauthorized: 
2016-05-12 03:19:29.507795 Traceback (most recent call last):
2016-05-12 03:19:29.507803   File "/opt/stack/horizon/openstack_dashboard/wsgi/../../horizon/views.py", line 101, in get
2016-05-12 03:19:29.507810     context = self.get_data(request, context, *args, **kwargs)
2016-05-12 03:19:29.507817   File "/opt/stack/cloudkitty-dashboard/cloudkittydashboard/dashboards/project/rating/views.py", line 118, in get_data
2016-05-12 03:19:29.507823     tenant =  napi.keystone.tenant_get(self.request, request.user.tenant_id)
2016-05-12 03:19:29.507829   File "/opt/stack/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/api/keystone.py", line 253, in tenant_get
2016-05-12 03:19:29.507836     manager = VERSIONS.get_project_manager(request, admin=admin)
2016-05-12 03:19:29.507842   File "/opt/stack/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/api/keystone.py", line 56, in get_project_manager
2016-05-12 03:19:29.507848     manager = keystoneclient(*args, **kwargs).tenants
2016-05-12 03:19:29.507854   File "/opt/stack/horizon/openstack_dashboard/wsgi/../../openstack_dashboard/api/keystone.py", line 150, in keystoneclient
2016-05-12 03:19:29.507860     raise exceptions.NotAuthorized
2016-05-12 03:19:29.507866 NotAuthorized

I can be able to see that in horizon , keystone connection api has function which will allow only admin user to get the details.

def tenant_get(request, project, admin=True):
    manager = VERSIONS.get_project_manager(request, admin=admin)
    return manager.get(project)

How I can make that tenant can be able to get the extra details.

Someone look and let me know your comments.

edit retag flag offensive close merge delete