[PATCH 1/4] Changing sequences to list of dictionaries

Jan Tluka jtluka at redhat.com
Wed Aug 15 12:58:30 UTC 2012


Signed-off-by: Jan Tluka <jtluka at redhat.com>
---
 NetTest/NetTestController.py |    2 +-
 NetTest/NetTestParse.py      |   13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index 296150d..27cf455 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -316,7 +316,7 @@ class NetTestController:
 
     def _run_command_sequence(self, sequence):
         seq_passed = True
-        for command in sequence:
+        for command in sequence["commands"]:
             logging.info("Executing command: [%s]", str_command(command))
             cmd_res = self._run_command(command)
             if self._res_serializer:
diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py
index fbe5adc..2bfe3bf 100644
--- a/NetTest/NetTestParse.py
+++ b/NetTest/NetTestParse.py
@@ -314,8 +314,9 @@ class NetConfigParse(RecipeParser):
 class CommandSequenceParse(RecipeParser):
     def parse(self, node):
         sequences = self._recipe["sequences"]
-        sequences.append([])
+        sequences.append({})
         seq_num = len(sequences) - 1
+        sequences[seq_num]["commands"] = []
 
         self._seq_num = seq_num
         self._seq_node = node
@@ -333,7 +334,7 @@ class CommandSequenceParse(RecipeParser):
     def _check_sequence(self, sequence):
         err = False
         bg_ids = {}
-        for i, command in enumerate(sequence):
+        for i, command in enumerate(sequence["commands"]):
             machine_id = command["machine_id"]
             if not machine_id in bg_ids:
                 bg_ids[machine_id] = set()
@@ -379,8 +380,8 @@ class CommandParse(RecipeParser):
     def parse(self, node):
         recipe = self._recipe
         command = {}
-        recipe["sequences"][self._seq_num].append(command)
-        self._cmd_num = len(recipe["sequences"][self._seq_num]) - 1
+        recipe["sequences"][self._seq_num]["commands"].append(command)
+        self._cmd_num = len(recipe["sequences"][self._seq_num]["commands"]) - 1
 
         if self._has_attribute(node, "machine_id"):
             machine_id = self._get_attribute(node, "machine_id", int)
@@ -418,7 +419,7 @@ class CommandParse(RecipeParser):
     def _options(self, node, params):
         seq = self._seq_num
         cmd = self._cmd_num
-        self._recipe["sequences"][seq][cmd]["options"] = {}
+        self._recipe["sequences"][seq]["commands"][cmd]["options"] = {}
 
         scheme = {"option": self._option}
         self._process_child_nodes(node, scheme)
@@ -426,7 +427,7 @@ class CommandParse(RecipeParser):
     def _option(self, node, params):
         seq = self._seq_num
         cmd = self._cmd_num
-        options = self._recipe["sequences"][seq][cmd]["options"]
+        options = self._recipe["sequences"][seq]["commands"][cmd]["options"]
 
         name = self._get_attribute(node, "name")
         if not name in options:
-- 
1.7.6.5



More information about the LNST-developers mailing list