Verified Commit 1c8d0e55 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Fix getting service on clear_alarm API view.

parent 96052492
......@@ -52,6 +52,7 @@ from noc.fm.models.alarmplugin import AlarmPlugin
from noc.core.translation import ugettext as _
from noc.fm.models.alarmescalation import AlarmEscalation
from noc.core.comp import smart_text
from noc.core.service.loader import get_service
def get_advanced_field(id):
......@@ -687,9 +688,10 @@ class AlarmApplication(ExtApplication):
# Send clear signal to the correlator
fm_pool = alarm.managed_object.get_effective_fm_pool().name
stream = f"dispose.{fm_pool}"
num_partitions = asyncio.run(self.service.get_stream_partitions(stream))
service = get_service()
num_partitions = asyncio.run(service.get_stream_partitions(stream))
partition = int(alarm.managed_object.id) % num_partitions
self.service.publish(
service.publish(
orjson.dumps(
{
"$op": "clearid",
......
......@@ -21,6 +21,7 @@ from noc.maintenance.models.maintenance import (
from noc.sa.models.profile import Profile
from noc.sa.models.managedobject import ManagedObject
from noc.sa.models.useraccess import UserAccess
from noc.main.models.label import Label
from noc.core.translation import ugettext as _
......@@ -101,7 +102,21 @@ class MaintenanceApplication(ExtDocApplication):
"profile": Profile.get_by_id(mo["profile"]).name,
"address": mo["address"],
"description": mo["description"],
"labels": mo["labels"],
"labels": [
{
"id": ll.name,
"is_protected": ll.is_protected,
"scope": ll.scope,
"name": ll.name,
"value": ll.value,
"badges": ll.badges,
"bg_color1": f"#{ll.bg_color1:06x}",
"fg_color1": f"#{ll.fg_color1:06x}",
"bg_color2": f"#{ll.bg_color2:06x}",
"fg_color2": f"#{ll.fg_color2:06x}",
}
for ll in Label.objects.filter(name__in=mo["labels"])
],
}
]
......
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