Verified Commit a30f9161 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Fix custom labels format.

parent 98835a6a
Pipeline #36643 passed with stages
in 13 minutes and 53 seconds
......@@ -44,6 +44,7 @@ class Script(BaseScript):
"status": True,
"description": f"Цифровой вход номер {i}",
"measurement": "Scalar",
"labels": ["noc::sensor::placement::external"],
"snmp_oid": f"1.3.6.1.4.1.35419.20.1.{100 + i}.0",
}
]
......
......@@ -6,7 +6,7 @@
# ---------------------------------------------------------------------
# Python Modules
from typing import Dict
from typing import Dict, List
# NOC modules
from noc.core.script.base import BaseScript
......@@ -17,7 +17,7 @@ class Script(BaseScript):
name = "Generic.get_inventory"
interface = IGetInventory
def get_sensor_labels(self) -> Dict[str, str]:
def get_sensor_labels(self) -> Dict[str, List[str]]:
"""
For customizing. Return map sensor_name -> label.
For sensor classification
......@@ -62,9 +62,9 @@ class Script(BaseScript):
return chassis
for ss in sensors:
if ss["name"] in sensor_labels and "labels" in ss:
ss["labels"] += [sensor_labels[ss["name"]]]
ss["labels"] += sensor_labels[ss["name"]]
elif ss["name"] in sensor_labels and "labels" not in ss:
ss["labels"] = [sensor_labels[ss["name"]]]
ss["labels"] = sensor_labels[ss["name"]]
return chassis
def execute_snmp(self):
......
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