aboutsummaryrefslogtreecommitdiff
path: root/jobs/JobBase.py
diff options
context:
space:
mode:
authorTom <tom@ritter.vg>2016-12-28 13:59:43 -0600
committerTom Ritter <tom@ritter.vg>2016-12-28 14:37:55 -0600
commit3e85f1d0d48f0fb65a83af6ce3fb4b6a08f0bb1a (patch)
tree43367c6c5c98bf31759e576bcf43efabd4772e57 /jobs/JobBase.py
parent50111ca74eaa5b14253814a9aa39e35b40480935 (diff)
Create an option that lets you require two failures before alerting.
Diffstat (limited to 'jobs/JobBase.py')
-rwxr-xr-xjobs/JobBase.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/jobs/JobBase.py b/jobs/JobBase.py
index 78c8c71..6b47eb7 100755
--- a/jobs/JobBase.py
+++ b/jobs/JobBase.py
@@ -22,6 +22,10 @@ class JobFailureNotificationFrequency:
EVERYDAY = "day"
ONSTATECHANGE = "state_change"
+class JobFailureCountMinimumBeforeNotification:
+ ONE = "one"
+ TWO = "two"
+
class JobBase(object):
def __init__(self, config, *args):
self.config = config
@@ -47,6 +51,14 @@ class JobBase(object):
"""Returns True if the jobmanager should call 'onFailure' to alert the admin"""
def shouldNotifyFailure(self, jobState):
notifyFrequency = self.notifyOnFailureEvery()
+ minFailureCount = self.numberFailuresBeforeNotification()
+
+ if minFailureCount == JobFailureCountMinimumBeforeNotification.ONE:
+ pass
+ elif minFailureCount == JobFailureCountMinimumBeforeNotification.TWO:
+ if jobState.CurrentStateSuccess:
+ return False
+
if notifyFrequency == JobFailureNotificationFrequency.EVERYTIME:
return True
elif notifyFrequency == JobFailureNotificationFrequency.EVERYFIVEMINUTES:
@@ -95,6 +107,12 @@ class JobBase(object):
pass
"""OVERRIDE ME
+ Returns a JobFailureCountMinimumBeforeNotification indicating how many
+ failures should occur before a notification email should be sent"""
+ def numberFailuresBeforeNotification(self):
+ pass
+
+ """OVERRIDE ME
Executes the job's actions, and returns true to indicate the job succeeded."""
def execute(self):
pass