OpenStack Learning Notes (14)-horizon Learning Notes (iv) __openstack

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.