Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
arthur-zzz
noc
Commits
d950216e
Verified
Commit
d950216e
authored
Nov 24, 2021
by
Andrey Vertiprahov
Browse files
Fix calculate effective_labels.
parent
fb0ccec3
Changes
2
Hide whitespace changes
Inline
Side-by-side
fm/models/activealarm.py
View file @
d950216e
...
...
@@ -8,6 +8,7 @@
# Python modules
import
datetime
from
collections
import
defaultdict
from
itertools
import
chain
from
typing
import
Optional
,
Set
,
Any
,
Dict
# Third-party modules
...
...
@@ -174,7 +175,7 @@ class ActiveAlarm(Document):
self
.
rca_neighbors
=
data
.
rca_neighbors
self
.
dlm_windows
=
data
.
dlm_windows
if
not
self
.
id
:
self
.
effective_labels
=
self
.
iter_effective_labels
(
self
)
self
.
effective_labels
=
list
(
chain
.
from_iterable
(
self
.
iter_effective_labels
(
self
)
))
def
safe_save
(
self
,
**
kwargs
):
"""
...
...
@@ -855,14 +856,16 @@ class ActiveAlarm(Document):
@
classmethod
def
iter_effective_labels
(
cls
,
instance
:
"ActiveAlarm"
):
return
[
ll
for
ll
in
instance
.
managed_object
.
effective_labels
if
cls
.
can_set_label
(
ll
)]
yield
instance
.
labels
yield
[
ll
for
ll
in
instance
.
managed_object
.
effective_labels
if
Label
.
get_effective_setting
(
ll
,
"expose_alarm"
)
]
@
classmethod
def
can_set_label
(
cls
,
label
):
return
Label
.
get_effective_setting
(
label
,
"enable_alarm"
)
or
Label
.
get_effective_setting
(
label
,
"expose_alarm"
)
return
Label
.
get_effective_setting
(
label
,
"enable_alarm"
)
class
ComponentHub
(
object
):
...
...
services/correlator/alarmrule.py
View file @
d950216e
...
...
@@ -34,7 +34,7 @@ class Group(object):
reference_template
:
Template
alarm_class
:
AlarmClass
title_template
:
Template
labels
:
Optional
[
List
[
str
]]
labels
:
Optional
[
List
[
str
]]
=
None
@
dataclass
...
...
@@ -42,7 +42,7 @@ class GroupItem(object):
reference
:
str
alarm_class
:
AlarmClass
title
:
str
labels
:
Optional
[
List
[
str
]]
labels
:
Optional
[
List
[
str
]]
=
None
class
AlarmRule
(
object
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment