phase1: move max_builds to slave properties
authorThibaut VARÈNE <hacks@slashdirt.org>
Fri, 22 Jun 2018 14:17:06 +0000 (16:17 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 26 Jun 2018 20:09:01 +0000 (22:09 +0200)
Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
phase1/master.cfg

index 4132f27c67f15491959307042eb9690cb10ea8d4..15a1be88e77458abf9de2f0f222b52f0bed5541d 100644 (file)
@@ -48,18 +48,18 @@ if ini.has_option("general", "port"):
        slave_port = ini.getint("general", "port")
 
 c['slaves'] = []
-max_builds = dict()
 NetLocks = dict()
 
 for section in ini.sections():
        if section.startswith("slave "):
                if ini.has_option(section, "name") and ini.has_option(section, "password"):
-                       sl_props = { 'dl_lock':None, 'ul_lock':None, 'do_cleanup':False }
+                       sl_props = { 'dl_lock':None, 'ul_lock':None, 'do_cleanup':False, 'max_builds':1 }
                        name = ini.get(section, "name")
                        password = ini.get(section, "password")
-                       max_builds[name] = 1
+                       max_builds = 1
                        if ini.has_option(section, "builds"):
-                               max_builds[name] = ini.getint(section, "builds")
+                               max_builds = ini.getint(section, "builds")
+                               sl_props['max_builds'] = max_builds
                        if ini.has_option(section, "cleanup"):
                                sl_props['do_cleanup'] = ini.getboolean(section, "cleanup")
                        if ini.has_option(section, "dl_lock"):
@@ -72,7 +72,7 @@ for section in ini.sections():
                                sl_props['ul_lock'] = lockname
                                if lockname not in NetLocks:
                                        NetLocks[lockname] = locks.MasterLock(lockname)
-                       c['slaves'].append(BuildSlave(name, password, max_builds = max_builds[name], properties = sl_props))
+                       c['slaves'].append(BuildSlave(name, password, max_builds = max_builds, properties = sl_props))
 
 # 'slavePortnum' defines the TCP port to listen on for connections from slaves.
 # This must match the value configured into the buildslaves (with their
@@ -283,8 +283,8 @@ def GetVersionPrefix(props):
                return ""
 
 def GetNumJobs(props):
-       if props.hasProperty("slavename") and props.hasProperty("nproc"):
-               return (int(props["nproc"]) / (max_builds[props["slavename"]] + other_builds))
+       if props.hasProperty("max_builds") and props.hasProperty("nproc"):
+               return (int(props["nproc"]) / (props["max_builds"] + other_builds))
        else:
                return 1