add support for basedirs
authorDustin J. Mitchell <dustin@mozilla.com>
Thu, 13 Jan 2011 12:02:18 -0600
changeset 1239 0e6ad3623f085986c8c8ada54f5515e8d760fbe5
parent 1238 33dd5944e69ff4263a6536d54c02cb0d05b0c18b
child 1240 0182f0d264a8e32a9a228d571de89869c9c73fb8
push id894
push userdmitchell@mozilla.com
push dateFri, 18 Mar 2011 22:21:21 +0000
add support for basedirs
.hgignore
lib/python/slavealloc/data/model.py
lib/python/slavealloc/logic/buildbottac.py
lib/python/slavealloc/scripts/dbinit.py
--- a/.hgignore
+++ b/.hgignore
@@ -1,1 +1,2 @@
 slavealloc.db
+.*.swp
--- a/lib/python/slavealloc/data/model.py
+++ b/lib/python/slavealloc/data/model.py
@@ -55,16 +55,17 @@ slaves = sa.Table('slaves', metadata,
     sa.Column('name', sa.Text),
     sa.Column('distroid', sa.Integer, sa.ForeignKey('distros.distroid')),
     sa.Column('bitsid', sa.Integer, sa.ForeignKey('bitlengths.bitsid')),
     sa.Column('purposeid', sa.Integer, sa.ForeignKey('purposes.purposeid')),
     sa.Column('dcid', sa.Integer, sa.ForeignKey('datacenters.dcid')),
     sa.Column('trustid', sa.Integer, sa.ForeignKey('trustlevels.trustid')),
     sa.Column('envid', sa.Integer, sa.ForeignKey('environments.envid')),
     sa.Column('poolid', sa.Integer, sa.ForeignKey('pools.poolid')),
+    sa.Column('basedir', sa.Text, nullable=False),
     sa.Column('current_masterid', sa.Integer, sa.ForeignKey('masters.masterid')),
 )
 
 # masters
 
 masters = sa.Table('masters', metadata,
     sa.Column('masterid', sa.Integer, primary_key=True),
     sa.Column('nickname', sa.Text),
--- a/lib/python/slavealloc/logic/buildbottac.py
+++ b/lib/python/slavealloc/logic/buildbottac.py
@@ -1,11 +1,13 @@
 import time
 import socket
 
+from slavealloc.data import model
+
 tac_template = """\
 # AUTOMATICALLY GENERATED - DO NOT MODIFY
 # generated: %(gendate)s on %(genhost)s
 from twisted.application import service
 from buildbot.slave.bot import BuildSlave
 from twisted.python.logfile import LogFile
 from twisted.python.log import ILogObserver, FileLogObserver
 
@@ -28,17 +30,23 @@ application.setComponent(ILogObserver, F
 s = BuildSlave(buildmaster_host, port, slavename, passwd, basedir,
                keepalive, usepty, umask=umask, maxdelay=maxdelay)
 s.setServiceParent(application)
 """
 
 def make_buildbot_tac(engine, slavename, allocation):
     info = dict()
 
+    # we'll need info on the slave itself, e.g., basedir
+    q = model.slaves.select(whereclause=(model.slaves.c.name == slavename))
+    q.bind = engine
+    slaverow = q.execute().fetchone()
+    print slaverow
+
     info['gendate'] = time.ctime()
     info['genhost'] = socket.getfqdn()
     info['buildmaster_host'] = allocation.fqdn
     info['port'] = allocation.pb_port
     info['slavename'] = slavename
-    info['basedir'] = 'TODO' # TODO!!
+    info['basedir'] = slaverow.basedir
     info['passwd'] = 'TODO' # TODO!!
 
     return tac_template % info
--- a/lib/python/slavealloc/scripts/dbinit.py
+++ b/lib/python/slavealloc/scripts/dbinit.py
@@ -67,10 +67,11 @@ def main(args):
         dict(name=row['name'],
              distroid=distros[row['distro']],
              bitsid=bitlengths[row['bitlength']],
              purposeid=purposes[row['purpose']],
              dcid=datacenters[row['datacenter']],
              trustid=trustlevels[row['trustlevel']],
              envid=environments[row['environment']],
              poolid=pools[row['pool']],
+             basedir=row['basedir'],
              current_masterid=None)
         for row in slaves ])