[Openstack] Horizon panel and database

Lukáš Vízner lukasvizner at gmail.com
Thu Jul 10 13:06:17 UTC 2014


Hey,

I just want to share interesting link which helped me solve my problem and
better understand how it all works together:
http://crazytechthoughts.blogspot.cz/2013/02/simple-employee-table-with-openstack.html

Greetings
Lukas


2014-07-03 11:18 GMT+02:00 Lukáš Vízner <lukasvizner at gmail.com>:

> Hello,
>
> thanks for reply. Yes I have model for data in the models.py file. I am
> able to show empty table in the panel but what I do not know is how the
> code of the function "get_data" in the views.py file should look like. When
> I try to look to another views.py files I can see that openstack api is
> used, but I can not use this api I have my own MySQL database outside
> openstack.
>
> I will provide pieces of code for better picture.(for simplicity just for
> one attribute)
>
> TABLES.PY
> _______________
>
> class BackupTable(tables.DataTable):
>     node = tables.Column("node_name",
>                                         verbose_name=_("Node Name"))
> class Meta:
>         name = "backup"
>         verbose_name = _("Backup")
>
> MODELS.PY
> _______________
>
> class Tsm_nodes(models.Model):
>     node_name = models.CharField(max_length=30)
>
> VIEWS.PY
> _______________
>
> class BackupIndexView(tables.DataTableView):
>     table_class = project_tables.BackupTable
>     template_name = 'admin/backup/index.html'
>
>     def get_data(self):
>         backup=[]
>         ???what here???
>         return backup
>
> MySQL TABLE
> _______________
>
> mysql> show columns from nodes;
>
> +------------------+----------------+--------+-----+-----------+----------------+
> | Field            | Type         |  Null  | Key| Default |    Extra    |
>
> +------------------+----------------+--------+-----+-----------+----------------+
> | node_name  | varchar(30) | YES |       | NULL   |                |
>
> +------------------+----------------+--------+-----+-----------+----------------+
>
> Thanks much for help !!!!
>
> Lukas
>
>
> 2014-06-30 13:53 GMT+02:00 Matthias Runge <mrunge at redhat.com>:
>
> On Thu, Jun 26, 2014 at 05:36:07PM +0200, Lukáš Vízner wrote:
>> > Hi,
>> >
>> > I have specific task that I need to create a new panel in horizon
>> > dashboard. In this panel I need to create table and in this table I
>> need to
>> > show data from my specific database table.
>> >
>> > I have created the new panel and table, I have prepared my database
>> table,
>> > but now I donť know how to work with it all to connect to my database,
>> read
>> > data from the database table and show it in the horizon table, because
>> in
>> > the example files from others panels is openstack api used. I would
>> need to
>> > read data directly from the database. Is this possible? What steps
>> should I
>> > follow now ?
>> >
>> > Could anybody help me to solve this issue?
>> >
>> Do you have a model for you data used? The Django docs are quite good at
>> this point[1].
>>
>> HTH, Matthias
>>
>>
>> [1] https://docs.djangoproject.com/en/1.6/topics/db/queries/
>> --
>> Matthias Runge <mrunge at redhat.com>
>>
>> _______________________________________________
>> Mailing list:
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
>> Post to     : openstack at lists.openstack.org
>> Unsubscribe :
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
>>
>
>
>
> --
> Lukáš Vízner
>



-- 
Lukáš Vízner
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20140710/e834ddbe/attachment.html>


More information about the Openstack mailing list