Skip to content

Commit 581b98f

Browse files
keeskuba-moo
authored andcommitted
pw_poller: Make trees configurable
Instead of hard-coding the trees in pw_poller.py, use a config section, for example: [trees] # name: prefix, src-path, remote[, branch] net-next: next-next, ../net-next, net-next net: net, ../net, net bpf-next: bpf-next, ../bpf-next, bpf-next bpf: bpf, ../bpf, bpf Additionally, make "results" and "worker_dir" configurable through a new "dirs" section. For example: [dirs] results: /home/kees/code/nipa/instance/results workers: /home/kees/code/nipa/instance/workers Signed-off-by: Kees Cook <[email protected]>
1 parent e9ae094 commit 581b98f

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

pw_poller.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,22 @@ def __init__(self) -> None:
3939
self._worker_id = 0
4040
self._async_workers = []
4141

42-
# TODO: make this non-static / read from a config
43-
self._trees = {
44-
"net-next": Tree("net-next", "net-next", "../net-next", "net-next"),
45-
"net": Tree("net", "net", "../net", "net"),
46-
"bpf-next": Tree("bpf-next", "bpf-next", "../bpf-next", "bpf-next"),
47-
"bpf": Tree("bpf", "bpf", "../bpf", "bpf"),
48-
}
42+
self.result_dir = config.get('dirs', 'results', fallback=os.path.join(NIPA_DIR, "results"))
43+
self.worker_dir = config.get('dirs', 'workers', fallback=os.path.join(NIPA_DIR, "workers"))
44+
tree_dir = config.get('dirs', 'trees', fallback=os.path.join(NIPA_DIR, "../"))
45+
self._trees = { }
46+
for tree in config['trees']:
47+
opts = [x.strip() for x in config['trees'][tree].split(',')]
48+
prefix = opts[0]
49+
fspath = opts[1]
50+
remote = opts[2]
51+
branch = None
52+
if len(opts) > 3:
53+
branch = opts[3]
54+
src = os.path.join(tree_dir, fspath)
55+
# name, pfx, fspath, remote=None, branch=None
56+
self._trees[tree] = Tree(tree, prefix, src, remote=remote, branch=branch)
4957

50-
self.result_dir = config.get('results', 'dir', fallback=os.path.join(NIPA_DIR, "results"))
51-
self.worker_dir = config.get('workers', 'dir', fallback=os.path.join(NIPA_DIR, "workers"))
5258
if os.path.exists(self.worker_dir):
5359
shutil.rmtree(self.worker_dir)
5460
os.makedirs(self.worker_dir)
@@ -113,9 +119,11 @@ def _series_determine_tree(self, s: PwSeries) -> str:
113119
log_open_sec('Series should have had a tree designation')
114120
else:
115121
log_open_sec('Series okay without a tree designation')
116-
if netdev.series_is_a_fix_for(s, self._trees["net"]):
122+
123+
# TODO: make this configurable
124+
if "net" in self._trees and netdev.series_is_a_fix_for(s, self._trees["net"]):
117125
s.tree_name = "net"
118-
elif self._trees["net-next"].check_applies(s):
126+
elif "net-next" in self._trees and self._trees["net-next"].check_applies(s):
119127
s.tree_name = "net-next"
120128

121129
if s.tree_name:

0 commit comments

Comments
 (0)