Skip to content
Snippets Groups Projects
Commit 8941e335 authored by Bjarke Madsen's avatar Bjarke Madsen
Browse files

POL1-653 Fix excluded_nrens filtering

parent d2b40fab
No related branches found
No related tags found
No related merge requests found
......@@ -303,18 +303,20 @@ def _provision_interfaces(config, org_config, ds_name, token):
excluded_nrens = org_config['excluded_nrens']
def excluded(interface):
desc = interface['description'].lower()
lab = 'lab.office' in interface['router'].lower()
to_exclude = any(nren.lower() in desc for nren in excluded_nrens)
if not (to_exclude or lab):
if 'dashboards_info' not in interface:
to_exclude = True
logger.info(f'No "dashboards_info" for '
f'{interface["router"]}:{interface["name"]}')
return not (to_exclude or lab)
relevant_interfaces = list(filter(excluded, interfaces))
def interfaces_to_keep(interface):
dash_info = interface.get('dashboards_info')
if dash_info is None:
logger.info(f'No "dashboards_info" for '
f'{interface["router"]}:{interface["name"]}')
# throw it away
return False
dashboards = {nren['name'].lower() for nren in dash_info}
is_lab_router = 'lab.office' in interface['router'].lower()
should_keep = not (is_lab_router or any(
nren.lower() in dashboards for nren in excluded_nrens))
return should_keep
relevant_interfaces = list(filter(interfaces_to_keep, interfaces))
for interface in relevant_interfaces:
interface['dashboards_info'] = list(filter(
lambda x: x['name'] != '',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment