introduce
Horizon allows adding dashboards, panels, and panel groups without modifying the default settings. Pluginized settings are a mechanism that allows settings to be stored in separate files. These files are read at startup and used to modify default settings.
The default location for the dashboard configuration file is openstack_dashboard/enabled
, another directory openstack_dashboard/local/enabled
is used for local overrides. Both sets of files will be loaded, but the openstack_dashboard/local/enabled
settings will override the default settings. These settings apply the alphabetical order of file names. If the same enabled
dashboard local/enabled
has config files in and , in local/enabled
will be used. Note that because python module names cannot start with a number, these files are usually named with a leading underscore followed by a number so that you can easily control their order.
General Pluggable Settings¶
Before describing specific use cases, the following configuration variables can be used in any pluginized settings file.
ADD_EXCEPTIONS
¶New in version 2014.1(Icehouse).
HORIZON['exceptions']
A dictionary of exception classes can be added to configuration variables .
ADD_INSTALLED_APPS
New in version 2014.1(Icehouse).
This setting is required when static files need to be exposed from plugins before the application list is inserted into the INSTALLED_APPS
list .
ADD_ANGULAR_MODULES
New in version 2014.2(Juno).
When Angular bootstraps, the list of AngularJS modules is loaded. These modules are added as dependencies to the root Horizon application horizon.
ADD_JS_FILES
New in version 2014.2(Juno).
The list of javascript source files is brought into the zip file set loaded on each page. This is required for AngularJS modules, because these ADD_ANGULAR_MODULES
added modules reference the javascript source files and therefore need to be included in every page.
ADD_JS_SPEC_FILES
¶ New in version 2015.1(Kilo).
A list of javascript spec files will be imported for integration with the Jasmine spec runner. Jasmine is a behavior-driven development framework for testing JavaScript code.
ADD_SCSS_FILES
¶New in version 8.0.0(Liberty).
The list of scss files will be brought into the set of compressed files loaded on each page. One scss file per dashboard is recommended, if you need to reference additional scss files for the panel, use @import.
ADD_XSTATIC_MODULES
¶New in version 14.0.0(Rocky).
A list of xstatic modules containing javascript and scss files is imported into the zip file set loaded on each page. Relevant files should ADD_XSTATIC_MODULES
be added instead of ADD_JS_FILES
. This option configuration value is a list of tuples, each tuple contains an xstatic module and a list of javascript files to load. Check out the BASE_XSTATIC_MODULES
comments .
example:
ADD_XSTATIC_MODULES = [ ('xstatic.pkg.foo', ['foo.js']), ('xstatic.pkg.bar', None), ]
AUTO_DISCOVER_STATIC_FILES
¶New in version 8.0.0(Liberty).
If set to True, JavaScript files and angular static html template files will be automatically found in each app's static folder in ADD_INSTALLED_APPS.
JavaScript source files will be sorted according to the naming convention: files with the .module.js extension are listed first, followed by other JavaScript source files.
JavaScript files used for testing will also be ordered according to the naming convention: files with the .mock.js extension are listed first, followed by files with the .spec.js extension.
If ADD_JS_FILES and/or ADD_JS_SPEC_FILES are also specified, manually listed files will be appended to automatically discovered files.
DISABLED
¶New in version 2014.1(Icehouse).
If set to True, this settings file will not be added to the settings.
EXTRA_TABS
¶New in version 14.0.0(Rocky).
Additional tabs can be added to a tab group by using this setting in horizon or other horizon plugins. Additional tabs are displayed after the default tabs defined in the corresponding tab group.
This is a dictionary configuration. The key of the dictionary specifies the tag group to which additional tags are added. key must match the full class name of the target tab group. The dictionary value is a list of the full names of the extra label classes (the module name and class name for this value must be separated by a period). The EXTRA_TABS
tabs specified by will be displayed in the order in which they were registered.
In some cases, you may want to specify the order of extra tabs, since multiple horizon plugins can register extra tabs. The priority of each tab can be specified in the EXTRA_TABS
configuration by using a tuple with the priority and the tab class name instead of an extra tab full name as a dictionary value. The priority is an integer, and the smaller the value, the higher the priority. If a tab forgets to set its priority, its priority will be set to 0.
example:
EXTRA_TABS = { 'openstack_dashboard.dashboards.project.networks.tabs.NetworkDetailsTabs': ( 'openstack_dashboard.dashboards.project.networks.subnets.tabs.SubnetsTab', 'openstack_dashboard.dashboards.project.networks.ports.tabs.PortsTab', ), }
Example with priority:
EXTRA_TABS = { 'openstack_dashboard.dashboards.project.networks.tabs.NetworkDetailsTabs': ( (1, 'openstack_dashboard.dashboards.project.networks.subnets.tabs.SubnetsTab'), (2, 'openstack_dashboard.dashboards.project.networks.ports.tabs.PortsTab'), ), }
UPDATE_HORIZON_CONFIG
¶New in version 2014.2(Juno).
The set dictionary value will update HORIZON_CONFIG
the value in .
Plugin settings for Dashboards¶ New in version 2014.1 (Icehouse).
The configuration below is for registering the dashboard.
DASHBOARD
¶ New in version 2014.1(Icehouse).
This value is the value of the slug field of the dashboard, which will be added to HORIZON['dashboards']
. is required.
DEFAULT
¶ New in version 2014.1(Icehouse).
If set to True, this dashboard will be set as the default dashboard.
example:
To disable the dashboard locally, create a openstack_dashboard/local/enabled/_40_dashboard-name.py
file :
DASHBOARD = '<dashboard-name>' DISABLED = True
To add a Tuskar-UI (Infrastructure) dashboard, you must first install it, then create a file openstack_dashboard/local/enabled/_50_tuskar.py
:
from tuskar_ui import exceptions DASHBOARD = 'infrastructure' ADD_INSTALLED_APPS = [ 'tuskar_ui.infrastructure', ] ADD_EXCEPTIONS = { 'recoverable': exceptions.RECOVERABLE, 'not_found': exceptions.NOT_FOUND, 'unauthorized': exceptions.UNAUTHORIZED, }
Plugin settings for Panels¶ New in version 2014.1 (Icehouse).
The following configuration is used to register or delete the panel.
PANEL
¶ New in version 2014.1(Icehouse).
This value is the value of the slug field of the panel, which will be added to HORIZON_CONFIG
. is required.
PANEL_DASHBOARD
¶ New in version 2014.1(Icehouse).
Specifies the slug value of the dashboard PANEL
associated with . is required. This configuration is to set the panel to the specified dashbaord.
PANEL_GROUP
¶ New in version 2014.1(Icehouse).
Specifies the slug value of the panel group PANEL
associated with . This configuration is to set the panel to the specified group. Set this value to "default" if you want this panel not to be in the group.
DEFAULT_PANEL
¶ New in version 2014.1(Icehouse).
If this value is set, it will update PANEL_DASHBOARD
the default panel of .
ADD_PANEL
¶ New in version 2014.1(Icehouse).
This value is the Python class of the panel to add.
REMOVE_PANEL
¶ New in version 2014.1(Icehouse).
If set to True, the panel will be removed from PANEL_DASHBOARD or PANEL_GROUP.
example:
To add a panel to the Admin panel group in the Admin dashboard, create a openstack_dashboard/local/enabled/_60_admin_add_panel.py
file :
PANEL = 'plugin_panel' PANEL_DASHBOARD = 'admin' PANEL_GROUP = 'admin' ADD_PANEL = 'test_panels.plugin_panel.panel.PluginPanel'
To delete the Info panel of the Admin panel group in the Admin dashboard, create a openstack_dashboard/local/enabled/_70_admin_remove_panel.py
file :
PANEL = 'info' PANEL_DASHBOARD = 'admin' PANEL_GROUP = 'admin' REMOVE_PANEL = True
To change the default panel in the Admin dashboard to Instances, create a openstack_dashboard/local/enabled/_80_admin_default_panel.py
file :
PANEL = 'instances' PANEL_DASHBOARD = 'admin' PANEL_GROUP = 'admin' DEFAULT_PANEL = 'instances'
Plugin settings for Panels groups¶ New in version 2014.1 (Icehouse).
The following configuration is used to register or delete panel groups.
PANEL_GROUP
¶ New in version 2014.1(Icehouse).
This value is the value of the slug field of the panel group, which will be added to HORIZON_CONFIG
. is required.
PANEL_GROUP_NAME
¶ New in version 2014.1(Icehouse).
PANEL_GROUP Display name. is required.
PANEL_GROUP_DASHBOARD
¶ New in version 2014.1(Icehouse).
Specifies the slug value of the dashboard PANEL_GROUP
associated with . is required. This configuration is to set the panel group to the specified dashbaord.
example:
Add a new panel group to the Admin dashboard, created with the following content openstack_dashboard/local/enabled/_90_admin_add_panel_group.py
:
PANEL_GROUP = 'plugin_panel_group' PANEL_GROUP_NAME = 'Plugin Panel Group' PANEL_GROUP_DASHBOARD = 'admin'
Reprinted from: http://luozn.top/2018/04/13/227/