OpenStack's Horizon Source analysis

Source: Internet
Author: User

First, the basic preparation:

Horizon is a standard Python WSGI program developed based on Django Webframework, and Django's design focuses on the highly reusable code, embracing dry principles, all object-oriented, And Horizon can say that the design style of Django is highly match. The website program basically has three parts, the business logic code (python), the static file (JS/CSS), the template (in Python Jinja,mako,nodejs has the jade), after the user initiates the request to the webserver, The server program finds the template corresponding to the current URL, populates the template variable (output as a string of HTML source), returns to the browser, and renders the page in the browser. The general template language has inheritance (extend), insert (include) and other features, to improve the page reuse rate.

Horizon has done a bit more, it has modularized all the elements on the page, some common elements, forms, tables, and tabs, all packaged into Python classes, each with its own small HTML template. When rendering the entire page, Horizon first finds out how many components are in the current page, renders each component into an HTML fragment, and finally, it is assembled into a full HTML page and returned to the browser.

Summarize the features of Horizon:

    • Page Element modularity
    • Sub-panel pluggable
    • All in one (from the deployment that Horizon has only its own component)
Ii. Analysis of Horizon

1. Horizon design is divided into three layers: Dashboard->panelgroup->panel

A, project normal user login to see the item panel

B, admin login to see the left-hand-tested admin panel

C, settings in the upper right corner of the Setup Panel

D, identity different roles after login, the "Identity" Panel on the left, you can set the project user

E, switch Management panel

Each dashboard is a App,django app in Django that can be understood as a means of modularity for business logic that can contain its own unique URL settings, templates, and business logic code. Each dashboard defined a series of panelgroup, the virtual machine management corresponds to the interface is a panelgroup (Managecompute), there is a series of sub-panel (overview, Instance, Volumes ...). Swift, heat, Neutron's admin panel is a panelgroup, with its own sub-panel underneath.

2. Project Structure

Horizon Source contains two code folders:

1, Horizon 2, Openstack_dashboard

Horizon This package is a generic component written on Django basis, table (table), tab (tab), form (form), breadcrumb navigation (browser), workflow (Workflow), This code has nothing to do with OpenStack's specific business logic, and if you do a new Django project, you can theoretically reuse the code in the horizon package. The horizon/base.py also implements a set of dashboard/panel mechanisms that make all dashboard on the horizon panel "pluggable", and all panels are "dynamically loaded".

Openstack_dashboard/dashboards/is the implementation code for each panel, which includes template files for each panel, business logic code for backend service interactions, and so on.

To make an introduction to the important catalogue, some catalogs are not yet in contact with the specific role:

1 Horizon2./Doc:horizon Related Helpful documents3./Horizon:horizon Generic Component library4./Browsers:5./Conf:horizon configuration file6./Contrib:7./Forms:form Table Single class package8./locale: International language Pack9./management:manage.py startdash/startpanel CommandTen./Static: Horizon static File Package One./tables:table base class Package A./Tabs:tab base class Package -./templates: Template file base class -./templatetags: Template Label base class the./Test: Testing Package -./utils: Toolkit -./Workflows: Workflow Mechanism Package -./Openstack_dashboard:horizon specific implementation code for each panel +./API: Call Nova, Swift, glance and other interface encapsulation -./Conf:nova, cinder and other API access control, called Xxx_policy.json, which defines the authentication rules.  +./The Dashboards:horizon interface displays each module implementation directory.  A./admin: admin interface at./instances: Cloud Host Management Interface -./templates: Cloud Host HTML interface template -./forms.py:form Form Implementation -./panel.py: Implementing panel registration to Dashbord -./tables.py:table Implementation -./tests.py: Testing in./Urls.py:url Mapping -./view of the Views.py:url map ... +./Identity: Project, user management interface -./Project : Common User Program Interface the./Router: *./settings: Setting the interface $./Django_pyscss_fix:Panax Notoginseng./enabled: Controls which modules are displayed for navigation loading.  -./Local: Native configuration file the./locale: Native country language Pack +./Management: Define the installation of Apache, Horizon, etc. as configuration files A template file.  the./Openstack:log, _i18n and other bags +./Static: Horizon Static Package -./Templates:horizon Template Package $./Templatetags:horizon Template Label Package $./Test: Testing Package -./Usage:horizon Overview Page Resource statistics Implementation package -./utils: Toolkit the./Wsgi:wsgi Bag -./Tool:horizon Tool KitWuyi./manage.py:

OpenStack's Horizon Source analysis

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.