How to add new dashboard on Horizon?

Asked by cheng jia su

Hello,

I write _init_.py, dashboard.py, models.py and some codes to create dashboard and panel.
This is document I refer : http://docs.openstack.org/developer/horizon/topics/tutorial.html

But I don't know how to make my dashboard show on webpage.

Question information

Language:
English Edit question
Status:
Answered
For:
OpenStack Dashboard (Horizon) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
David Lyle (david-lyle) said :
#1

Your new dashboard needs to also be referenced in the settings file. See: http://docs.openstack.org/developer/horizon/topics/tutorial.html#the-settings-file

Revision history for this message
cheng jia su (chengjia-su) said :
#2

I add my dashboard in /usr/share/openstack-dashboard/openstack_dashboard/settings.py HORIZON_CONFIG
but, when I restart apache2, I got error message in log file:

[Tue Aug 06 16:01:34 2013] [error] [client 1.168.150.54] File does not exist: /var/www/favicon.ico
[Tue Aug 06 08:01:34 2013] [error] [client 1.168.150.54] mod_wsgi (pid=5162): Exception occurred processing WSGI script '/usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi'.
[Tue Aug 06 08:01:34 2013] [error] [client 1.168.150.54] Traceback (most recent call last):
[Tue Aug 06 08:01:34 2013] [error] [client 1.168.150.54] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
[Tue Aug 06 08:01:34 2013] [error] [client 1.168.150.54] self.load_middleware()
[Tue Aug 06 08:01:34 2013] [error] [client 1.168.150.54] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 47, in load_middleware
[Tue Aug 06 08:01:34 2013] [error] [client 1.168.150.54] raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
[Tue Aug 06 08:01:34 2013] [error] [client 1.168.150.54] ImproperlyConfigured: Error importing middleware horizon.middleware: "No module named ids"
[Tue Aug 06 16:01:34 2013] [error] [client 1.168.150.54] File does not exist: /var/www/favicon.ico

Revision history for this message
David Lyle (david-lyle) said :
#3

There are two places where it needs to be added in the settings file... This first place is in HORIZON_CONFIG, the second is in INSTALLED_APPS. This is also detailed in the above link.

Revision history for this message
cheng jia su (chengjia-su) said :
#4

I also add my dashboard in INSTALLED_APPS. like this:

INSTALLED_APPS = (
    'openstack_dashboard',
    'django.contrib.contenttypes',
    'django.contrib.auth',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.humanize',
    'compressor',
    'horizon',
    'openstack_dashboard.dashboards.project',
    'openstack_dashboard.dashboards.admin',
    'openstack_dashboard.dashboards.settings',
    'openstack_auth',
    'openstack_dashboard.dashboards.ids',
)

Revision history for this message
David Lyle (david-lyle) said :
#5

At this point, it is difficult to diagnose from the information given. There are several possible problems, but without access to your directory structure and source. The circular registration between the panel and the dashboard, a urls.py issue, whether __init__.py has two underscores or one. I would suggest hopping in the #openstack-horizon IRC room https://wiki.openstack.org/wiki/IRC and seek more interactive help there.

Revision history for this message
Lin Hua Cheng (lin-hua-cheng) said :
#6

Did you register the new dashboard after adding the code?

From the tutorial:

"Once our dashboard class is complete, all we need to do is register it:

    horizon.register(VizDash)
The typical place for that would be the bottom of the dashboard.py file, but it could also go elsewhere."

Revision history for this message
cheng jia su (chengjia-su) said :
#7

I add it in bottom of my dashboard.py

from django.utils.translation import ugettext_lazy as _
import horizon

class TestPanels(horizon.PanelGroup):
    slug = "intrusion_detection"
    name = _("Intrusion detection system")
    panels = ('test',)

class Ids(horizon.Dashboard):
    name = _("IDS")
    slug = "ids"
    panels = (TestPanels,)
    default_panel = 'test'
    permissions = ('openstack.roles.admin',)

horizon.register(Ids)

Revision history for this message
Lin Hua Cheng (lin-hua-cheng) said :
#8

Try adding some debug to validate if the dashboard is being loaded.

I wonder if the fourth dashboard is not showing up due to the limited space in the tabbed menu, also try hitting the dashboard url directly for the new dashboard.

Is there a folder /usr/share/pyshared/openstack_dashboard in your directory? If yes, you need to put the code in there to be accessible from Python path.

Can you help with this problem?

Provide an answer of your own, or ask cheng jia su for more information if necessary.

To post a message you must log in.