Add a really basic status page.

Text only, not very pretty, but hopefully should do the job for
now.

Change-Id: I2e30f0e087086ca1fcbafa6f4bdde9855225e71f
This commit is contained in:
James E. Blair 2012-06-13 18:24:29 -07:00
parent 9f9667eddf
commit 268d9344af
2 changed files with 42 additions and 2 deletions

View File

@ -46,10 +46,15 @@ class JenkinsCallback(threading.Thread):
def app(self, environ, start_response):
request = Request(environ)
start_response('200 OK', [('content-type', 'text/html')])
if request.path == '/jenkins_endpoint':
self.jenkins_endpoint(request)
start_response('200 OK', [('content-type', 'text/html')])
return ['Zuul good.']
return ['Zuul good.']
elif request.path == '/status':
ret = self.jenkins.sched.formatStatusHTML()
return [ret]
else:
return ['Zuul good.']
def jenkins_endpoint(self, request):
data = json.loads(request.body)

View File

@ -235,6 +235,20 @@ class Scheduler(threading.Thread):
return
self.log.warning("Build %s not found by any queue manager" % (build))
def formatStatusHTML(self):
ret = '<html><pre>'
keys = self.queue_managers.keys()
keys.sort()
for key in keys:
manager = self.queue_managers[key]
s = 'Queue: %s' % manager.name
ret += s + '\n'
ret += '-' * len(s) + '\n'
ret += manager.formatStatusHTML()
ret += '\n'
ret += '</pre></html>'
return ret
class BaseQueueManager(object):
log = logging.getLogger("zuul.BaseQueueManager")
@ -354,6 +368,16 @@ for change %s:" % (job, change))
self.log.exception("Exception while reporting:")
return ret
def formatStatusHTML(self):
changes = []
for build, change in self.building_jobs.items():
if change not in changes:
changes.append(change)
ret = ''
for change in changes:
ret += change.formatStatus()
return ret
class IndependentQueueManager(BaseQueueManager):
log = logging.getLogger("zuul.IndependentQueueManager")
@ -500,3 +524,14 @@ behind failed change %s" % (
self.log.info("Change %s behind change %s is ready, \
possibly reporting" % (change.change_behind, change))
self.possiblyReportChange(change.change_behind)
def formatStatusHTML(self):
ret = ''
ret += '\n'
for queue in self.change_queues:
s = 'Shared queue: %s' % queue.name
ret += s + '\n'
ret += '-' * len(s) + '\n'
if queue.queue:
ret += queue.queue[-1].formatStatus()
return ret