Commit fe280b61 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'fix-avs-objectmetrics-catch-value-error' into 'master'

Catch ValueError on objectmetrics NBI API.

See merge request noc/noc!6252
parents 96052492 0027b3f4
......@@ -108,9 +108,16 @@ class ObjectMetricsAPI(NBIAPI):
scopes = {} # table_name -> ([fields, ..], [where, ..])
for mc in req.metrics:
profile = profiles[mc.object]
ifaces = tuple(
sorted(profile.convert_interface_name(i) for i in getattr(mc, "interfaces", []))
)
try:
ifaces = tuple(
sorted(profile.convert_interface_name(i) for i in getattr(mc, "interfaces", []))
)
except ValueError:
HTTPException(
400,
f'Invalid interface name: {",".join(getattr(mc, "interfaces", []))} '
f"for device: {mc.object}",
)
for mn in mc.metric_types:
mt = MetricType.get_by_name(mn)
if not mt:
......
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