Allow users to set periodic notifications on all notification types
In some cases, users may want to send periodic notifications for notification types other than webhooks. Story: 2006837 Task: 37412 Change-Id: Icd1b12f4b1e452f8285b8402f49815dd7f72b1ea
This commit is contained in:
parent
efc6e28edc
commit
044b9c7d11
@ -47,7 +47,7 @@ class NotificationEngine(object):
|
|||||||
def _add_periodic_notifications(self, notifications):
|
def _add_periodic_notifications(self, notifications):
|
||||||
for notification in notifications:
|
for notification in notifications:
|
||||||
period = str(notification.period)
|
period = str(notification.period)
|
||||||
if period in CONF.kafka.periodic.keys() and notification.type == "webhook":
|
if period in CONF.kafka.periodic.keys():
|
||||||
notification.notification_timestamp = time.time()
|
notification.notification_timestamp = time.time()
|
||||||
self._producer.publish(CONF.kafka.periodic[period],
|
self._producer.publish(CONF.kafka.periodic[period],
|
||||||
[notification.to_json()])
|
[notification.to_json()])
|
||||||
|
@ -52,7 +52,7 @@ class PeriodicEngine(object):
|
|||||||
self._db_repo = get_db_repo()
|
self._db_repo = get_db_repo()
|
||||||
self._period = period
|
self._period = period
|
||||||
|
|
||||||
def _keep_sending(self, alarm_id, original_state, type, period):
|
def _keep_sending(self, alarm_id, original_state, period):
|
||||||
try:
|
try:
|
||||||
current_state = self._db_repo.get_alarm_current_state(alarm_id)
|
current_state = self._db_repo.get_alarm_current_state(alarm_id)
|
||||||
except exceptions.DatabaseException:
|
except exceptions.DatabaseException:
|
||||||
@ -68,8 +68,6 @@ class PeriodicEngine(object):
|
|||||||
# Period changed
|
# Period changed
|
||||||
if period != self._period:
|
if period != self._period:
|
||||||
return False
|
return False
|
||||||
if type != "webhook":
|
|
||||||
return False
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -86,7 +84,6 @@ class PeriodicEngine(object):
|
|||||||
|
|
||||||
if self._keep_sending(notification.alarm_id,
|
if self._keep_sending(notification.alarm_id,
|
||||||
notification.state,
|
notification.state,
|
||||||
notification.type,
|
|
||||||
notification.period):
|
notification.period):
|
||||||
|
|
||||||
wait_duration = notification.period - (
|
wait_duration = notification.period - (
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- Allows periodic notifications to be used for all notification types.
|
Loading…
Reference in New Issue
Block a user