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