summaryrefslogtreecommitdiff
path: root/lorrycontroller
diff options
context:
space:
mode:
Diffstat (limited to 'lorrycontroller')
-rw-r--r--lorrycontroller/__init__.py4
-rw-r--r--lorrycontroller/status.py27
2 files changed, 25 insertions, 6 deletions
diff --git a/lorrycontroller/__init__.py b/lorrycontroller/__init__.py
index b2510dc..ef9c977 100644
--- a/lorrycontroller/__init__.py
+++ b/lorrycontroller/__init__.py
@@ -21,7 +21,7 @@ from .statedb import (
HostNotFoundError)
from .route import LorryControllerRoute
from .readconf import ReadConfiguration
-from .status import Status, StatusHTML, StatusRenderer
+from .status import Status, StatusHTML, StatusRenderer, FailuresHTML
from .listqueue import ListQueue
from .showlorry import ShowLorry, ShowLorryHTML
from .startstopqueue import StartQueue, StopQueue
@@ -70,7 +70,7 @@ __all__ = [
'LorryNotFoundError', 'WrongNumberLorriesRunningJob', 'HostNotFoundError',
'LorryControllerRoute',
'ReadConfiguration',
- 'Status', 'StatusHTML', 'StatusRenderer',
+ 'Status', 'StatusHTML', 'StatusRenderer', 'FailuresHTML',
'ListQueue',
'ShowLorry', 'ShowLorryHTML',
'StartQueue', 'StopQueue',
diff --git a/lorrycontroller/status.py b/lorrycontroller/status.py
index 8483485..df39470 100644
--- a/lorrycontroller/status.py
+++ b/lorrycontroller/status.py
@@ -29,19 +29,24 @@ class StatusRenderer(object):
'''Helper class for rendering service status as JSON/HTML'''
- def get_status_as_dict(self, statedb, work_directory):
+ def get_queue_status_as_dict(self, statedb):
now = statedb.get_current_time()
- status = {
- 'running_queue': statedb.get_running_queue(),
+ return {
'timestamp':
time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime(now)),
'run_queue': self.get_run_queue(statedb),
+ }
+
+ def get_status_as_dict(self, statedb, work_directory):
+ status = self.get_queue_status_as_dict(statedb)
+ status.update({
+ 'running_queue': statedb.get_running_queue(),
'hosts': self.get_hosts(statedb),
'warning_msg': '',
'max_jobs': self.get_max_jobs(statedb),
'links': True,
'publish_failures': True,
- }
+ })
status.update(self.get_free_disk_space(work_directory))
return status
@@ -209,3 +214,17 @@ class StatusHTML(lorrycontroller.LorryControllerRoute):
self.app_settings['publish-failures'])
return renderer.render_status_as_html(
self._templates['status'], status)
+
+
+class FailuresHTML(lorrycontroller.LorryControllerRoute):
+
+ http_method = 'GET'
+ path = '/1.0/failures-html'
+
+ def run(self, **kwargs):
+ logging.info('%s %s called', self.http_method, self.path)
+ renderer = StatusRenderer()
+ with self.open_statedb() as statedb:
+ status = renderer.get_queue_status_as_dict(statedb)
+ return renderer.render_status_as_html(
+ self._templates['failures'], status)