Separate Murano Dashboard config

Registered by Dmitry Teselkin

Currently Murano Dashboard keeps all configuration values in file local_settings.py. It's a bit awkward, especially when it's required to update some of the variables automatically.

In order to simplify installation and automated configuration for Murano Dashboard it is proposed to separate values from local_settings.py.

The idea is the following: create separate python file with single class, called, say MuranoDashboardConfig. This class should provide a number of methods, each of which is targeted to update one of Murano Dashboard configuration variables. This class should define defaults for all variables, and be able to parse external configuration file, replacing default values for parameters which are found in config file.

For example:

* murano_dashboard_config.py
--------------------------------------------------------------------------------
import os

class MuranoDashboardConfig():
    def __init__(self, config_file):
        # Set default values
        self.murano_api_proto='http'
        self.murano_api_host='127.0.0.1'
        self.murano_api_port='8082'
        self.metadata_cache_dir='/tmp/muranodashboard-cache'
        self.backend_db_type='sqlite3'
        self.session_engine='django.contrib.sessions.backends.db'

        # Try to parse external config file
        self._parse_config_file(config_file)

    def _parse_config_file(self, config_file):
        # Try to open and parse config_file file.
        pass

    def session_engine(self):
        return self.session_engine

    def murano_api_url(self):
        return "{0}://{1}:{2}".format(self.murano_api_proto,
            self.murano_api_host, self.murano_api_port)

    def alter_databases_dict(self, d):
        if self.backend_db_type == 'mysql':
            # Alter d['default']
            return
        # Use sqlite3 by default
        d['default'] = {
            'ENGINE' = 'django.db.backends.sqlite3',
            'NAME' = os.path.join(self.metadata_cache_dir, 'openstack-dashboard.sqlite')
        }

    def horizon_config(self, d):
        d['dashboards'] += ('murano',)

    def installed_apps(self, t):
        return t + ('muranodashboard', 'floppyforms',)

    def middleware_classes(self, t):
        return t + ('muranodashboard.middleware.ExceptionMiddleware',)
--------------------------------------------------------------------------------

* local_settings.py
--------------------------------------------------------------------------------

import murano_dashboard_config

mdc = MuranoDashboardConfig('/etc/murano/dashboard.conf')

MURANO_API_URL = mdc.murano_api_url()
SESSION_ENGINE = mdc.session_engine()
HORIZON_CONFIG = mdc.horizon_config(HORIZON_CONFIG)
INSTALLED_APPS = mdc.installed_apps(INSTALLED_APPS)
MIDDLEWARE_CLASSES = mdc.middleware_classes(MIDDLEWARE_CLASSES)

mdc.alter_databases_dict(DATABASES)

--------------------------------------------------------------------------------

* /etc/murano/dashboard.conf
--------------------------------------------------------------------------------
[DEFAULT]

murano_api_proto = http
murano_api_host = 127.0.0.1
murano_api_port = 8082

backend_db_type = 'sqlite3'
--------------------------------------------------------------------------------

Blueprint information

Status:
Complete
Approver:
None
Priority:
Low
Drafter:
Dmitry Teselkin
Direction:
Approved
Assignee:
Ekaterina Chernova
Definition:
Pending Approval
Series goal:
Accepted for juno
Implementation:
Implemented
Milestone target:
None
Started by
Ruslan Kamaldinov
Completed by
Ruslan Kamaldinov

Related branches

Sprints

Whiteboard

Gerrit topic: https://review.openstack.org/#q,topic:bp/separate-muranodashboard-config,n,z

Addressed by: https://review.openstack.org/101578
    Introduces script for updating horizon config

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.