Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 2. Customizing the dashboard
The Red Hat OpenStack Platform (RHOSP) dashboard (horizon) uses a default theme (RCUE), which is stored inside the horizon container. You can add your own theme to the container image and customize certain parameters to change the look and feel of the following dashboard elements:
- Logo
- Site colors
- Stylesheets
- HTML title
- Site branding link
- Help URL
To ensure continued support for modified RHOSP container images, the resulting images must comply with the Red Hat Container Support Policy.
2.1. Obtaining the horizon container image Copier lienLien copié sur presse-papiers!
To obtain a copy of the horizon container image, pull the image either into the undercloud or a separate client system that is running podman.
Procedure
Pull the horizon container image:
sudo podman pull registry.redhat.io/rhosp-rhel8/openstack-horizon:16.2
$ sudo podman pull registry.redhat.io/rhosp-rhel8/openstack-horizon:16.2Copy to Clipboard Copied! Toggle word wrap Toggle overflow You can use this image as a basis for a modified image.
2.2. Obtaining the RCUE theme Copier lienLien copié sur presse-papiers!
The horizon container image uses the Red Hat branded RCUE theme by default. You can use this theme as a basis for your own theme and extract a copy from the container image.
Procedure
Create a directory for your theme:
mkdir ~/horizon-themes cd ~/horizon-themes
$ mkdir ~/horizon-themes $ cd ~/horizon-themesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start a container that executes a null loop. For example, run the following command:
sudo podman run --rm -d --name horizon-temp registry.redhat.io/rhosp-rhel8/openstack-horizon:16.2 /usr/bin/sleep infinity
$ sudo podman run --rm -d --name horizon-temp registry.redhat.io/rhosp-rhel8/openstack-horizon:16.2 /usr/bin/sleep infinityCopy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the RCUE theme from the container to your local directory:
sudo podman cp horizon-temp:/usr/share/openstack-dashboard/openstack_dashboard/themes/rcue .
$ sudo podman cp horizon-temp:/usr/share/openstack-dashboard/openstack_dashboard/themes/rcue .Copy to Clipboard Copied! Toggle word wrap Toggle overflow Terminate the container:
sudo podman kill horizon-temp
$ sudo podman kill horizon-tempCopy to Clipboard Copied! Toggle word wrap Toggle overflow Result: You now have a local copy of the RCUE theme.
2.3. Creating your own theme based on RCUE Copier lienLien copié sur presse-papiers!
To use RCUE as a basis, copy the entire RCUE theme directory rcue to a new location. This procedure uses mytheme as an example name.
Procedure
Copy the theme:
cp -r rcue mytheme
$ cp -r rcue mythemeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
To change the colors, graphics, fonts, and other elements of a theme, edit the files in mytheme. When you edit this theme, check for all instances of rcue including paths, files, and directories to ensure that you change them to the new mytheme name.
2.4. Creating a file to enable your theme and customize the dashboard Copier lienLien copié sur presse-papiers!
To enable your theme in the dashboard container, you must create a file to override the AVAILABLE_THEMES parameter. This procedure uses mytheme as an example name.
Procedure
Create a new file called
_12_mytheme_theme.pyin thehorizon-themesdirectory and add the following content:AVAILABLE_THEMES = [('mytheme', 'My Custom Theme', 'themes/mytheme')]AVAILABLE_THEMES = [('mytheme', 'My Custom Theme', 'themes/mytheme')]Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
12in the file name ensures this file is loaded after the RCUE file, which uses11, and overrides theAVAILABLE_THEMESparameter.Optional: You can also set custom parameters in the
_12_mytheme_theme.pyfile. Use the following examples as a guide:- SITE_BRANDING
Set the HTML title that appears at the top of the browser window.
SITE_BRANDING = "Example, Inc. Cloud"
SITE_BRANDING = "Example, Inc. Cloud"Copy to Clipboard Copied! Toggle word wrap Toggle overflow - SITE_BRANDING_LINK
Changes the hyperlink of the theme logo, which normally redirects to
horizon:user_homeby default.SITE_BRANDING_LINK = "http://example.com"
SITE_BRANDING_LINK = "http://example.com"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.5. Generating a modified horizon image Copier lienLien copié sur presse-papiers!
When your custom theme is ready, you can create a new container image that uses your theme. This procedure uses mytheme as an example name.
Procedure
Use a
Dockerfileto generate a new container image using the originalhorizonimage as a basis, as shown in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Save this file in your
horizon-themesdirectory asDockerfile. Use the Dockerfile to generate the new image:
sudo podman build . -t "172.24.10.10:8787/rhosp-rhel8/openstack-horizon:0-5" --log-level debug
$ sudo podman build . -t "172.24.10.10:8787/rhosp-rhel8/openstack-horizon:0-5" --log-level debugCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
-toption names and tags the resulting image. It uses the following syntax:[LOCATION]/[NAME]:[TAG]
[LOCATION]/[NAME]:[TAG]Copy to Clipboard Copied! Toggle word wrap Toggle overflow - LOCATION
- This is usually the location of the container registry that the overcloud eventually uses to pull images. In this instance, you push this image to the container registry of the undercloud, so set this to the undercloud IP and port.
- NAME
-
For consistency, this is usually the same name as the original container image followed by the name of your theme. In this instance, it is
rhosp-rhel8/openstack-horizon-mytheme. - TAG
-
The tag for the image. Red Hat uses the
versionandreleaselabels as a basis for this tag. If you generate a new version of this image, increment therelease, for example,0-2.
Push the image to the container registry of the undercloud:
sudo openstack tripleo container image push --local 172.24.10.10:8787/rhosp-rhel8/openstack-horizon:0-5
$ sudo openstack tripleo container image push --local 172.24.10.10:8787/rhosp-rhel8/openstack-horizon:0-5Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the image has uploaded to the local registry:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
If you update or upgrade Red Hat OpenStack Platform, you must reapply the theme to the new horizon image and push a new version of the modified image to the undercloud.
2.6. Using the modified container image in the overcloud Copier lienLien copié sur presse-papiers!
To use the container image that you modified with your overcloud deployment, edit the environment file that contains the list of container image locations. This environment file is usually named overcloud-images.yaml. This procedure uses mytheme as an example name.
Procedure
Edit the
DockerHorizonConfigImageandDockerHorizonImageparameters to point to your modified container image:parameter_defaults: ... ContainerHorizonConfigImage: 192.168.24.1:8787/rhosp-rhel8/openstack-horizon-mytheme:0-1 ContainerHorizonImage: 192.168.24.1:8787/rhosp-rhel8/openstack-horizon-mytheme:0-1 ...
parameter_defaults: ... ContainerHorizonConfigImage: 192.168.24.1:8787/rhosp-rhel8/openstack-horizon-mytheme:0-1 ContainerHorizonImage: 192.168.24.1:8787/rhosp-rhel8/openstack-horizon-mytheme:0-1 ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Save this new version of the
overcloud-images.yamlfile.
2.7. Editing puppet parameters Copier lienLien copié sur presse-papiers!
Director provides a set of dashboard parameters that you can modify with environment files.
Procedure
Use the
ExtraConfigparameter to set Puppet hieradata. For example, the default help URL points to https://access.redhat.com/documentation/en/red-hat-openstack-platform. To modify this URL, use the following environment file content and replace the URL:parameter_defaults: ExtraConfig: horizon::help_url: "http://openstack.example.com"parameter_defaults: ExtraConfig: horizon::help_url: "http://openstack.example.com"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
2.8. Deploying an overcloud with a customized dashboard Copier lienLien copié sur presse-papiers!
Procedure
To deploy the overcloud with your dashboard customizations, include the following environment files in the
openstack overcloud deploycommand:- The environment file with your modified container image locations.
- The environment file with additional dashboard modifications.
Any other environment files that are relevant to your overcloud configuration.
openstack overcloud deploy --templates \ -e /home/stack/templates/overcloud-images.yaml \ -e /home/stack/templates/help_url.yaml \ [OTHER OPTIONS]$ openstack overcloud deploy --templates \ -e /home/stack/templates/overcloud-images.yaml \ -e /home/stack/templates/help_url.yaml \ [OTHER OPTIONS]Copy to Clipboard Copied! Toggle word wrap Toggle overflow