This commit fixes bug (trac #3) in system config code, namely the NetTestCommandSystemConfig class.
In cases when value was assigned to a same option multiple times within a single system_config command, only the first value was used. The remaining ones were discarded.
Now the option is set one by one to all the values as they are specified in the command.
Signed-off-by: Radek Pazdera rpazdera@redhat.com --- NetTest/NetTestCommand.py | 11 +++++++---- NetTest/NetTestParse.py | 5 ++++- 2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/NetTest/NetTestCommand.py b/NetTest/NetTestCommand.py index 8c0ef82..ae1297f 100644 --- a/NetTest/NetTestCommand.py +++ b/NetTest/NetTestCommand.py @@ -147,8 +147,10 @@ class NetTestCommandSystemConfig(NetTestCommandGeneric): val = [{"value": self._command["value"]}] self._command["options"] = {opt: val}
- for option, values in self._command["options"].iteritems(): - new_val = values[0]["value"] + for option, opt_data in self._command["options"].iteritems(): + new_values = [] + for record in opt_data: + new_values.append(record["value"])
option_abspath = os.path.abspath(option) if option_abspath[0:5] != "/sys/" and \ @@ -159,12 +161,13 @@ class NetTestCommandSystemConfig(NetTestCommandGeneric):
try: prev_val = self._retrive_option(option) - self._set_option(option, new_val) + for new_val in new_values: + self._set_option(option, new_val) except ExecCmdFail: self.set_fail("Unable to set %s config option!" % option) return
- res_data[option] = {"current_val": new_val, + res_data[option] = {"current_val": new_values[-1], "previous_val": prev_val}
res = {"passed": True} diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py index fbe5adc..ce1d7a6 100644 --- a/NetTest/NetTestParse.py +++ b/NetTest/NetTestParse.py @@ -391,7 +391,10 @@ class CommandParse(RecipeParser):
command["machine_id"] = machine_id command["type"] = self._get_attribute(node, "type") - command["value"] = self._get_attribute(node, "value") + + command["value"] = None + if self._has_attribute(node, "value"): + command["value"] = self._get_attribute(node, "value")
if self._has_attribute(node, "timeout"): command["timeout"] = self._get_attribute(node, "timeout", int)
lnst-developers@lists.fedorahosted.org