From: Thibaut VARÈNE Date: Thu, 27 Oct 2022 12:32:30 +0000 (+0200) Subject: phase1: refactor worker parsing X-Git-Tag: v2~10 X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=344059d3bc43555559bfd3bffd928e00a79c006b;p=buildbot.git phase1: refactor worker parsing Signed-off-by: Thibaut VARÈNE --- diff --git a/phase1/master.cfg b/phase1/master.cfg index fdbb2cd..53d2098 100644 --- a/phase1/master.cfg +++ b/phase1/master.cfg @@ -131,27 +131,39 @@ c['buildbotURL'] = inip1.get("buildbot_url") c['workers'] = [] NetLocks = dict() +def ini_parse_workers(section): + name = section.get("name") + password = section.get("password") + phase = section.getint("phase") + + if not name or not password or not phase == 1: + log.msg("invalid worker configuration ignored: {}".format(repr(section))) + return + + sl_props = { 'dl_lock':None, 'ul_lock':None } + if "dl_lock" in section: + lockname = section.get("dl_lock") + sl_props['dl_lock'] = lockname + if lockname not in NetLocks: + NetLocks[lockname] = locks.MasterLock(lockname) + if "ul_lock" in section: + lockname = section.get("ul_lock") + sl_props['ul_lock'] = lockname + if lockname not in NetLocks: + NetLocks[lockname] = locks.MasterLock(lockname) + + log.msg("Configured worker: {}".format(name)) + c['workers'].append(Worker(name, password, max_builds = 1, properties = sl_props)) + + for section in ini.sections(): if section.startswith("branch "): ini_parse_branch(ini[section]) if section.startswith("worker "): - if ini.has_option(section, "name") and ini.has_option(section, "password") and \ - (not ini.has_option(section, "phase") or ini.getint(section, "phase") == 1): - sl_props = { 'dl_lock':None, 'ul_lock':None } - name = ini.get(section, "name") - password = ini.get(section, "password") - if ini.has_option(section, "dl_lock"): - lockname = ini.get(section, "dl_lock") - sl_props['dl_lock'] = lockname - if lockname not in NetLocks: - NetLocks[lockname] = locks.MasterLock(lockname) - if ini.has_option(section, "ul_lock"): - lockname = ini.get(section, "ul_lock") - sl_props['ul_lock'] = lockname - if lockname not in NetLocks: - NetLocks[lockname] = locks.MasterLock(lockname) - c['workers'].append(Worker(name, password, max_builds = 1, properties = sl_props)) + ini_parse_workers(ini[section]) + +branchNames = [branches[b]["name"] for b in branches] c['protocols'] = {'pb': {'port': pb_port}} @@ -255,8 +267,6 @@ c['prioritizeBuilders'] = prioritizeBuilders ####### CHANGESOURCES -branchNames = [branches[b]["name"] for b in branches] - # find targets targets = set()