Merge branch 'master' of https://github.com/linspector/linspector
This commit is contained in:
commit
b01b7855ef
8 changed files with 84 additions and 4 deletions
|
|
@ -154,8 +154,9 @@ def main():
|
||||||
hostgroup)
|
hostgroup)
|
||||||
|
|
||||||
scheduler_job = period.createJob(scheduler, job, handle_job, start_date=new_start_date)
|
scheduler_job = period.createJob(scheduler, job, handle_job, start_date=new_start_date)
|
||||||
scheduler_job.misfire_grace_time = 2
|
|
||||||
if scheduler_job is not None:
|
if scheduler_job is not None:
|
||||||
|
scheduler_job.misfire_grace_time = 2
|
||||||
job.set_job(scheduler_job)
|
job.set_job(scheduler_job)
|
||||||
jobs.append(job)
|
jobs.append(job)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,11 @@ class Member:
|
||||||
raise MemberMissingArgumentException(tmp, name)
|
raise MemberMissingArgumentException(tmp, name)
|
||||||
self.add_tasks(kwargs[tmp])
|
self.add_tasks(kwargs[tmp])
|
||||||
|
|
||||||
|
tmp = "parent"
|
||||||
|
self.parent = None
|
||||||
|
if tmp in kwargs:
|
||||||
|
self.parent = kwargs[tmp]
|
||||||
|
|
||||||
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)
|
||||||
|
|
@ -59,6 +64,12 @@ class Member:
|
||||||
def get_tasks(self):
|
def get_tasks(self):
|
||||||
return self.__tasks
|
return self.__tasks
|
||||||
|
|
||||||
|
def has_parent(self):
|
||||||
|
return self.parent is not None
|
||||||
|
|
||||||
|
def get_parent(self):
|
||||||
|
return self.parent
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
ret = "Member: " + self.name + " Tasks: "
|
ret = "Member: " + self.name + " Tasks: "
|
||||||
for t in self.tasks:
|
for t in self.tasks:
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@ class LinspectorInterface(object):
|
||||||
for job in self.jobs:
|
for job in self.jobs:
|
||||||
self.jobHex.append(job.hex_string())
|
self.jobHex.append(job.hex_string())
|
||||||
|
|
||||||
|
def get_config(self):
|
||||||
|
return self._config
|
||||||
|
|
||||||
def get_job_hex_strings(self):
|
def get_job_hex_strings(self):
|
||||||
return self.jobHex
|
return self.jobHex
|
||||||
|
|
||||||
|
|
@ -74,6 +77,9 @@ class LinspectorInterface(object):
|
||||||
#d["Last Escalation"] = None
|
#d["Last Escalation"] = None
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def add_job(self, job):
|
||||||
|
self.jobs.append(job)
|
||||||
|
|
||||||
def get_job_list(self):
|
def get_job_list(self):
|
||||||
job_list = []
|
job_list = []
|
||||||
for job in self.jobs:
|
for job in self.jobs:
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,8 @@ class LishFrontend(Frontend):
|
||||||
run = True
|
run = True
|
||||||
while run:
|
while run:
|
||||||
try:
|
try:
|
||||||
commander.cmdloop(GREEN + "Lish - Linspector interactive shell (" + __version__ + ")" + END)
|
print(GREEN + "Lish - Linspector interactive shell (" + __version__ + ")" + END)
|
||||||
|
commander.cmdloop()
|
||||||
except KeyboardInterrupt, ki:
|
except KeyboardInterrupt, ki:
|
||||||
run = False
|
run = False
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
|
|
@ -220,8 +221,6 @@ class NewLish(CmdWrapper):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Job(CmdWrapper):
|
class Job(CmdWrapper):
|
||||||
def __init__(self, interface):
|
def __init__(self, interface):
|
||||||
|
|
||||||
|
|
|
||||||
9
linspector/transactions/BaseTransaction.py
Normal file
9
linspector/transactions/BaseTransaction.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
__author__ = 'rafael'
|
||||||
|
|
||||||
|
|
||||||
|
class BaseTransaction(object):
|
||||||
|
def __init__(self, linspectorInterface:
|
||||||
|
self.interface = linspectorInterface
|
||||||
|
|
||||||
|
def transact(self):
|
||||||
|
pass
|
||||||
44
linspector/transactions/HostgroupHostTransaction.py
Normal file
44
linspector/transactions/HostgroupHostTransaction.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
from linspector.transactions import HostgroupTransaction
|
||||||
|
from linspector.core.job import LinspectorJob
|
||||||
|
|
||||||
|
__author__ = 'rafael'
|
||||||
|
|
||||||
|
def handle_job(job):
|
||||||
|
job.handle_call()
|
||||||
|
|
||||||
|
|
||||||
|
class HostgroupHostTransaction(HostgroupTransaction):
|
||||||
|
def __init__(self, linspectorInterface, hostgroup, host):
|
||||||
|
super(HostgroupHostTransaction).__init__(linspectorInterface, hostgroup)
|
||||||
|
self.host = host
|
||||||
|
|
||||||
|
class HostgroupAddHostTransaction(HostgroupHostTransaction):
|
||||||
|
def __init__(self, linspectorInterface, hostgroup, host):
|
||||||
|
super(HostgroupHostTransaction).__init__(linspectorInterface, hostgroup, host)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def transact(self):
|
||||||
|
hostgroup = self.interface.get_config().get_hostgroup_by_name(self.hostgroup)
|
||||||
|
if hostgroup is not None:
|
||||||
|
hostgroup.add_host(self.host)
|
||||||
|
for service in hostgroup.get_services():
|
||||||
|
for host in hostgroup.get_hosts():
|
||||||
|
for period in service.get_periods():
|
||||||
|
|
||||||
|
job = LinspectorJob(service,
|
||||||
|
host,
|
||||||
|
hostgroup.get_members(),
|
||||||
|
None,
|
||||||
|
hostgroup)
|
||||||
|
scheduler_job = period.createJob(self.scheduler, job, handle_job)
|
||||||
|
if scheduler_job is not None:
|
||||||
|
scheduler_job.misfire_grace_time = 2
|
||||||
|
job.set_job(scheduler_job)
|
||||||
|
self.interface.add_job(job)
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
raise Exception("could not find hostgroup %s" % self.hostgroup )
|
||||||
|
|
||||||
|
|
||||||
9
linspector/transactions/HostgroupTransaction.py
Normal file
9
linspector/transactions/HostgroupTransaction.py
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
from cherrypy.test.test_session import host
|
||||||
|
from linspector.transactions import BaseTransaction
|
||||||
|
|
||||||
|
__author__ = 'rafael'
|
||||||
|
|
||||||
|
class HostgroupTransaction(BaseTransaction):
|
||||||
|
def __init__(self, linspectorInterface, hostgroup):
|
||||||
|
super(HostgroupTransaction, self).__init__(linspectorInterface)
|
||||||
|
self.hostgroup = hostgroup
|
||||||
1
linspector/transactions/__init__.py
Normal file
1
linspector/transactions/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
__author__ = 'rafael'
|
||||||
Loading…
Add table
Add a link
Reference in a new issue