aboutsummaryrefslogtreecommitdiff
path: root/jobs/JobBase.py
diff options
context:
space:
mode:
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