Commit 889ee71a authored by MaksimSmile13's avatar MaksimSmile13
Browse files

Merge branch 'fix/ddash' into 'master'

Fix ddash

See merge request !2479
parents 91726f39 7561a6f4
Pipeline #15241 passed with stages
in 16 minutes and 50 seconds
......@@ -6,7 +6,6 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
from __future__ import absolute_import
......@@ -59,8 +58,17 @@ class MODashboard(BaseDashboard):
return metrics
return None
def check_metrics(metric):
"""
Object check metrics
"""
if metric.name.startswith("Check"):
return True
return False
port_types = []
object_metrics = []
object_check_metrics = []
lags = []
subif = []
radio_types = []
......@@ -132,17 +140,24 @@ class MODashboard(BaseDashboard):
if self.object.object_profile.report_ping_rtt:
object_metrics += ["rtt"]
om = []
ocm = []
for m in self.object.object_profile.metrics or []:
mt = MetricType.get_by_id(m["metric_type"])
if not mt or not (m.get("enable_periodic", False) or m.get("enable_box", False)):
continue
if check_metrics(mt):
ocm += [{"name": mt.name, "metric": mt.field_name}]
continue
om += [mt.name]
object_metrics.extend(sorted(om))
object_check_metrics.extend(sorted(ocm))
return {
"port_types": port_types,
"object_metrics": object_metrics,
"object_check_metrics": object_check_metrics,
"lags": lags,
"subifaces": subif,
"radio_types": radio_types,
......@@ -153,6 +168,7 @@ class MODashboard(BaseDashboard):
context = {
"port_types": self.object_data["port_types"],
"object_metrics": self.object_data["object_metrics"],
"object_check_metrics": self.object_data["object_check_metrics"],
"lags": self.object_data["lags"],
"device": self.object.name.replace('"', ""),
"ip": self.object.address,
......
{% macro radio(port_type) -%}
{% if port_type["ports"][0] and port_type["ports"][0]["descr"] %}
{% set port_name = port_type["ports"][0]["descr"] %}
{% elif port_type["ports"][0] and port_type["ports"][0]["name"] %}
{% set port_name = port_type["ports"][0]["name"] %}
{% elif port_type["ports"][0] %}
{% set port_name = "Lag w/o interfaces" %}
{%endif%}
{% set comma = joiner(",") -%}
{
"current": {
"selected": true,
"tags": [],
"text": "All",
"value": [
"$__all"
]
},
"datasource": null,
"hide": 0,
"includeAll": true,
"label": "{{port_type.name}}",
"multi": true,
"name": "{{port_type.type}}",
"options": [
{
"selected": false,
"text": "All",
"value": "$__all"
},
{%for port in port_type.ports -%}
{{ comma() }}{
"selected": false,
"text": "{%- if port.descr -%}{{port.name}} status : {{ port.status }} ({{port.descr}}){%else%}{{port.name}} status : {{ port.status }}{%- endif -%}",
"value": "{{port.name}}"
}
{%- endfor %}
],
"query": "{%- for port in port_type.ports %}{{port.name}},{% endfor %}",
"refresh": 0,
"type": "custom"
}
{%- endmacro %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment