Skip to content
Snippets Groups Projects
Commit f0d65e75 authored by Sam Roberts's avatar Sam Roberts
Browse files

make it so that EAP is given in dashboards too

parent 5795c1dd
Branches
Tags
1 merge request!43Regions included in dashboard generation
......@@ -469,7 +469,7 @@ def after_request(resp):
return common.after_request(resp)
def _get_dashboards(interface):
def _get_dashboards(interface, region=None):
"""
Yield enums from BRIAN_DASHBOARDS to indicate which dashboards
this interface should be included in.
......@@ -482,12 +482,14 @@ def _get_dashboards(interface):
inventory_provider.routes.poller._DASHBOARD_IDS
:param interface: a dict with keys like router, name, description
:param region: a key from the regions dict
:return: generator that yields enums from BRIAN_DASHBOARDS
"""
router = interface.get('router', '').lower()
ifc_name = interface.get('name', '')
description = interface.get('description', '').strip()
if 'SRV_L3VPN' in description and 'COPERNICUS' in description:
yield BRIAN_DASHBOARDS.COPERNICUS
if re.match(r'SRV_CLS\s', description):
......@@ -539,11 +541,12 @@ def _get_dashboards(interface):
if re.match(r'PHY UPSTREAM\s', description):
yield BRIAN_DASHBOARDS.GWS_PHY_UPSTREAM
regex = r'(PHY|LAG|(SRV_(GLOBAL|LHCONE|MDVPN|IAS|CLS|L3VPN))) CUSTOMER\s'
if re.match(regex, description):
if re.match(regex, description) and region is None:
yield BRIAN_DASHBOARDS.NREN
if "GA-" in description and "ANA-" in description:
yield BRIAN_DASHBOARDS.ANA
if region == 'EAP':
yield BRIAN_DASHBOARDS.EAP
def _get_dashboard_data(ifc, customers, regions=None):
if regions is None:
......@@ -873,6 +876,9 @@ def load_interfaces_to_poll(config, hostname=None, no_lab=False, use_next_redis=
_get_services_and_customers(config, hostname, use_next_redis)
snmp_indexes = common.load_snmp_indexes(config, hostname, use_next_redis)
nren_regions = _load_nren_regions(config, use_next_redis)
unique_regions = set([value for value in nren_regions.values()])
region_index = {region_key: [nren for nren, reg in nren_regions.items() if reg == region_key]
for region_key in unique_regions}
def _get_populated_interfaces(all_interfaces):
if use_next_redis:
......@@ -900,7 +906,9 @@ def load_interfaces_to_poll(config, hostname=None, no_lab=False, use_next_redis=
and ifc_services_and_customers['services']:
ifc['circuits'] = ifc_services_and_customers['services']
dashboards = _get_dashboards(ifc)
_customers = ifc_services_and_customers.get('customers', [])
region = 'EAP' if any(customer in region_index.get('EAP', []) for customer in _customers) else None
dashboards = _get_dashboards(ifc, region)
ifc['dashboards'] = sorted([d.name for d in dashboards])
ifc = _get_dashboard_data(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment