...
 
Commits (4)
......@@ -65,6 +65,7 @@ class EscalationItem(EmbeddedDocument):
clear_template = ForeignKeyField(Template)
create_tt = BooleanField(default=False)
promote_group_tt = BooleanField(default=True)
promote_affected_tt = BooleanField(default=True)
close_tt = BooleanField(default=False)
wait_tt = BooleanField(default=False)
# Stop or continue to next rule
......
......@@ -197,12 +197,14 @@ class MODiscoveryJob(PeriodicJob):
:return:
"""
from noc.fm.models.activealarm import ActiveAlarm
from noc.fm.models.alarmescalation import AlarmEscalation
now = datetime.datetime.now()
umbrella = ActiveAlarm.objects.filter(
alarm_class=umbrella_cls.id, managed_object=self.object.id
).first()
u_sev = sum(d.get("severity", 0) for d in details)
umbrella_changed = False
if not umbrella and not details:
# No money, no honey
return
......@@ -216,10 +218,12 @@ class MODiscoveryJob(PeriodicJob):
)
umbrella.save()
self.logger.info("Opening umbrella alarm %s (%s)", umbrella.id, umbrella_cls.name)
umbrella_changed = True
elif umbrella and not details:
# Close existing umbrella
self.logger.info("Clearing umbrella alarm %s (%s)", umbrella.id, umbrella_cls.name)
umbrella.clear_alarm("Closing umbrella")
umbrella_changed = True
elif umbrella and details and u_sev != umbrella.severity:
self.logger.info(
"Change umbrella alarm %s severity %s -> %s (%s)",
......@@ -229,6 +233,7 @@ class MODiscoveryJob(PeriodicJob):
umbrella_cls.name,
)
umbrella.change_severity(severity=u_sev)
umbrella_changed = True
# Get existing details for umbrella
active_details = {} # (alarm class, path) -> alarm
if umbrella:
......@@ -253,6 +258,7 @@ class MODiscoveryJob(PeriodicJob):
d_sev,
)
active_details[d_key].change_severity(severity=d_sev)
umbrella_changed = True
elif d_key not in active_details:
# Create alarm
self.logger.info("Create detail alarm to path %s", d_key)
......@@ -276,10 +282,14 @@ class MODiscoveryJob(PeriodicJob):
self.logger.info(
"Opening detail alarm %s %s (%s)", da.id, d_path, da.alarm_class.name
)
umbrella_changed = True
# Close details when necessary
for d in set(active_details) - seen:
self.logger.info("Clearing detail alarm %s", active_details[d].id)
active_details[d].clear_alarm("Closing")
umbrella_changed = True
if umbrella and umbrella_changed:
AlarmEscalation.watch_escalations(umbrella)
def update_alarms(self):
from noc.fm.models.alarmseverity import AlarmSeverity
......
......@@ -206,28 +206,33 @@ def escalate(alarm_id, escalation_id, escalation_delay, login="correlator", *arg
log("Promoting to group tt")
gtt = tts.create_group_tt(tt_id, alarm.timestamp)
# Append affected objects
for ao in alarm.iter_affected():
if ao.can_escalate(True):
if ao.tt_system == mo.tt_system:
log("Appending object %s to group tt %s", ao.name, gtt)
try:
tts.add_to_group_tt(gtt, ao.tt_system_id)
except TTError as e:
alarm.set_escalation_error(
"[%s] %s" % (mo.tt_system.name, e)
if tts.promote_affected_tt:
for ao in alarm.iter_affected():
if ao.can_escalate(True):
if ao.tt_system == mo.tt_system:
log(
"Appending object %s to group tt %s",
ao.name,
gtt,
)
try:
tts.add_to_group_tt(gtt, ao.tt_system_id)
except TTError as e:
alarm.set_escalation_error(
"[%s] %s" % (mo.tt_system.name, e)
)
else:
log(
"Cannot append object %s to group tt %s: Belongs to other TT system",
ao.name,
gtt,
)
else:
log(
"Cannot append object %s to group tt %s: Belongs to other TT system",
"Cannot append object %s to group tt %s: Escalations are disabled",
ao.name,
gtt,
)
else:
log(
"Cannot append object %s to group tt %s: Escalations are disabled",
ao.name,
gtt,
)
metrics["escalation_tt_create"] += 1
except TTError as e:
log("Failed to create TT: %s", e)
......
......@@ -165,6 +165,13 @@ Ext.define("NOC.fm.alarmescalation.Application", {
width: 50,
renderer: NOC.render.Bool
},
{
text: __("ATT"),
dataIndex: "promote_affected_tt",
editor: "checkboxfield",
width: 50,
renderer: NOC.render.Bool
},
{
text: __("Wait TT"),
dataIndex: "wait_tt",
......