From 627552cdc070b5dd2e002468659150f96d3e6b69 Mon Sep 17 00:00:00 2001 From: Douglas RAILLARD Date: Mon, 3 Dec 2018 15:59:33 +0000 Subject: [PATCH] utils: Add DEFAULT_SRC feature to MultiSrcConf --- lisa/env.py | 5 +---- lisa/utils.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lisa/env.py b/lisa/env.py index 27b0d3dc6..1747d0f76 100644 --- a/lisa/env.py +++ b/lisa/env.py @@ -125,7 +125,6 @@ class TargetConf(MultiSrcConf, HideExekallID): KeyDesc('port', 'SSH or ADB server port', [int, None]), KeyDesc('device', 'ADB device. Takes precedence over "host"', [str, None]), KeyDesc('keyfile', 'SSH private key file', [str, None]), - KeyDesc('workdir', 'Remote target workdir', [str]), KeyDesc('tools', 'List of tools to install on the target', [StrList]), LevelKeyDesc('ftrace', 'FTrace configuration', ( @@ -146,7 +145,7 @@ class TargetConf(MultiSrcConf, HideExekallID): )) )) - DEFAULT_CONF = { + DEFAULT_SRC = { 'username': USERNAME_DEFAULT, 'ftrace': { 'buffsize': FTRACE_BUFSIZE_DEFAULT, @@ -160,8 +159,6 @@ class TargetConf(MultiSrcConf, HideExekallID): def __init__(self, conf, src='user'): super().__init__(conf=conf, src=src) - # Give some preset in the the lowest prio source - self.add_src('default', self.DEFAULT_CONF, fallback=True) # We do not allow overriding source for this kind of configuration to keep # the YAML interface simple and dict-like diff --git a/lisa/utils.py b/lisa/utils.py index a79664923..29645f280 100644 --- a/lisa/utils.py +++ b/lisa/utils.py @@ -697,8 +697,13 @@ class MultiSrcConf(SerializableConfABC, Loggable, Mapping, metaclass=MultiSrcCon """ pass - def __init__(self, conf=None, src='default'): + DEFAULT_SRC = {} + """ + Source added automatically using :meth:`add_src` under the name 'default' + when instances are built. + """ + def __init__(self, conf=None, src='conf'): self._nested_init( parent=None, structure=self.STRUCTURE, @@ -707,6 +712,10 @@ class MultiSrcConf(SerializableConfABC, Loggable, Mapping, metaclass=MultiSrcCon if conf is not None: self.add_src(src, conf) + # Give some preset in the the lowest prio source + if self.DEFAULT_SRC: + self.add_src('default', self.DEFAULT_SRC, fallback=True) + @classmethod def get_help(cls, *args, **kwargs): return cls.STRUCTURE.get_help(*args, **kwargs) -- GitLab