renamed filters to tasks... members.py needs some fixes now. think it is a good style to manage post processing.
This commit is contained in:
parent
533cf02c10
commit
851069cc2a
8 changed files with 55 additions and 48 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
from config import *
|
from config import *
|
||||||
from core import *
|
from core import *
|
||||||
from filters import *
|
from tasks import *
|
||||||
from parser import *
|
from parser import *
|
||||||
from service import *
|
from service import *
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import json
|
import json
|
||||||
from filters import parseFilterList
|
from tasks import parseTaskList
|
||||||
from members import parseMemberList
|
from members import parseMemberList
|
||||||
from periods import parsePeriodList
|
from periods import parsePeriodList
|
||||||
#from hostgroups import parseHostGroupList
|
#from hostgroups import parseHostGroupList
|
||||||
|
|
@ -15,8 +15,8 @@ class Config:
|
||||||
|
|
||||||
self.dict = json.loads(self.config)
|
self.dict = json.loads(self.config)
|
||||||
|
|
||||||
self.filters = parseFilterList(self.dict['filters'])
|
self.tasks = parseTaskList(self.dict['tasks'])
|
||||||
self.members = parseMemberList(self.dict['members'], self.filters, log)
|
self.members = parseMemberList(self.dict['members'], self.tasks, log)
|
||||||
self.periods = parsePeriodList(self.dict['periods'], log)
|
self.periods = parsePeriodList(self.dict['periods'], log)
|
||||||
#self.hostgroups = parseHostGroupList(self.dict['hostgroups'],
|
#self.hostgroups = parseHostGroupList(self.dict['hostgroups'],
|
||||||
# self.members,
|
# self.members,
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
class Filter:
|
|
||||||
def __init__(self, name="", command="", priority=0, comment=""):
|
|
||||||
self.name = name
|
|
||||||
self.command = command
|
|
||||||
self.priority = priority
|
|
||||||
self.comment = comment
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return "Filter('Name: " + self.name + "', 'Command: " + self.command + "', 'Priority: " + str(
|
|
||||||
self.priority) + "')"
|
|
||||||
|
|
||||||
def clone(self):
|
|
||||||
return Filter(self.name, self.command, self.priority, self.comment)
|
|
||||||
|
|
||||||
|
|
||||||
def parseFilterList(filters):
|
|
||||||
return [Filter(name, **values) for name, values in filters.items()]
|
|
||||||
16
lib/config/tasks.py
Normal file
16
lib/config/tasks.py
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
class Task:
|
||||||
|
def __init__(self, name="", command="", priority=0, comment=""):
|
||||||
|
self.name = name
|
||||||
|
self.command = command
|
||||||
|
self.priority = priority
|
||||||
|
self.comment = comment
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Task('Name: " + self.name + "', 'Command: " + self.command + "', 'Priority: " + str(self.priority) + "')"
|
||||||
|
|
||||||
|
def clone(self):
|
||||||
|
return Task(self.name, self.command, self.priority, self.comment)
|
||||||
|
|
||||||
|
|
||||||
|
def parseTaskList(tasks):
|
||||||
|
return [Task(name, **values) for name, values in tasks.items()]
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
"""
|
|
||||||
The email filter in pure Python.
|
|
||||||
"""
|
|
||||||
3
lib/tasks/email.py
Normal file
3
lib/tasks/email.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
"""
|
||||||
|
The email task.
|
||||||
|
"""
|
||||||
|
|
@ -1,42 +1,50 @@
|
||||||
{
|
{
|
||||||
"filters":{
|
"tasks":{
|
||||||
"email":{
|
"email":{
|
||||||
"command":"email @member @+message",
|
"command": "email @member @+message",
|
||||||
"comment":"Sends an E-Mail to the member.",
|
"comment": "Sends an E-Mail to a member.",
|
||||||
"priority":1
|
"priority": 2
|
||||||
|
},
|
||||||
|
"sms":{
|
||||||
|
"command": "sms @member @+message",
|
||||||
|
"comment": "Sends a SMS to a member.",
|
||||||
|
"priority": 1
|
||||||
|
},
|
||||||
|
"mongodb":{
|
||||||
|
"command": "mongodb @host @user @password @+rawdata",
|
||||||
|
"comment": "Stores the rawdata in a MongoDB database.",
|
||||||
|
"priority": 1000
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"members":{
|
"members":{
|
||||||
"hanez":{
|
"hanez":{
|
||||||
"name":"Johannes Findeisen",
|
"name": "Johannes Findeisen",
|
||||||
"comment":"Just a nerd doing admin stuff...",
|
"comment": "Just a nerd doing admin stuff.",
|
||||||
"parent": "darth",
|
"parent": "darth",
|
||||||
"filters":{ "email":"you@hanez.org" }
|
"tasks":[{ "class": "email", "args": { "rcpt": "you@hanez.org" }},
|
||||||
|
{ "class": "sms","args": { "rcpt": "+49110"}}]
|
||||||
},
|
},
|
||||||
"darth":{
|
"darth":{
|
||||||
"name":"Darth Vader",
|
"name": "Darth Vader",
|
||||||
"comment":"The father",
|
"comment": "The father",
|
||||||
"filters":{ "email":"darth.vader@hanez.org" }
|
"tasks":{ "class": "email", "args": { "rcpt": "darth.vader@hanez.org" }}
|
||||||
|
},
|
||||||
|
"mongodb":{
|
||||||
|
"name": "MongoDB",
|
||||||
|
"comment": "The writer to a MongoDB",
|
||||||
|
"tasks":{ "class": "mongodb", "args": { "host": "localhost", "user": "root", "password": "root" }}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"periods":{
|
"periods":{
|
||||||
"short":{
|
"short":{ "seconds": 5, "comment": "Interval job; every 10 seconds" },
|
||||||
"seconds":5,
|
"middle":{ "seconds": 60,"comment": "Interval job; every 60 seconds" },
|
||||||
"comment":"Interval job; every 10 seconds"
|
"long":{ "minutes": 2,"comment": "Interval job; every 2 minutes" },
|
||||||
},
|
"christmas2013":{ "date": "2013-12-24 20:00:00", "comment": "Date Job; just one day at 8PM" }
|
||||||
"middle":{
|
|
||||||
"seconds":60,
|
|
||||||
"comment":"Interval job; every 60 seconds"
|
|
||||||
},
|
|
||||||
"long":{
|
|
||||||
"minutes":2,
|
|
||||||
"comment":"Interval job; every 2 minutes"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"hostgroups":{
|
"hostgroups":{
|
||||||
"group1":{
|
"group1":{
|
||||||
"members":[ "hanez" ],
|
"members": [ "hanez", "mongodb" ],
|
||||||
"hosts":[ "a.systemchaos.org", "b.systemchaos.org" ],
|
"hosts": [ "a.systemchaos.org", "b.systemchaos.org" ],
|
||||||
"parents": [ "network" ],
|
"parents": [ "network" ],
|
||||||
"services":[
|
"services":[
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue