diff --git a/inventory_provider/routes/poller.py b/inventory_provider/routes/poller.py index 0656b76f74e19615412f1fd25940775fc3d03b26..e6187d682f422a0e330dec371dc309f0c43fa7b7 100644 --- a/inventory_provider/routes/poller.py +++ b/inventory_provider/routes/poller.py @@ -523,7 +523,10 @@ def _get_dashboards(interface): yield BRIAN_DASHBOARDS.ANA -def _get_dashboard_data(ifc, customers): +def _get_dashboard_data(ifc, customers, regions=None): + if regions is None: + regions = [] + def _get_interface_type(description): if re.match(r'^PHY', description): return INTERFACE_TYPES.PHYSICAL @@ -580,6 +583,15 @@ def _get_dashboard_data(ifc, customers): if not names: return ifc + # add region-based dashboard names + region_names = [] + for name in names: + if name in regions: + region = regions[name] + if region == 'EAP': + region_names.append(BRIAN_DASHBOARDS.EAP.name) + names.extend(region_names) + # to maintain compatability with current brian dashboard manager we will # continue to return dashboard_info with the first customer name. We will # also return dashboards_info (note the plural of dashboards) with up to @@ -597,20 +609,6 @@ def _get_dashboard_data(ifc, customers): } -def _add_region_data(ifc, regions): - if 'dashboards_info' in ifc: - for item in ifc['dashboards_info']: - name = item['name'] - if name in regions: - region = regions[name] - if region == 'EAP': - dashboards = ifc['dashboards'] - dashboards.append(BRIAN_DASHBOARDS.EAP.name) - ifc['dashboards'] = sorted(dashboards) - return ifc - return ifc - - def _load_interface_bundles(config, hostname=None, use_next_redis=False): result = dict() @@ -883,8 +881,7 @@ def load_interfaces_to_poll(config, hostname=None, no_lab=False, use_next_redis= ifc['dashboards'] = sorted([d.name for d in dashboards]) ifc = _get_dashboard_data( - ifc, ifc_services_and_customers.get('customers', [])) - ifc = _add_region_data(ifc, nren_regions) + ifc, ifc_services_and_customers.get('customers', []), nren_regions) port_type = _get_port_type(ifc['description']) ifc['port_type'] = port_type yield ifc