Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to extend OpenStack Dashboard

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article will explain in detail how to expand OpenStack Dashboard, the content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Introduction to Horizon

Horizon is a subproject of OpenStack to provide a Web front-end console (called Dashboard) to demonstrate the functionality of OpenStack. Usually, we learn about OpenStack from Horizon and Dashboard. In fact, Horizon doesn't add any new functionality to OpenStack, it just uses some of the API features of OpenStack, so we can extend the functionality of Horizon and extend Dashboard.

Extended Dashboard

Overview of Dashboard

Figure 2-1-1 Dashboard interface

A Dashboard (called app in django) typically consists of four components, panel, tab (optional), table, and view, as shown in figure 2-1-1. Among them, panel, tab and table are used for navigation, and the real display of data is in view. The relationship between them is that panel contains tab,tab, contains table,view, contains table or tab.

By looking at the source code of Horizon, you can see the relationship between them from its directory structure, as shown in figure 2-1-2.

Figure 2-1-2 Horizon source directory structure

Next, I will take the panel of adding a monitoring to the Dashboard of admin as an example to introduce the process of extending OpenStack Dashboard.

Define panel

First introduce the Dashboard.py file, which is located in the root directory of each Dashboard, and its purpose is to register Dashboard (called app in django) and set the properties of Dashboard, such as which panel are in Dashboard.

Open the Dashboard.py file in the admin directory, and set the panel of SystemPanels with monitoring:

We can add and remove panel attributes at will in the Dashboard.py file, which is very convenient when debugging the program.

Then create a monitoring folder in the amdin directory, and create a panel.py file in the monitoring folder to define panel:

This is the simplest panel, with only its name defined. Note: the value of the slug attribute should be the same as the monitoring folder name. When the definition is complete, remember to register it with Dashboard.

Define url

Horizon is based on the Django framework, and the program finds the panel through url. Therefore, you need to establish a urls.py file in the monitoring directory and define the url:

Define table

Table is used to display data. Horizon provides the DataTable base class. We can implement custom table by inheriting DataTable:

Two columns of resources and percent are defined in MonitoringTable.

Define view

View is used to integrate table or tab. Horizon provides a variety of vie classes. Let's use DataTableView to customize our own IndexView:

Define the attribute values of table_class and template_name in IndexView, as well as the get_data () method, which is used to obtain data and display it in table.

At this point, the extension of Dashboard is complete, and you need to restart apache to see the effect: sudo service apache2 restart. The effect is as follows:

On how to expand OpenStack Dashboard to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report