Skip to content
Snippets Groups Projects
Select Git revision
  • 3ff6f95bcf427eeeb56ec75ff1119a8ceac5c9ce
  • python3 default protected
  • feature/exabgp_support2
  • feature/exabgp_support2.bgpextcommunity
  • feature/exabgp_support2.django4.2
  • fix/existingcheck_honor_fragtype
  • feature/python3-authz_netmask
  • feature/authz_netmask
  • fix/wrong_ratelimit_stats
  • feature/requirements_version_update2024-01
  • feature/split_celery
  • feature/improved-warning-mails
  • fix/reenable_expireset_via_restapi
  • feature/admin_user_delete_with_owned_rule_reassigning1
  • feature/admin_user_delete_with_owned_rule_reassigning
  • feature/branded_doc
  • fix/forked_snmp_polling_worker_exit_issue
  • fix/false_user_activation_error
  • feature/exabgp_with_docker-compose
  • fix/prefix_overlap_handling
  • fix/js_security_issues-a
  • save1
  • rpm-1.5-7
  • working1
  • myv1.6
  • t12b1
  • v1.5_newnew2
  • merged_final
  • v1.5_newnew
  • startstop_old
  • myadd2
  • tomas3
  • merge_jra2t6_and_RESTAPI
  • mytomas2
  • mynew1
  • new_jra2t6
  • v1.5_final
  • fod16_ruleroutes-merged_old
  • merged_new
  • v1.6_new_old
  • v1.5_new_old_follower
41 results

manage.py

Blame
  • eumetsat.py 3.37 KiB
    import operator
    from brian_dashboard_manager.templating.helpers \
        import get_dashboard_data, letter_generator, create_panel
    
    
    def get_panel_data(all_subscriptions):
        """
        Helper for generating multicast panel data from subscriptions
        which are duplicated across all routers
    
        :param all_subscriptions: list of subscriptions
        :return: dict of dashboard name to list of panels.
        """
    
        result = dict()
    
        def _panel(s):
            return {
                'measurement': 'multicast_rates',
                'title': f'{s["subscription"]} on {s["router"]}',
                'subscription': s['subscription'],
                'hostname': s['router']
            }
    
        for subscription in all_subscriptions:
            dashboard_name = f'{subscription["router"]} subscriptions'
            result.setdefault(dashboard_name, []).append(_panel(subscription))
    
        # make the panels sorted deterministically
        for name in result.keys():
            result[name] = sorted(
                result[name],
                key=operator.itemgetter('subscription'))
    
        return result
    
    
    def get_panel_fields(panel, panel_type, datasource):
        """
        Helper for generating a single multicast panel
    
        :param panel: panel data
        :param panel_type: type of panel (traffic, errors, etc.)
        :param datasource: datasource to use
        :return: panel data
        """
        letters = letter_generator()
    
        def get_target_data(alias, field):
            return {
                # panel includes identifying information
                # such as hostname, subscription, etc.
                **panel,
                'alias': alias,
                'refId': next(letters),
                'select_field': field
                # 'percentile': 'percentile' in alias.lower(),
            }
    
        targets = [("Multicast Traffic", "octets")]
        title = panel.pop("title").format(panel_type)
        return create_panel(
            **panel,
            datasource=datasource,
            linewidth=1,
            title=title,
            panel_targets=[get_target_data(*target) for target in targets],
            y_axis_type="bits",
        )
    
    
    def subscription_panel_generator(gridPos):
        """
        Generates panels used for multicast traffic dashboards
    
        :param gridPos: generator of grid positions
        :return: function that generates panels
        """
        def get_panel_definitions(panels, datasource, errors=False):
            result = []
    
            for panel in panels:
                result.append(get_panel_fields({
                    **panel,
                    **next(gridPos)
                }, 'traffic', datasource))
                if panel.get('has_v6', False):
                    result.append(get_panel_fields({
                        **panel,
                        **next(gridPos)
                    }, 'IPv6', datasource))
                if errors:
                    result.append(get_panel_fields({
                        **panel,
                        **next(gridPos)
                    }, 'errors', datasource))
    
            return result
    
        return get_panel_definitions
    
    
    def generate_eumetsat_multicast(subscriptions, datasource):
        """
        Generates EUMETSAT multicast dashboards
    
        :param subscriptions: list of subscriptions
        :param datasource: datasource to use
        :return: generator of dashboards
        """
    
        panel_data = get_panel_data(subscriptions)
        for dash in get_dashboard_data(
                data=panel_data,
                datasource=datasource,
                tag='EUMET_MULTICAST',
                panel_generator=subscription_panel_generator):
    
            yield dash