whitespacing.... :)
This commit is contained in:
parent
2671dc3273
commit
927fff0c5e
22 changed files with 66 additions and 109 deletions
|
|
@ -51,9 +51,7 @@ class HostGroup:
|
||||||
#me["processors"] = [processor._to_config_dict(configDict) for processor in self.get_processors()]
|
#me["processors"] = [processor._to_config_dict(configDict) for processor in self.get_processors()]
|
||||||
configDict["hostgroups"][self.get_name()] = me
|
configDict["hostgroups"][self.get_name()] = me
|
||||||
|
|
||||||
|
def __add_internal(self, l, item):
|
||||||
|
|
||||||
def __add_internal(self,l,item):
|
|
||||||
if isinstance(item, list):
|
if isinstance(item, list):
|
||||||
l.extend(item)
|
l.extend(item)
|
||||||
else:
|
else:
|
||||||
|
|
@ -92,7 +90,6 @@ class HostGroup:
|
||||||
def get_members(self):
|
def get_members(self):
|
||||||
return self.members
|
return self.members
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
ret = "HostGroup: " + self.name + " threshold: " + str(self.threshold) + " parent: " + self.parent + "\n"
|
ret = "HostGroup: " + self.name + " threshold: " + str(self.threshold) + " parent: " + self.parent + "\n"
|
||||||
ret += "members: {\n"
|
ret += "members: {\n"
|
||||||
|
|
|
||||||
|
|
@ -116,4 +116,3 @@ def parseHostList(hosts, services, log):
|
||||||
#replace host.service member by parsed HostService Objects
|
#replace host.service member by parsed HostService Objects
|
||||||
host.services = hostServices
|
host.services = hostServices
|
||||||
return parsedHosts
|
return parsedHosts
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ class Layout:
|
||||||
else:
|
else:
|
||||||
self._hostgroups = hostgroups
|
self._hostgroups = hostgroups
|
||||||
|
|
||||||
|
|
||||||
def _to_config_dict(self, configDict):
|
def _to_config_dict(self, configDict):
|
||||||
me = {}
|
me = {}
|
||||||
me["hostgroups"] = [hg.name for hg in self.get_hostgroups()]
|
me["hostgroups"] = [hg.name for hg in self.get_hostgroups()]
|
||||||
|
|
@ -25,7 +24,6 @@ class Layout:
|
||||||
for hostgroup in self.get_hostgroups():
|
for hostgroup in self.get_hostgroups():
|
||||||
hostgroup._to_config_dict(configDict)
|
hostgroup._to_config_dict(configDict)
|
||||||
|
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
|
@ -35,7 +33,6 @@ class Layout:
|
||||||
def get_hostgroups(self):
|
def get_hostgroups(self):
|
||||||
return self._hostgroups
|
return self._hostgroups
|
||||||
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
ret = "Layout: 'Name:" + str(self.name) + "', 'Enabled: " + str(self.enabled) + " "
|
ret = "Layout: 'Name:" + str(self.name) + "', 'Enabled: " + str(self.enabled) + " "
|
||||||
for group in self.hostgroups:
|
for group in self.hostgroups:
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ class Member:
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MemberFilter:
|
class MemberFilter:
|
||||||
def __init__(self, filter, Value):
|
def __init__(self, filter, Value):
|
||||||
self.filter = filter
|
self.filter = filter
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
from os.path import isfile
|
from os.path import isfile
|
||||||
import json
|
import json
|
||||||
import imp
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from layouts import Layout
|
from layouts import Layout
|
||||||
|
|
@ -8,13 +7,11 @@ from hostgroups import HostGroup
|
||||||
from members import Member
|
from members import Member
|
||||||
from periods import CronPeriod, DatePeriod, IntervalPeriod
|
from periods import CronPeriod, DatePeriod, IntervalPeriod
|
||||||
|
|
||||||
|
|
||||||
from lib.services.service import Service
|
from lib.services.service import Service
|
||||||
from lib.processors.processor import Processor
|
from lib.processors.processor import Processor
|
||||||
from lib.parsers.parser import Parser
|
from lib.parsers.parser import Parser
|
||||||
from lib.tasks.task import Task
|
from lib.tasks.task import Task
|
||||||
|
|
||||||
|
|
||||||
MOD_SERVICES = "services"
|
MOD_SERVICES = "services"
|
||||||
MOD_PROCESSORS = "processors"
|
MOD_PROCESSORS = "processors"
|
||||||
MOD_PARSERS = "parsers"
|
MOD_PARSERS = "parsers"
|
||||||
|
|
@ -40,15 +37,14 @@ class ConfigurationException(Exception):
|
||||||
return repr(self.msg)
|
return repr(self.msg)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigParser:
|
class ConfigParser:
|
||||||
def __init__(self, log):
|
def __init__(self, log):
|
||||||
'''
|
"""
|
||||||
initializes a new ConfigParser Object
|
initializes a new ConfigParser Object
|
||||||
|
|
||||||
params:
|
params:
|
||||||
log: pre configured logger Object to post messages while parsing"
|
log: pre configured logger Object to post messages while parsing"
|
||||||
'''
|
"""
|
||||||
self.log = log
|
self.log = log
|
||||||
self.hostgroups = {}
|
self.hostgroups = {}
|
||||||
self.members = {}
|
self.members = {}
|
||||||
|
|
@ -65,12 +61,12 @@ class ConfigParser:
|
||||||
layout._to_config_dict(configDict)
|
layout._to_config_dict(configDict)
|
||||||
|
|
||||||
def _read_json_config(self, configFilename):
|
def _read_json_config(self, configFilename):
|
||||||
'''
|
"""
|
||||||
reads the config File and returns a dictionary, while lowering the first keys
|
reads the config File and returns a dictionary, while lowering the first keys
|
||||||
|
|
||||||
params:
|
params:
|
||||||
configFilename: the path under which the configuration file should be found
|
configFilename: the path under which the configuration file should be found
|
||||||
'''
|
"""
|
||||||
if not isfile(configFilename):
|
if not isfile(configFilename):
|
||||||
msg = "config file not found at " + str(configFilename)
|
msg = "config file not found at " + str(configFilename)
|
||||||
raise ConfigurationException(msg, self.log)
|
raise ConfigurationException(msg, self.log)
|
||||||
|
|
@ -84,11 +80,11 @@ class ConfigParser:
|
||||||
return json.loads(config)
|
return json.loads(config)
|
||||||
|
|
||||||
def _get_as_list(self, configValue):
|
def _get_as_list(self, configValue):
|
||||||
'''
|
"""
|
||||||
In some cases the config permits to define a list or a single value.
|
In some cases the config permits to define a list or a single value.
|
||||||
|
|
||||||
returns the value as list
|
returns the value as list
|
||||||
'''
|
"""
|
||||||
return configValue if isinstance(configValue, list) else [configValue]
|
return configValue if isinstance(configValue, list) else [configValue]
|
||||||
|
|
||||||
def _create_raw_Object(self, jsonDict, msgName, creator):
|
def _create_raw_Object(self, jsonDict, msgName, creator):
|
||||||
|
|
@ -114,9 +110,9 @@ class ConfigParser:
|
||||||
return layouts
|
return layouts
|
||||||
|
|
||||||
def create_hostgroups_from_json(self, jsonHostGroups):
|
def create_hostgroups_from_json(self, jsonHostGroups):
|
||||||
'''
|
"""
|
||||||
creates Hostgroups from the jsonConfig
|
creates Hostgroups from the jsonConfig
|
||||||
'''
|
"""
|
||||||
hostgroups = []
|
hostgroups = []
|
||||||
for hgName, hgValues in jsonHostGroups.items():
|
for hgName, hgValues in jsonHostGroups.items():
|
||||||
try:
|
try:
|
||||||
|
|
@ -128,9 +124,9 @@ class ConfigParser:
|
||||||
return hostgroups
|
return hostgroups
|
||||||
|
|
||||||
def create_members_from_json(self, jsonMembers):
|
def create_members_from_json(self, jsonMembers):
|
||||||
'''
|
"""
|
||||||
creates Members from the jsonConfig
|
creates Members from the jsonConfig
|
||||||
'''
|
"""
|
||||||
members = []
|
members = []
|
||||||
for memberName, memberValues in jsonMembers.items():
|
for memberName, memberValues in jsonMembers.items():
|
||||||
try:
|
try:
|
||||||
|
|
@ -173,7 +169,6 @@ class ConfigParser:
|
||||||
del items[:]
|
del items[:]
|
||||||
items.extend(repl)
|
items.extend(repl)
|
||||||
|
|
||||||
|
|
||||||
def replace_pointer(self, objectList, replObjectList, id_list_func, id_get_func):
|
def replace_pointer(self, objectList, replObjectList, id_list_func, id_get_func):
|
||||||
for obj in objectList:
|
for obj in objectList:
|
||||||
replacements = []
|
replacements = []
|
||||||
|
|
@ -186,12 +181,8 @@ class ConfigParser:
|
||||||
del idList[:]
|
del idList[:]
|
||||||
idList.extend(replacements)
|
idList.extend(replacements)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parse_config(self, configFilename):
|
def parse_config(self, configFilename):
|
||||||
'''
|
"""
|
||||||
parses the json configuration and returns a list of layouts,
|
parses the json configuration and returns a list of layouts,
|
||||||
which contains all nessesary information of the config file.
|
which contains all nessesary information of the config file.
|
||||||
It will only parse nessesary Objects.
|
It will only parse nessesary Objects.
|
||||||
|
|
@ -202,7 +193,7 @@ class ConfigParser:
|
||||||
|
|
||||||
params:
|
params:
|
||||||
configFilename: indicates which configuration file to parse
|
configFilename: indicates which configuration file to parse
|
||||||
'''
|
"""
|
||||||
|
|
||||||
self.jsonDict = self._read_json_config(configFilename)
|
self.jsonDict = self._read_json_config(configFilename)
|
||||||
|
|
||||||
|
|
@ -215,7 +206,6 @@ class ConfigParser:
|
||||||
for hgName in layout.get_hostgroups():
|
for hgName in layout.get_hostgroups():
|
||||||
hostgroupNames.add(hgName)
|
hostgroupNames.add(hgName)
|
||||||
|
|
||||||
|
|
||||||
jsonHostgroups = {}
|
jsonHostgroups = {}
|
||||||
for hgName in hostgroupNames:
|
for hgName in hostgroupNames:
|
||||||
if not hgName in self.jsonDict[KEY_HOSTGROUPS]:
|
if not hgName in self.jsonDict[KEY_HOSTGROUPS]:
|
||||||
|
|
@ -244,8 +234,6 @@ class ConfigParser:
|
||||||
self.members = self.create_members_from_json(jsonMembers)
|
self.members = self.create_members_from_json(jsonMembers)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parsePeriodList(name, values):
|
def parsePeriodList(name, values):
|
||||||
if "date" in values:
|
if "date" in values:
|
||||||
return DatePeriod(name, **values)
|
return DatePeriod(name, **values)
|
||||||
|
|
@ -257,18 +245,13 @@ def parsePeriodList(name, values):
|
||||||
comp = ["year", "month", "day", "week", "day_of_week", "hour", "minute", "second"]
|
comp = ["year", "month", "day", "week", "day_of_week", "hour", "minute", "second"]
|
||||||
if len([i for i in comp if i in values]) > 0 :
|
if len([i for i in comp if i in values]) > 0 :
|
||||||
return CronPeriod(name, **values)
|
return CronPeriod(name, **values)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ConfigurationException("could not determine correct Period(" + repr(values)+").")
|
raise ConfigurationException("could not determine correct Period(" + repr(values)+").")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FullConfigParser(ConfigParser):
|
class FullConfigParser(ConfigParser):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def parse_config(self, configFilename):
|
def parse_config(self, configFilename):
|
||||||
'''
|
"""
|
||||||
parses the json configuration and returns a list of layouts,
|
parses the json configuration and returns a list of layouts,
|
||||||
which contains all nessesary information of the config file.
|
which contains all nessesary information of the config file.
|
||||||
parses the full config
|
parses the full config
|
||||||
|
|
@ -279,7 +262,7 @@ class FullConfigParser(ConfigParser):
|
||||||
|
|
||||||
params:
|
params:
|
||||||
configFilename: indicates which configuration file to parse
|
configFilename: indicates which configuration file to parse
|
||||||
'''
|
"""
|
||||||
self.jsonDict = self._read_json_config(configFilename)
|
self.jsonDict = self._read_json_config(configFilename)
|
||||||
|
|
||||||
# first step
|
# first step
|
||||||
|
|
@ -329,7 +312,3 @@ class FullConfigParser(ConfigParser):
|
||||||
self.replace_pointer(layouts, hostgroups, id_list_func, id_get_func)
|
self.replace_pointer(layouts, hostgroups, id_list_func, id_get_func)
|
||||||
|
|
||||||
return layouts
|
return layouts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -67,7 +67,3 @@ class DatePeriod(Period):
|
||||||
|
|
||||||
def createJob(self, scheduler, jobInfo, func):
|
def createJob(self, scheduler, jobInfo, func):
|
||||||
return scheduler.add_date_job(func, self.date, jobInfo)
|
return scheduler.add_date_job(func, self.date, jobInfo)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
class Parser:
|
class Parser:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ The MongoDB processor
|
||||||
|
|
||||||
from processor import Processor
|
from processor import Processor
|
||||||
|
|
||||||
|
|
||||||
class Mongodb(Processor):
|
class Mongodb(Processor):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
'''
|
"""
|
||||||
Created on Jun 16, 2013
|
Created on Jun 16, 2013
|
||||||
|
|
||||||
@author: rafael
|
@author: rafael
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Processor:
|
class Processor:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
"""
|
|
||||||
The snmpget service in pure Python.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# http://pysnmp.sourceforge.net/
|
|
||||||
|
|
@ -41,7 +41,6 @@ class HttpService(Service):
|
||||||
def needs_arguments(self):
|
def needs_arguments(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
params = urllib.urlencode(self.params)
|
params = urllib.urlencode(self.params)
|
||||||
if self.method is "get":
|
if self.method is "get":
|
||||||
|
|
@ -51,5 +50,6 @@ class HttpService(Service):
|
||||||
|
|
||||||
#print f.read()
|
#print f.read()
|
||||||
|
|
||||||
|
|
||||||
def create(**kwargs):
|
def create(**kwargs):
|
||||||
return HttpService(**kwargs)
|
return HttpService(**kwargs)
|
||||||
|
|
@ -5,6 +5,7 @@ The ping service in pure Python.
|
||||||
# http://code.activestate.com/recipes/409689-icmplib-library-for-creating-and-reading-icmp-pack/
|
# http://code.activestate.com/recipes/409689-icmplib-library-for-creating-and-reading-icmp-pack/
|
||||||
from service import Service
|
from service import Service
|
||||||
|
|
||||||
|
|
||||||
class PingService(Service):
|
class PingService(Service):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super(PingService, self).__init__(**kwargs)
|
super(PingService, self).__init__(**kwargs)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ KEY_FAILS = "fails"
|
||||||
KEY_PERIODS = "periods"
|
KEY_PERIODS = "periods"
|
||||||
KEY_ARGS = "args"
|
KEY_ARGS = "args"
|
||||||
|
|
||||||
|
|
||||||
class Service:
|
class Service:
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
|
|
@ -88,7 +89,6 @@ class Service:
|
||||||
def get_parser(self):
|
def get_parser(self):
|
||||||
return self._parser
|
return self._parser
|
||||||
|
|
||||||
|
|
||||||
def add_parser(self, parser):
|
def add_parser(self, parser):
|
||||||
if parser is not None:
|
if parser is not None:
|
||||||
if isinstance(parser, list):
|
if isinstance(parser, list):
|
||||||
|
|
@ -116,6 +116,5 @@ class Service:
|
||||||
for parser in self.get_parser():
|
for parser in self.get_parser():
|
||||||
result.append(self._parser._parse(executionResult))
|
result.append(self._parser._parse(executionResult))
|
||||||
|
|
||||||
|
|
||||||
def handle_result(self, parseResult):
|
def handle_result(self, parseResult):
|
||||||
pass
|
pass
|
||||||
|
|
@ -18,9 +18,9 @@ class ShellService(Service):
|
||||||
def needs_arguments(self):
|
def needs_arguments(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
self.command.call()
|
self.command.call()
|
||||||
|
|
||||||
|
|
||||||
def create(**kwargs):
|
def create(**kwargs):
|
||||||
return ShellService(**kwargs)
|
return ShellService(**kwargs)
|
||||||
|
|
@ -51,5 +51,6 @@ class SnmpgetService(Service):
|
||||||
# for name, val in varBinds:
|
# for name, val in varBinds:
|
||||||
# print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
|
# print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
|
||||||
|
|
||||||
|
|
||||||
def create(**kargs):
|
def create(**kargs):
|
||||||
return SnmpgetService(**kwargs)
|
return SnmpgetService(**kwargs)
|
||||||
|
|
@ -39,6 +39,7 @@ class SshService(Service):
|
||||||
print '... ' + line.strip('\n')
|
print '... ' + line.strip('\n')
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
|
||||||
def create(**kwargs):
|
def create(**kwargs):
|
||||||
return SshService(**kwargs)
|
return SshService(**kwargs)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ class TcpconnectService(Service):
|
||||||
else:
|
else:
|
||||||
raise Exception("There is no port set")
|
raise Exception("There is no port set")
|
||||||
|
|
||||||
|
|
||||||
def needs_arguments(self):
|
def needs_arguments(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -39,5 +38,6 @@ class TcpconnectService(Service):
|
||||||
sock.close()
|
sock.close()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def create(**kwargs):
|
def create(**kwargs):
|
||||||
return TcpconnectService(**kwargs)
|
return TcpconnectService(**kwargs)
|
||||||
|
|
@ -4,6 +4,7 @@ The email task.
|
||||||
|
|
||||||
from lib.tasks.task import Task
|
from lib.tasks.task import Task
|
||||||
|
|
||||||
|
|
||||||
class EmailTask(Task):
|
class EmailTask(Task):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if not "type" in kwargs:
|
if not "type" in kwargs:
|
||||||
|
|
@ -13,12 +14,9 @@ class EmailTask(Task):
|
||||||
self.set_task_type(kwargs["type"])
|
self.set_task_type(kwargs["type"])
|
||||||
self.recipient = kwargs["args"]["rcpt"]
|
self.recipient = kwargs["args"]["rcpt"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def execute_task(self, msg):
|
def execute_task(self, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def creator(**taskDict):
|
def creator(**taskDict):
|
||||||
return EmailTask(**taskDict)
|
return EmailTask(**taskDict)
|
||||||
|
|
@ -4,6 +4,7 @@ The sms task.
|
||||||
|
|
||||||
from task import Task
|
from task import Task
|
||||||
|
|
||||||
|
|
||||||
class SmsTask(Task):
|
class SmsTask(Task):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if not "type" in kwargs:
|
if not "type" in kwargs:
|
||||||
|
|
@ -13,12 +14,9 @@ class SmsTask(Task):
|
||||||
self.set_task_type(kwargs["type"])
|
self.set_task_type(kwargs["type"])
|
||||||
self.recipient = kwargs["args"]["rcpt"]
|
self.recipient = kwargs["args"]["rcpt"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def execute_task(self, msg):
|
def execute_task(self, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def creator(**taskDict):
|
def creator(**taskDict):
|
||||||
return SmsTask(**taskDict)
|
return SmsTask(**taskDict)
|
||||||
|
|
@ -1,35 +1,36 @@
|
||||||
'''
|
"""
|
||||||
Created on Jun 15, 2013
|
Created on Jun 15, 2013
|
||||||
|
|
||||||
@author: Rafael Timmerberg
|
@author: Rafael Timmerberg
|
||||||
'''
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Task:
|
class Task:
|
||||||
'''
|
"""
|
||||||
Base class for all built-in Tasks.
|
Base class for all built-in Tasks.
|
||||||
'''
|
"""
|
||||||
|
|
||||||
def set_task_type(self, taskType):
|
def set_task_type(self, taskType):
|
||||||
'''
|
"""
|
||||||
sets the type of this task.
|
sets the type of this task.
|
||||||
|
|
||||||
Be aware! this method can only get called once!
|
Be aware! this method can only get called once!
|
||||||
|
|
||||||
params:
|
params:
|
||||||
taskType: the type of this task
|
taskType: the type of this task
|
||||||
'''
|
"""
|
||||||
if hasattr(self, "_taskType"):
|
if hasattr(self, "_taskType"):
|
||||||
raise Exception("taskType is only allowed to set once!")
|
raise Exception("taskType is only allowed to set once!")
|
||||||
self.taskType = taskType
|
self.taskType = taskType
|
||||||
|
|
||||||
def get_task_type(self):
|
def get_task_type(self):
|
||||||
'''
|
"""
|
||||||
returns the type set by set_type_task
|
returns the type set by set_type_task
|
||||||
'''
|
"""
|
||||||
return self._taskType
|
return self._taskType
|
||||||
|
|
||||||
def execute_task(self, msg):
|
def execute_task(self, msg):
|
||||||
'''
|
"""
|
||||||
this is the method tasks usually override.
|
this is the method tasks usually override.
|
||||||
It gets called anytime the task should get executed
|
It gets called anytime the task should get executed
|
||||||
|
|
||||||
|
|
@ -37,11 +38,11 @@ class Task:
|
||||||
|
|
||||||
params:
|
params:
|
||||||
msg: the msg for this task
|
msg: the msg for this task
|
||||||
'''
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _execute(self,taskType, msg):
|
def _execute(self, taskType, msg):
|
||||||
'''
|
"""
|
||||||
internal method which gets called for any member in a hostgroup.
|
internal method which gets called for any member in a hostgroup.
|
||||||
It determines if it has an appropriate type by comparing taskType with get_task_type().
|
It determines if it has an appropriate type by comparing taskType with get_task_type().
|
||||||
Calls execute_task() if the type matches
|
Calls execute_task() if the type matches
|
||||||
|
|
@ -52,9 +53,8 @@ class Task:
|
||||||
|
|
||||||
return:
|
return:
|
||||||
True if execute_task() is called succesfully, else False
|
True if execute_task() is called succesfully, else False
|
||||||
'''
|
"""
|
||||||
if self.get_task_type() == taskType:
|
if self.get_task_type() == taskType:
|
||||||
self.execute_task(msg)
|
self.execute_task(msg)
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
@ -4,6 +4,7 @@ The xmpp task.
|
||||||
|
|
||||||
from task import Task
|
from task import Task
|
||||||
|
|
||||||
|
|
||||||
class XmppTask(Task):
|
class XmppTask(Task):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
if not "type" in kwargs:
|
if not "type" in kwargs:
|
||||||
|
|
@ -13,12 +14,9 @@ class XmppTask(Task):
|
||||||
self.set_task_type(kwargs["type"])
|
self.set_task_type(kwargs["type"])
|
||||||
self.recipient = kwargs["args"]["rcpt"]
|
self.recipient = kwargs["args"]["rcpt"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def execute_task(self, msg):
|
def execute_task(self, msg):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def creator(**taskDict):
|
def creator(**taskDict):
|
||||||
return XmppTask(taskDict)
|
return XmppTask(taskDict)
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/python2.7 -tt
|
#!/usr/bin/python2.7 -tt
|
||||||
from zenmapCore.UmitConf import config_parser
|
|
||||||
|
|
||||||
__version__ = "0.4/TETRIS"
|
__version__ = "0.4/TETRIS"
|
||||||
__default_config__ = "./linspector.json"
|
__default_config__ = "./linspector.json"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue