Adding a column to horizon instances table

asked 2014-12-01 09:39:21 -0500

Taliesyn gravatar image

Greetings,

we are in the process setting up an Openstack platform for internal use, and I would like to add some information to the instances table, namely the external FQDN associated with the instance's floating IP (if present, obviously).

My first idea was to override the InstancesTable class to add that column, but I'm having trouble with that (probably related to my being a complete python/django newbie). I can manipulate the column order through the Meta class just fine, but trying to add a column yields the following error :

AttributeError: 'module' object has no attribute 'Column'

Here's my override code :

from django.utils.translation import ugettext_lazy as _
from horizon import tables
from openstack_dashboard.dashboards.project.instances import tables
from openstack_dashboard.dashboards.project.instances import views

class MyInstancesTable(tables.InstancesTable):
    pubname = tables.Column("pubname", 
                                verbose_name=_("Public name"))

views.IndexView.table_class = MyInstancesTable

So, my questions, in order, are : - is extending the default instances table the best way to achieve my goals, or should I create a brand new data table? - what am I missing with this table override?

Thanks in advance,

Dan.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-12-04 03:09:26 -0500

teju gravatar image

updated 2014-12-04 03:12:01 -0500

Hi. Please try the below code and let me know if it is working fine.

http://pastebin.com/sieghZkd

edit flag offensive delete link more

Comments

So I finally got time to get back to this subject, and your code worked with a small change, thanks. I merely had to use a different name for the 'tables' from horizon, maybe it's just an ordering problem.

Here's my working code : http://pastebin.com/k9LD0u8z

Taliesyn gravatar imageTaliesyn ( 2015-01-07 03:26:20 -0500 )edit
0

answered 2014-12-08 02:03:24 -0500

Taliesyn gravatar image

Hey, and thanks for your answer. Unfortunately, I still get an error :

[Mon Dec 08 08:59:18.218485 2014] [:error] [pid 26866] Internal Server Error: /dashboard/project/instances/
[Mon Dec 08 08:59:18.218591 2014] [:error] [pid 26866] Traceback (most recent call last):
[Mon Dec 08 08:59:18.218485 2014] [:error] [pid 26866] Internal Server Error: /dashboard/project/instances/
[Mon Dec 08 08:59:18.218591 2014] [:error] [pid 26866] Traceback (most recent call last):
[Mon Dec 08 08:59:18.218598 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 112, in get_response
[Mon Dec 08 08:59:18.218602 2014] [:error] [pid 26866]     response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Mon Dec 08 08:59:18.218606 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/horizon/decorators.py", line 36, in dec
[Mon Dec 08 08:59:18.218624 2014] [:error] [pid 26866]     return view_func(request, *args, **kwargs)
[Mon Dec 08 08:59:18.218629 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/horizon/decorators.py", line 52, in dec
[Mon Dec 08 08:59:18.218632 2014] [:error] [pid 26866]     return view_func(request, *args, **kwargs)
[Mon Dec 08 08:59:18.218636 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/horizon/decorators.py", line 36, in dec
[Mon Dec 08 08:59:18.218639 2014] [:error] [pid 26866]     return view_func(request, *args, **kwargs)
[Mon Dec 08 08:59:18.218643 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/horizon/decorators.py", line 84, in dec
[Mon Dec 08 08:59:18.218647 2014] [:error] [pid 26866]     return view_func(request, *args, **kwargs)
[Mon Dec 08 08:59:18.218650 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/django/views/generic/base.py", line 69, in view
[Mon Dec 08 08:59:18.218654 2014] [:error] [pid 26866]     return self.dispatch(request, *args, **kwargs)
[Mon Dec 08 08:59:18.218657 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/django/views/generic/base.py", line 87, in dispatch
[Mon Dec 08 08:59:18.218661 2014] [:error] [pid 26866]     return handler(request, *args, **kwargs)
[Mon Dec 08 08:59:18.218705 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/horizon/tables/views.py", line 157, in get
[Mon Dec 08 08:59:18.218720 2014] [:error] [pid 26866]     handled = self.construct_tables()
[Mon Dec 08 08:59:18.218729 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/horizon/tables/views.py", line 148, in construct_tables
[Mon Dec 08 08:59:18.218737 2014] [:error] [pid 26866]     handled = self.handle_table(table)
[Mon Dec 08 08:59:18.218742 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages/horizon/tables/views.py", line 120, in handle_table
[Mon Dec 08 08:59:18.218749 2014] [:error] [pid 26866]     data = self._get_data_dict()
[Mon Dec 08 08:59:18.218755 2014] [:error] [pid 26866]   File "/usr/lib/python2.7/site-packages ...
(more)
edit flag offensive delete link more

Comments

Look into the default dashboard applications code @ https://github.com/openstack/horizon/...

If you still cant fix it, copy your code @ http://pastebin.com/ and paste the URLs.

teju gravatar imageteju ( 2014-12-08 13:02:55 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-12-01 09:39:21 -0500

Seen: 690 times

Last updated: Dec 08 '14