This module implements a skeleton Flask-based webservice.
This module is used to provision Organizations and Dashboards in Grafana for BRIAN.
It implements a Flask-based webservice used only to trigger the provisioning process.
The webservice is communicates with clients over HTTP.
Responses to valid requests are returned as JSON messages.
The server will therefore return an error unless
`application/json` is in the `Accept` request header field.
The dashboards are generated from a list of interfaces obtained from Inventory Provider.
HTTP communication and JSON grammar details are
beyond the scope of this document.
Please refer to [RFC 2616](https://tools.ietf.org/html/rfc2616)
and www.json.org for more details.
Jinja templates are populated with data from these interfaces to render Dashboard JSON definitions sent to the Grafana API.
Grafana API-related code lives in the `grafana` package.
The `brian_dashboard_manager/grafana/provision.py` file is responsible for the entire provisioning lifecycle.
Grafana API endpoints have wrapper functions in one file for relevant parts of the API, e.g. `brian_dashboard_manager/grafana/dashboard.py` for the dashboard API functions.
Another example is `brian_dashboard_manager/grafana/organization.py` for the organization API functions.
Some of the provisioned dashboards are not generated but are just static JSON files. These are put in the `brian_dashboard_manager/dashboards` directory. The same can be done for JSON datasource definitions in the `datasources` directory.
The `brian_dashboard_manager/templating` package contains the code and Jinja templates used to render dashboard JSON. Most dashboards reuse the same templates, with the exception of NREN-specific dashboards, which has its own template.
Of note is the `templating/helpers.py` file, which has all of the predicates and helper functions used to group interfaces together and generate the necessary data for the dashboard templates.
The `templating/render.py` has functions for rendering of the various Jinja templates from the given data.
## Configuration
This app allows specification of a few
example configuration parameters. These
example configuration parameters. These
parameters should stored in a file formatted
similarly to `config.json.example`, and the name
of this file should be stored in the environment
...
...
@@ -29,58 +38,37 @@ variable `CONFIG_FILENAME` when running the service.
This module has been tested in the following execution environments:
- As an embedded Flask application.
For example, the application could be launched as follows:
For example, the application could be launched as follows: