added main thread for background scheduling; version set to 0.11
This commit is contained in:
parent
79ee26ff71
commit
3642e67013
4 changed files with 96 additions and 41 deletions
|
|
@ -4,7 +4,7 @@ Lish is the Linspector Interactive Shell.
|
|||
This will become a commandline interface to Linspector. Think of a
|
||||
network switch or router like those from Cisco.
|
||||
|
||||
Copyright (c) 2011-2013 "Johannes Findeisen and Rafael Timmerberg"
|
||||
Copyright (c) 2011-2013 by Johannes Findeisen and Rafael Timmerberg
|
||||
|
||||
This file is part of Linspector (http://linspector.org).
|
||||
|
||||
|
|
@ -175,6 +175,8 @@ class LishCommander(Exit):
|
|||
PURPLE + " Host" + END + ": " + job_dict["Host"] + \
|
||||
PURPLE + " Service" + END + ": " + job_dict["Service"] + \
|
||||
PURPLE + " Next run" + END + ": " + job_dict["Next run"] + \
|
||||
PURPLE + " Runs" + END + ": " + job_dict["Runs"] + \
|
||||
PURPLE + " Fails" + END + ": " + job_dict["Fails"] + \
|
||||
PURPLE + " Enabled" + END + ": " + job_dict["Enabled"]
|
||||
elif text == "count":
|
||||
print GREEN + "Job Count" + END + ":\t" + str(self.interface.get_job_count())
|
||||
|
|
|
|||
64
linspector/linspector.py
Normal file
64
linspector/linspector.py
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
"""
|
||||
The Linspector main thread. Here all scheduling is done so backends and
|
||||
frontends can start before all jobs are scheduled.
|
||||
|
||||
Copyright (c) 2011-2013 by Johannes Findeisen and Rafael Timmerberg
|
||||
|
||||
This file is part of Linspector (http://linspector.org).
|
||||
|
||||
Linspector is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import threading
|
||||
import time
|
||||
|
||||
from core.job import Job
|
||||
|
||||
|
||||
def handle_job(jobInfo):
|
||||
jobInfo.handle_call()
|
||||
|
||||
|
||||
class Linspector(threading.Thread):
|
||||
def __init__(self, linConf, core, scheduler, log, q):
|
||||
self.linConf = linConf
|
||||
self.core = core
|
||||
self.scheduler = scheduler
|
||||
self.log = log
|
||||
self.q = q
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
def handle_job(self, jobInfo):
|
||||
jobInfo.handle_call()
|
||||
|
||||
def run(self):
|
||||
jobs = []
|
||||
for layout in self.linConf.get_enabled_layouts():
|
||||
for hostgroup in layout.get_hostgroups():
|
||||
for service in hostgroup.get_services():
|
||||
for host in hostgroup.get_hosts():
|
||||
for period in service.get_periods():
|
||||
time.sleep(3)
|
||||
job = Job(service,
|
||||
host,
|
||||
hostgroup.get_members(),
|
||||
hostgroup.get_processors(),
|
||||
self.core,
|
||||
hostgroup)
|
||||
schedulerJob = period.createJob(self.scheduler, job, handle_job)
|
||||
if schedulerJob is not None:
|
||||
job.set_job(schedulerJob)
|
||||
job.set_logger(self.log)
|
||||
jobs.append(job)
|
||||
self.q.put(jobs)
|
||||
Loading…
Add table
Add a link
Reference in a new issue