Horizon is a subproject of OpenStack that provides a Web front-end console (called a dashboard) to demonstrate the functionality of OpenStack. Usually, we start from horizon, Dashboard to understand the OpenStack. In fact, Horizon does not add any new functionality to OpenStack, it only uses the OpenStack part of the API, so we can extend the horizon function and extend the dashboard.
On the dashboard interface, you can have an intuitive feeling when you set up the environment. Horizon Source Directory structure
An example of extending a monitoring panel in the Admin dashboard is to introduce the process of expanding OpenStack dashboard. 1. Define panel
First, we introduce the dashboard.py file, which is located in the root directory of each dashboard, to register dashboard (Django called app) and set dashboard properties, such as which panel in dashboard.
Open the dashboard.py file under the Admin directory and set up a panel with the Systempanels monitoring:
We can add and remove panel properties at random in dashboard.py files, which is handy for debugging programs. Then create a monitoring folder in the Amdin directory and create panel.py files in the Monitoring folder to define the panel:
This is the simplest panel and only defines its name. Note: The value of the Slug property is the same as the Monitoring folder name. When the definition is complete, remember to register it in the dashboard. 2. Define URL
Horizon is based on the Django framework, the program is found by the URL to the panel, so you need to create a urls.py file in the monitoring directory, define the URL:
3. Define Table
Table for displaying data, Horizon provides a DataTable base class, and we can implement a custom table by inheriting the DataTable:
Two columns of resources and percent were defined in the monitoringtable. 4. Define View
View is used to integrate table or tab, Horizon offers a variety of vie classes, and the following uses Datatableview to customize our own Indexview: Define Table_class and Template_ in Indexview Property value of name, and you need to define the Get_data () method, which is used to get the data displayed in the table.
Now that the extension dashboard is complete, you need to restart Apache to see the effect: sudo service apache2 restart. The effect is as follows:
This article is a lot of online, turn it over to facilitate learning.