diff --git a/brian_dashboard_manager/config.py b/brian_dashboard_manager/config.py index 03181e49b0cf156d96301b06c85e5871c4f559d5..df6d5c65c93df7e1549daedc3824316a9050b2c7 100644 --- a/brian_dashboard_manager/config.py +++ b/brian_dashboard_manager/config.py @@ -189,13 +189,18 @@ CONFIG_SCHEMA = { }, "additionalProperties": False }, + "ignored_folders": { + "type": "array", + "items": {"type": "string"} + } }, "required": [ "admin_username", "admin_password", "hostname", "inventory_provider", - "datasources" + "datasources", + "ignored_folders" ] } @@ -206,7 +211,8 @@ def defaults(): "admin_password": "admin", "hostname": "localhost:3000", "listen_port": 3001, - "datasources": {} + "datasources": {}, + "ignored_folders": [] } diff --git a/brian_dashboard_manager/grafana/dashboard.py b/brian_dashboard_manager/grafana/dashboard.py index e7b856d13cf62852586b30c91fd9a2e4383e5bb5..3ab43d34d96c8bb498e5798ce5f1bb9964df4e14 100644 --- a/brian_dashboard_manager/grafana/dashboard.py +++ b/brian_dashboard_manager/grafana/dashboard.py @@ -124,7 +124,7 @@ def _search_dashboard(request: TokenRequest, dashboard: Dict, folder_id=None): if r and isinstance(r, list): if len(r) >= 1: for dash in r: - if dash['title'].lower() == dashboard['title'].lower(): + if dash['title'] == dashboard['title']: definition = _get_dashboard(request, dash['uid']) return definition return None diff --git a/brian_dashboard_manager/grafana/provision.py b/brian_dashboard_manager/grafana/provision.py index bccb7e9dcb52e3ce0c8f4fe491f688dc8dae20a5..7a9bc702a9dfe5c55b18b442efbdb7f3cee4e917 100644 --- a/brian_dashboard_manager/grafana/provision.py +++ b/brian_dashboard_manager/grafana/provision.py @@ -51,15 +51,7 @@ def provision_folder(token_request, folder_name, dash, folder = find_folder(token_request, folder_name) tag = dash['tag'] - interfaces = dash['interfaces'] - - empty_names = [iface for iface in interfaces if not _check_valid(iface)] - - if any(empty_names): - for iface in empty_names: - logger.info('Invalid dashboard name on interface:') - logger.info(json.dumps(iface, indent=2)) - interfaces = list(filter(_check_valid, interfaces)) + interfaces = list(filter(_check_valid, dash['interfaces'])) # dashboard should include error panels errors = dash.get('errors', False) @@ -460,8 +452,12 @@ def provision(config): # get dashboard UIDs from ignored folders # and make sure we don't touch them for name in ignored_folders: - folder = find_folder(request, name) - to_ignore = list_dashboards(request, folder['id']) + logger.info( + f'Ignoring dashboards under the folder {org["name"]}/{name}') + folder = find_folder(token_request, name, create=False) + if folder is None: + continue + to_ignore = list_dashboards(token_request, folder['id']) for dash in to_ignore: # mark it updated, so we don't modify it. diff --git a/changelog.md b/changelog.md index 838064a3248f4748e348f90ce2d3ab98eb7009fc..c5374a4daba918e1a42f6fa69d250275b826ef8e 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. +## [0.20] - 2021-09-13 +- Don't automatically create ignored folders, just ignore them if they are present. + ## [0.19] - 2021-09-13 - [POL1-501] create config option ignored_folders for provisioning folders with manually maintained dashboards diff --git a/setup.py b/setup.py index 06bcf86744c57e9772bff06936aeae8ed7523b39..1b5e7aa93bf018ba54ba3cc5304acbeeb89dffad 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='brian-dashboard-manager', - version="0.19", + version="0.20", author='GEANT', author_email='swd@geant.org', description='', diff --git a/test/conftest.py b/test/conftest.py index 22b968d8e27d238fb211cbcefff95e65da445146..87039da970227fff27576c169b6056b25b74249b 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -45,7 +45,8 @@ def data_config(): "isDefault": True, "readOnly": False } - } + }, + "ignored_folders": [] }