[Buildbot-devel] [PATCH 3/4] track SlaveBuilders in BuildSlave

Dustin J. Mitchell dustin at zmanda.com
Fri Jun 22 18:04:51 UTC 2007


2007-06-22  Dustin J. Mitchell <dustin at zmanda.com>
    * buildbot/buildslave.py: add addSlaveBuilder() and removeSlaveBuilder()
    * buildbot/process/builder.py: call BuildSlave's addSlaveBuilder() and 
      removeSlaveBuilder()

Index: wip/buildbot/buildslave.py
===================================================================
--- wip.orig/buildbot/buildslave.py	2007-06-22 12:39:39.392755280 -0500
+++ wip/buildbot/buildslave.py	2007-06-22 12:39:43.384628488 -0500
@@ -12,6 +12,7 @@
     def __init__(self, name, password):
         BotPerspective.__init__(self, name)
         self.password = password
+        self.slavebuilders = []
 
     def consumeTheSoulOfYourSuccessor(self, new):
         """
@@ -28,6 +29,15 @@
                (self.slavename,
                 string.join(map(lambda b: b.name, builders), ','))
 
+    def addSlaveBuilder(self, sb):
+        log.msg("%s adding %s" % (self, sb))
+        self.slavebuilders.append(sb)
+
+    def removeSlaveBuilder(self, sb):
+        log.msg("%s removing %s" % (self, sb))
+        if sb in self.slavebuilders:
+            self.slavebuilders.remove(sb)
+
     def canStartBuild(self):
         """
         I am called when a build is requested to see if this buildslave is
Index: wip/buildbot/process/builder.py
===================================================================
--- wip.orig/buildbot/process/builder.py	2007-06-22 12:39:39.392755280 -0500
+++ wip/buildbot/process/builder.py	2007-06-22 12:39:43.388628361 -0500
@@ -62,6 +62,7 @@
         self.slave = slave
         self.remote = remote
         self.remoteCommands = commands # maps command name to version
+        self.slave.addSlaveBuilder(self)
         log.msg("Buildslave %s attached to %s" % (slave.slavename,
                                                   self.builder_name))
         d = self.remote.callRemote("setMaster", self)
@@ -89,6 +90,7 @@
     def detached(self):
         log.msg("Buildslave %s detached from %s" % (self.slave.slavename,
                                                     self.builder_name))
+        if self.slave: self.slave.removeSlaveBuilder(self)
         self.slave = None
         self.remote = None
         self.remoteCommands = None

-- 
        Dustin J. Mitchell
        Storage Software Engineer, Zmanda, Inc.
        http://www.zmanda.com/




More information about the devel mailing list