From: Ondrej Lichtner <olichtne(a)redhat.com>
Sometimes when reusing ModuleAPI objects it is needed to unset module
options, This method should help with that.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Task.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index d3ce6ba..49ea816 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -444,6 +444,10 @@ class ModuleAPI(object):
else:
self._opts[opt].append({"value": str(val)})
+ def unset_option(self, option_name):
+ if option_name in self._opts:
+ del self._opts[option_name]
+
class ProcessAPI(object):
""" An API class representing either a running or finished process.
"""
--
2.6.1
Show replies by date
From: Ondrej Lichtner <olichtne(a)redhat.com>
The update_options method (as well as set_options) automatically
transforms option values to string type which means that setting options
to None doesn't have the expected effect.
This commit fixes that to instead use a new specialized method that
deletes the option completely from the ModuleAPI object.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/PerfRepoUtils.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lnst/Controller/PerfRepoUtils.py b/lnst/Controller/PerfRepoUtils.py
index 2dec65e..533652b 100644
--- a/lnst/Controller/PerfRepoUtils.py
+++ b/lnst/Controller/PerfRepoUtils.py
@@ -15,8 +15,8 @@ import logging
from lnst.Common.Utils import Noop
def netperf_baseline_template(module, baseline):
- module.update_options({'threshold': None,
- 'threshold_deviation': None})
+ module.unset_option('threshold')
+ module.unset_option('threshold_deviation')
if baseline.get_texec() is None:
return module
--
2.6.1