Example #1
0
def _transform_dashlets_mut(dashlet_spec):
    # abusing pass by reference to mutate dashlet

    if dashlet_spec['type'] == 'view':
        transform_painter_spec(dashlet_spec)

    # ->2014-10
    if dashlet_spec['type'] == 'pnpgraph':
        if 'service' not in dashlet_spec['single_infos']:
            dashlet_spec['single_infos'].append('service')
        if 'host' not in dashlet_spec['single_infos']:
            dashlet_spec['single_infos'].append('host')

    if dashlet_spec['type'] in ['pnpgraph', 'custom_graph']:
        # -> 1.5.0i2
        if "graph_render_options" not in dashlet_spec:
            dashlet_spec["graph_render_options"] = {
                "show_legend": dashlet_spec.pop("show_legend", False),
                "show_service": dashlet_spec.pop("show_service", True),
            }
        # -> 2.0.0i1
        dashlet_spec["graph_render_options"].setdefault(
            "title_format",
            default_dashlet_graph_render_options["title_format"])
        transform_graph_render_options(dashlet_spec["graph_render_options"])
        title_format = dashlet_spec["graph_render_options"].pop("title_format")
        dashlet_spec.setdefault(
            "title_format", title_format
            or dashlet_spec["graph_render_options"]["title_format"])
        dashlet_spec["graph_render_options"].pop("show_title", None)

    # -> 2.0.0i1 All dashlets have new mandatory title_format
    dashlet_spec.setdefault("title_format", ['plain'])

    return dashlet_spec
Example #2
0
def _transform_dashlets_mut(dashlet_spec: DashletConfig) -> DashletConfig:
    # abusing pass by reference to mutate dashlet
    if dashlet_spec['type'] == 'view':
        transform_painter_spec(dashlet_spec)

    # ->2014-10
    if dashlet_spec['type'] == 'pnpgraph':
        if 'service' not in dashlet_spec['single_infos']:
            dashlet_spec['single_infos'].append('service')
        if 'host' not in dashlet_spec['single_infos']:
            dashlet_spec['single_infos'].append('host')

        # The service context has to be set, otherwise the pnpgraph dashlet would
        # complain about missing context information when displaying host graphs.
        dashlet_spec["context"].setdefault("service", "_HOST_")

    if dashlet_spec['type'] in ['pnpgraph', 'custom_graph']:
        # -> 1.5.0i2
        if "graph_render_options" not in dashlet_spec:
            dashlet_spec["graph_render_options"] = {
                "show_legend": dashlet_spec.pop("show_legend", False),
                "show_service": dashlet_spec.pop("show_service", True),
            }
        # -> 2.0.0b6
        transform_graph_render_options(dashlet_spec["graph_render_options"])
        dashlet_spec["graph_render_options"].pop("show_title", None)
        # title_format is not used in Dashlets (Custom tiltle instead, field 'title')
        dashlet_spec["graph_render_options"].pop("title_format", None)

    if dashlet_spec["type"] == "network_topology":
        # -> 2.0.0i Removed network topology dashlet type
        transform_topology_dashlet(dashlet_spec)

    return dashlet_spec
Example #3
0
def _transform_dashboards(boards):
    # type: (Dict[Tuple[UserId, DashboardName], DashboardConfig]) -> Dict[Tuple[UserId, DashboardName], DashboardConfig]
    for dashboard in boards.values():
        visuals.transform_old_visual(dashboard)

        # Also transform dashlets
        for dashlet in dashboard['dashlets']:
            visuals.transform_old_visual(dashlet)

            if dashlet['type'] == 'view':
                # abusing pass by reference to mutate dashlet
                transform_painter_spec(dashlet)

            if dashlet['type'] == 'pnpgraph':
                if 'service' not in dashlet['single_infos']:
                    dashlet['single_infos'].append('service')
                if 'host' not in dashlet['single_infos']:
                    dashlet['single_infos'].append('host')

    return boards
Example #4
0
def _transform_dashlets_mut(dashlet_spec: DashletConfig) -> DashletConfig:
    # abusing pass by reference to mutate dashlet
    if dashlet_spec["type"] == "view":
        transform_painter_spec(dashlet_spec)

    # ->2014-10
    if dashlet_spec["type"] == "pnpgraph":
        if "service" not in dashlet_spec["single_infos"]:
            dashlet_spec["single_infos"].append("service")
        if "host" not in dashlet_spec["single_infos"]:
            dashlet_spec["single_infos"].append("host")

        # The service context has to be set, otherwise the pnpgraph dashlet would
        # complain about missing context information when displaying host graphs.
        dashlet_spec["context"].setdefault("service", "_HOST_")

    if dashlet_spec["type"] in ["pnpgraph", "custom_graph"]:
        # -> 1.5.0i2
        if "graph_render_options" not in dashlet_spec:
            dashlet_spec["graph_render_options"] = {
                "show_legend": dashlet_spec.pop("show_legend", False),
                "show_service": dashlet_spec.pop("show_service", True),
            }
        # -> 2.0.0b6
        transform_graph_render_options(dashlet_spec["graph_render_options"])
        dashlet_spec["graph_render_options"].pop("show_title", None)
        # title_format is not used in Dashlets (Custom tiltle instead, field 'title')
        dashlet_spec["graph_render_options"].pop("title_format", None)

    if dashlet_spec["type"] == "network_topology":
        # -> 2.0.0i Removed network topology dashlet type
        transform_topology_dashlet(dashlet_spec)

    if dashlet_spec["type"] in ["notifications_bar_chart", "alerts_bar_chart"]:
        # -> v2.0.0b6 introduced the different render modes
        _transform_event_bar_chart_dashlet(dashlet_spec)

    return dashlet_spec