1.request.user.roles:
[{u'id': u'1b0f1d4d68754c76a279bb45ba2763e6', u'name': u'admin'}, {u'id': u'99c59f8c1f0a450e8bcaf527169afc5e', u'name': u'KeystoneAdmin'}, {u'id': u'776129c80a2b4745b8b3cd5e940ebb2a', u'name': u'KeystoneServiceAdmin'}]
roles = set([role['name'].lower() for role in request.user.roles])
roles:
set([u'admin', u'keystoneadmin', u'keystoneserviceadmin'])
set([u'admin', u'keystoneadmin', u'keystoneserviceadmin'])
2.view_func._required_roles
set(['admin'])
/horizon/dashboard/nova/dashboard.py
from django.utils.translation import ugettext_lazy as _
import horizon
class SystemPanels(horizon.PanelGroup):
slug = "syspanel"
#name = _("System Panel")
panels = ('overview', 'hosts','instances', 'services', 'flavors', 'images',
'projects', 'users', 'quotas',)
class Syspanel(horizon.Dashboard):
name = _("Admin")
slug = "syspanel"
panels = (SystemPanels,)
default_panel = 'overview'
roles = ('admin',)
#权限,如果是用户就写member 如果admin和member同时拥有此权限不管作用(‘admin’, 'member',)
permissions = ('openstack.roles.admin','my.other.perm,isstion',)
#不起作用 参考:http://docs.openstack.org/developer/horizon/quickstart.html
nav = True
# Optional boolean to control whether or not this dashboard should appear in automatically-generated navigation. Default: True.
#参考:http://docs.openstack.org/developer/horizon/api/horizon.base.html?highlight=dashboard#horizon.base.Dashboard #/horizon/dashboard/setting 不显示就是应为设置了nav = False
supports_tenants = True;
horizon.register(Syspanel)