Ticket #743: slaves-page.diff

File slaves-page.diff, 4.1 KB (added by jhford, 10 years ago)

simple slave list.diff

  • buildbot/status/web/baseweb.py

    diff --git a/buildbot/status/web/baseweb.py b/buildbot/status/web/baseweb.py
    index aa6630a..ae1006b 100644
    a b from buildbot.status.web.grid import GridStatusResource, TransposedGridStatusRes 
    2020from buildbot.status.web.changes import ChangesResource
    2121from buildbot.status.web.builder import BuildersResource
    2222from buildbot.status.web.buildstatus import BuildStatusStatusResource
    23 from buildbot.status.web.slaves import BuildSlavesResource
     23from buildbot.status.web.slaves import BuildSlavesResource, SlavesResource
    2424from buildbot.status.web.status_json import JsonStatusResource
    2525from buildbot.status.web.xmlrpc import XMLRPCServer
    2626from buildbot.status.web.about import AboutBuildbot
    class WebStatus(service.MultiService): 
    7676                                timer, and controls to accelerate the timer.
    7777     /buildslaves : list all BuildSlaves
    7878     /buildslaves/SLAVENAME : describe a single BuildSlave
     79     /slaves : describe which slaves are connected
    7980     /one_line_per_build : summarize the last few builds, one line each
    8081     /one_line_per_build/BUILDERNAME : same, but only for a single builder
    8182     /about : describe this buildmaster (Buildbot and support library versions)
    class WebStatus(service.MultiService): 
    303304        self.putChild("one_box_per_builder", Redirect("/builders"))
    304305        self.putChild("changes", ChangesResource())
    305306        self.putChild("buildslaves", BuildSlavesResource())
     307        self.putChild("slaves", SlavesResource())
    306308        self.putChild("buildstatus", BuildStatusStatusResource())
    307309        #self.putChild("schedulers", SchedulersResource())
    308310        self.putChild("one_line_per_build",
  • buildbot/status/web/slaves.py

    diff --git a/buildbot/status/web/slaves.py b/buildbot/status/web/slaves.py
    index 6d160e1..e588f30 100644
    a b class BuildSlavesResource(HtmlResource): 
    125125            return OneBuildSlaveResource(path)
    126126        except KeyError:
    127127            return NoResource("No such slave '%s'" % html.escape(path))
     128
     129# /slaves
     130class SlavesResource(HtmlResource):
     131    title = "Slaves"
     132    addSlash = True
     133
     134    def content(self, request, ctx):
     135        s = self.getStatus(request)
     136        slaves = ctx['slaves'] = []
     137        for name in util.naturalSort(s.getSlaveNames()):
     138            info = {}
     139            slaves.append(info)
     140            slave = s.getSlave(name)
     141            slave_status = s.botmaster.slaves[name].slave_status
     142            info['link'] = request.childLink(urllib.quote(name,''))
     143            info['name'] = name
     144            info['version'] = slave.getVersion()
     145            info['connected'] = slave.isConnected()
     146           
     147            if slave.isConnected():
     148                info['admin'] = unicode(slave.getAdmin() or '', 'utf-8')
     149                last = slave.lastMessageReceived()
     150                if last:
     151                    info['last_heard_from_age'] = abbreviate_age(time.time() - last)
     152                    info['last_heard_from_time'] = time.strftime("%Y-%b-%d %H:%M:%S",
     153                                                                time.localtime(last))
     154
     155        template = request.site.buildbot_service.templates.get_template("slaves.html")
     156        data = template.render(**ctx)
     157        return data
     158
     159    def getChild(self, path, req):
     160        try:
     161            self.getStatus(req).getSlave(path)
     162            return OneBuildSlaveResource(path)
     163        except KeyError:
     164            return NoResource("No such slave '%s'" % html.escape(path))
  • buildbot/status/web/templates/root.html

    diff --git a/buildbot/status/web/templates/root.html b/buildbot/status/web/templates/root.html
    index 4ef11ae..03a2df0 100644
    a b  
    3939  per line.</li>
    4040
    4141  <li class="{{ item_class.next() }}"><a href="buildslaves">Buildslave</a> information</li>
     42  <li class="{{ item_class.next() }}"><a href="slaves">Slave</a> information</li>
    4243  <li class="{{ item_class.next() }}"><a href="changes">Changesource</a> information.</li>
    4344
    4445  <li class="{{ item_class.next() }}"><a href="about">About</a> this Buildbot</li>