Newer
Older
"""
This file loads the configuration used for the dashboard manager.
The config is stored in a JSON format on the filesystem,
with the following schema:
.. asjson::
brian_dashboard_manager.config.CONFIG_SCHEMA
Some config specific to each organization is hardcoded.
This includes which organizations to provision,
and which dashboards not to provision for each organization:
`excluded_nrens` is a list of strings to search for in interface descriptions
to exclude for that organization.
`excluded_dashboards` is a list of dashboard names to exclude.
These only cover the static dashboards loaded from the file system.
`excluded_folders` covers dynamically generated folders and dashboards.
This property is a mapping of folder name to `True` or a list of dashboards.
A value of `True` should result in that folder being excluded.
If the value is a list, dashboard titles within the list should be excluded.
.. asjson::
brian_dashboard_manager.config.DEFAULT_ORGANIZATIONS
"""
import json
import jsonschema
STATE_PATH = tempfile.gettempdir() + '/briandashboardmanager-state.json'
DEFAULT_ORGANIZATIONS = [
{
"name": "GÉANT Staff",
"excluded_nrens": [
"GEANT",
"excluded_dashboards": [],
"excluded_folders": {}
"GEANT-IT",
"Microsoft"
"excluded_dashboards": [
"GÉANT Office devices",
},
{
"name": "General Public",
"excluded_nrens": [
"GEANT-IT",
"Microsoft"
"excluded_dashboards": [
"GÉANT Office devices",
"Aggregates": ["CAE1", "GWS UPSTREAMS", "IAS PEERS"],
"IAS CUSTOMER": True,
"IAS PRIVATE": True,
"IAS PUBLIC": True,
"GWS Direct": True,
"GWS Indirect": True,
"EUMETSAT Multicast": True,
"NREN Access BETA": True
"excluded_dashboards": [
"GÉANT Office devices",
"EUMETSAT Multicast": True
},
{
"name": "CAE1 - Asia",
"GEANT-IT",
"Microsoft"
"excluded_dashboards": [
"GÉANT Office devices",
"IAS CUSTOMER": True,
"IAS PRIVATE": True,
"IAS PUBLIC": True,
"GWS PHY Upstream": True,
"EUMETSAT Multicast": True,
"NREN Access BETA": True
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"influx-datasource": {
"type": "object",
"properties": {
"name": {"type": "string"},
"username": {"type": "string"},
"password": {"type": "string"},
"type": {"type": "string"},
"url": {"type": "string"},
"database": {"type": "string"},
"basicAuth": {"type": "boolean"},
"access": {"type": "string"},
"isDefault": {"type": "boolean"},
"readOnly": {"type": "boolean"}
},
"required": [
"name",
"type",
"url",
"database",
"basicAuth",
"access",
"isDefault",
"readOnly"
]
},
"organization": {
"type": "object",
"properties": {
"name": {"type": "string"},
"excluded_nrens": {
"type": "array",
"items": {"type": "string"}
},
},
"required": [
"name",
"excluded_nrens",
]
"type": "object",
"properties": {
"admin_username": {"type": "string"},
"admin_password": {"type": "string"},
"hostname": {"type": "string"},
"listen_port": {"type": "integer"},
"reporting_provider": {"type": "string"},
"datasources": {
"type": "object",
"properties": {
"influxdb": {"$ref": "#/definitions/influx-datasource"}
},
"additionalProperties": False
},
"ignored_folders": {
"type": "array",
"items": {"type": "string"}
}
"required": [
"admin_username",
"admin_password",
"hostname",
"datasources",
"ignored_folders"
}
def defaults():
return {
"admin_username": "admin",
"admin_password": "admin",
"datasources": {},
"ignored_folders": []
}
def load(f):
"""
loads, validates and returns configuration parameters
:param f: file-like object that produces the config file
:return:
"""
config = json.loads(f.read())
jsonschema.validate(config, CONFIG_SCHEMA)
return config