[openstack-dev] [Horizon] Overrides to register/deregister panels and Menu Placements
Rahul Sharma
rahuls at juniper.net
Mon Jul 14 06:48:51 UTC 2014
Hi,
Our Networking panels are bit different from Stock Horizon. Until our blueprints are approved merged to Neutron/Horizon, we have created a separate package for our extra Horizon code and we register it to stock Horizon.
I am running into couple of issues here:
1. My Networking panels come under "Other" in menu. I want to bring them under "Manage Networking".
2. The menu items under other sometimes keep flipping their positions.
Can someone please help me with the API's required to add a menu item and add my panels under those. Also I am pasting snippet of my code, please let me know if there is a better way to fix this. Please note that at this moment I cannot modify base Horizon code. I am based of Havana.
Snippet for Menu/Panel registrations:
from django.utils.translation import ugettext_lazy as _
import horizon
from contrail_openstack_dashboard.openstack_dashboard.dashboards.project.networking.panel import Networking
from contrail_openstack_dashboard.openstack_dashboard.dashboards.admin.networking.panel import AdminNetworking
from contrail_openstack_dashboard.openstack_dashboard.dashboards.project.networking_topology.panel import NetworkingTopology
class NetworkingPanel(horizon.Panel):
name = "Networking"
slug = "networking"
urls = 'contrail_openstack_dashboard.openstack_dashboard.dashboards.project.networking.urls'
class AdminNetworkingPanel(horizon.Panel):
name = "Networking"
slug = "networking"
urls = 'contrail_openstack_dashboard.openstack_dashboard.dashboards.admin.networking.urls'
class NetworkingTopology(horizon.Panel):
name = _("Networking Topology")
slug = 'networking_topology'
urls = 'contrail_openstack_dashboard.openstack_dashboard.dashboards.project.networking_topology.urls'
try:
projects_dashboard = horizon.get_dashboard("project")
try:
topology_panel = projects_dashboard.get_panel("network_topology")
projects_dashboard.unregister(topology_panel.__class__)
except:
pass
try:
network_panel = projects_dashboard.get_panel("networks")
projects_dashboard.unregister(network_panel.__class__)
except:
pass
try:
routers_panel = projects_dashboard.get_panel("routers")
projects_dashboard.unregister(routers_panel.__class__)
except:
try:
lb_panel = projects_dashboard.get_panel("loadbalancers")
projects_dashboard.unregister(lb_panel.__class__)
except:
pass
except:
pass
try:
admin_dashboard = horizon.get_dashboard("admin")
try:
admin_net_panel = admin_dashboard.get_panel("networks")
admin_dashboard.unregister(admin_net_panel.__class__)
except:
pass
try:
admin_router_panel = admin_dashboard.get_panel("routers")
admin_dashboard.unregister(admin_router_panel.__class__)
except:
pass
except:
pass
My Panel definitions:
class Networking(horizon.Panel):
name = _("Networking")
slug = 'networking'
permissions = ('openstack.services.network',)
dashboard.Project.register(Networking)
[cid:9477E9A9-CAF6-4F43-9C36-B44ED1D9E11C] [cid:31018469-AEFE-4546-B43A-8CAE7D54FDA7]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140714/0e2c7a98/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2014-07-14 at 12.09.27 PM[1].png
Type: image/png
Size: 111663 bytes
Desc: Screen Shot 2014-07-14 at 12.09.27 PM[1].png
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140714/0e2c7a98/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2014-07-14 at 12.09.48 PM[1].png
Type: image/png
Size: 40069 bytes
Desc: Screen Shot 2014-07-14 at 12.09.48 PM[1].png
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140714/0e2c7a98/attachment-0003.png>
More information about the OpenStack-dev
mailing list