...
 
Commits (2)
...@@ -90,7 +90,7 @@ class BaseTTSystem(object): ...@@ -90,7 +90,7 @@ class BaseTTSystem(object):
""" """
raise NotImplementedError() raise NotImplementedError()
def close_tt(self, tt_id, subject=None, body=None, reason=None, login=None): def close_tt(self, tt_id, subject=None, body=None, reason=None, login=None, queue=None):
""" """
Close TT Close TT
:param tt_id: TT id, as returned by create_tt :param tt_id: TT id, as returned by create_tt
...@@ -98,18 +98,20 @@ class BaseTTSystem(object): ...@@ -98,18 +98,20 @@ class BaseTTSystem(object):
:param body: Closing message body :param body: Closing message body
:param reason: Final reason :param reason: Final reason
:param login: User login :param login: User login
:param queue: ticket queue
:returns: Boolean. True, when alarm is closed properly :returns: Boolean. True, when alarm is closed properly
:raises TTError: :raises TTError:
""" """
raise NotImplementedError() raise NotImplementedError()
def add_comment(self, tt_id, subject=None, body=None, login=None): def add_comment(self, tt_id, subject=None, body=None, login=None, queue=None):
""" """
Append comment to TT Append comment to TT
:param tt_id: TT id, as returned by create_tt :param tt_id: TT id, as returned by create_tt
:param subject: Closing message subject :param subject: Closing message subject
:param body: Closing message body :param body: Closing message body
:param login: User login :param login: User login
:param queue: ticket queue
:raises TTError: :raises TTError:
""" """
raise NotImplementedError() raise NotImplementedError()
......
...@@ -337,6 +337,8 @@ class ActiveAlarm(Document): ...@@ -337,6 +337,8 @@ class ActiveAlarm(Document):
if self.clear_notification_group if self.clear_notification_group
else None, else None,
close_tt=self.close_tt, close_tt=self.close_tt,
login="correlator",
queue=a.managed_object.tt_queue,
) )
# Gather diagnostics # Gather diagnostics
AlarmDiagnosticConfig.on_clear(a) AlarmDiagnosticConfig.on_clear(a)
......
...@@ -41,7 +41,7 @@ retry_lock = threading.Lock() ...@@ -41,7 +41,7 @@ retry_lock = threading.Lock()
next_retry = datetime.datetime.now() next_retry = datetime.datetime.now()
def escalate(alarm_id, escalation_id, escalation_delay, *args, **kwargs): def escalate(alarm_id, escalation_id, escalation_delay, login="correlator", *args, **kwargs):
def log(message, *args): def log(message, *args):
msg = message % args msg = message % args
logger.info("[%s] %s", alarm_id, msg) logger.info("[%s] %s", alarm_id, msg)
...@@ -187,7 +187,7 @@ def escalate(alarm_id, escalation_id, escalation_delay, *args, **kwargs): ...@@ -187,7 +187,7 @@ def escalate(alarm_id, escalation_id, escalation_delay, *args, **kwargs):
reason=pre_reason, reason=pre_reason,
subject=subject, subject=subject,
body=body, body=body,
login="correlator", login=login,
timestamp=alarm.timestamp, timestamp=alarm.timestamp,
) )
except TemporaryTTError as e: except TemporaryTTError as e:
...@@ -247,7 +247,10 @@ def escalate(alarm_id, escalation_id, escalation_delay, *args, **kwargs): ...@@ -247,7 +247,10 @@ def escalate(alarm_id, escalation_id, escalation_delay, *args, **kwargs):
try: try:
log("Appending comment to TT %s", tt_id) log("Appending comment to TT %s", tt_id)
tts.add_comment( tts.add_comment(
c_tt_id, body="Covered by TT %s" % tt_id, login="correlator" c_tt_id,
body="Covered by TT %s" % tt_id,
login=login,
queue=mo.tt_queue,
) )
metrics["escalation_tt_comment"] += 1 metrics["escalation_tt_comment"] += 1
except NotImplementedError: except NotImplementedError:
...@@ -294,17 +297,22 @@ def escalate(alarm_id, escalation_id, escalation_delay, *args, **kwargs): ...@@ -294,17 +297,22 @@ def escalate(alarm_id, escalation_id, escalation_delay, *args, **kwargs):
if alarm.clear_notification_group if alarm.clear_notification_group
else None, else None,
close_tt=alarm.close_tt, close_tt=alarm.close_tt,
login=login,
queue=mo.tt_queue,
) )
elif nalarm == "A" and not nalarm.escalation_tt and tt_id: elif nalarm == "A" and not nalarm.escalation_tt and tt_id:
logger.error("[%s] Alarm without escalation TT: %s", alarm.id, tt_id) logger.error("[%s] Alarm without escalation TT: %s", alarm.id, tt_id)
logger.info("[%s] Escalations loop end", alarm_id) logger.info("[%s] Escalations loop end", alarm_id)
def notify_close(alarm_id, tt_id, subject, body, notification_group_id, close_tt=False): def notify_close(
alarm_id, tt_id, subject, body, notification_group_id, close_tt=False, login=None, queue=None
):
def log(message, *args): def log(message, *args):
msg = message % args msg = message % args
logger.info("[%s] %s", alarm_id, msg) logger.info("[%s] %s", alarm_id, msg)
login = login or "correlator"
if tt_id: if tt_id:
alarm = get_alarm(alarm_id) alarm = get_alarm(alarm_id)
alarm.set_escalation_close_ctx() alarm.set_escalation_close_ctx()
...@@ -325,7 +333,7 @@ def notify_close(alarm_id, tt_id, subject, body, notification_group_id, close_tt ...@@ -325,7 +333,7 @@ def notify_close(alarm_id, tt_id, subject, body, notification_group_id, close_tt
# Close tt # Close tt
try: try:
log("Closing TT %s", tt_id) log("Closing TT %s", tt_id)
tts.close_tt(c_tt_id, subject=subject, body=body, login="correlator") tts.close_tt(c_tt_id, subject=subject, body=body, login=login, queue=queue)
metrics["escalation_tt_close"] += 1 metrics["escalation_tt_close"] += 1
if alarm: if alarm:
alarm.close_escalation() alarm.close_escalation()
...@@ -349,7 +357,9 @@ def notify_close(alarm_id, tt_id, subject, body, notification_group_id, close_tt ...@@ -349,7 +357,9 @@ def notify_close(alarm_id, tt_id, subject, body, notification_group_id, close_tt
# Append comment to tt # Append comment to tt
try: try:
log("Appending comment to TT %s", tt_id) log("Appending comment to TT %s", tt_id)
tts.add_comment(c_tt_id, subject=subject, body=body, login="correlator") tts.add_comment(
c_tt_id, subject=subject, body=body, login=login, queue=queue
)
metrics["escalation_tt_comment"] += 1 metrics["escalation_tt_comment"] += 1
except TTError as e: except TTError as e:
log("Failed to add comment to %s: %s", tt_id, e) log("Failed to add comment to %s: %s", tt_id, e)
......
...@@ -41,7 +41,7 @@ class StubTTSystem(BaseTTSystem): ...@@ -41,7 +41,7 @@ class StubTTSystem(BaseTTSystem):
) )
return str(uuid.uuid4()) return str(uuid.uuid4())
def add_comment(self, tt_id, subject=None, body=None, login=None): def add_comment(self, tt_id, subject=None, body=None, login=None, queue=None):
self.logger.info( self.logger.info(
"add_comment(tt_id=%s, subject=%s, body=%s, login=%s)", tt_id, subject, body, login "add_comment(tt_id=%s, subject=%s, body=%s, login=%s)", tt_id, subject, body, login
) )
...@@ -63,7 +63,7 @@ class StubTTSystem(BaseTTSystem): ...@@ -63,7 +63,7 @@ class StubTTSystem(BaseTTSystem):
""" """
self.logger.info("Object %s appended to group TT %s", obj, gtt_id) self.logger.info("Object %s appended to group TT %s", obj, gtt_id)
def close_tt(self, tt_id, subject=None, body=None, reason=None, login=None): def close_tt(self, tt_id, subject=None, body=None, reason=None, login=None, queue=None):
""" """
Close TT Close TT
:param tt_id: TT id, as returned by create_tt :param tt_id: TT id, as returned by create_tt
...@@ -71,6 +71,7 @@ class StubTTSystem(BaseTTSystem): ...@@ -71,6 +71,7 @@ class StubTTSystem(BaseTTSystem):
:param body: Closing message body :param body: Closing message body
:param reason: Final reason :param reason: Final reason
:param login: User login :param login: User login
:param queue: ticket queue
:returns: Boolean. True, when alarm is closed properly :returns: Boolean. True, when alarm is closed properly
:raises TTError: :raises TTError:
""" """
......