match_setup() - now requires to run _run_python_task() in order to get mreq dict
for matching algorithm
config_only_recipe() - this method and run mode should be renamed to something like debug
mode,
because now it's same as run mode, the only difference is, that it stops executing of
recipe
on breakpoint()s until user presses Enter. Although this behaviour should be discussed
and
it will be done in next phase of PyRecipes implementation
_run_python_recipe() - modules and tools are not used now, so they cannot be loaded and
TaskAPI is initialized earlier because it's needed for setup phase for all run modes
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/NetTestController.py | 74 +++++++++++-------------------------
1 file changed, 23 insertions(+), 51 deletions(-)
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 3e7eb69..80708e5 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -452,37 +452,22 @@ class NetTestController:
def match_setup(self):
self.run_mode = "match_setup"
+ res = self._run_python_task()
return {"passed": True}
def config_only_recipe(self):
self.run_mode = "config_only"
try:
- self._prepare_network(resource_sync=False)
- except (KeyboardInterrupt, Exception) as exc:
- msg = "Exception raised during configuration."
- logging.error(msg)
- self._cleanup_slaves()
+ res = self._run_recipe()
+ except Exception as exc:
+ logging.error("Recipe execution terminated by unexpected
exception")
raise
-
- self._save_machine_config()
-
- self._cleanup_slaves(deconfigure=False)
- return {"passed": True}
-
- def run_recipe(self):
- try:
- self._prepare_tasks()
- self._prepare_network()
- except (KeyboardInterrupt, Exception) as exc:
- msg = "Exception raised during configuration."
- logging.error(msg)
+ finally:
self._cleanup_slaves()
- raise
- if self._packet_capture:
- self._start_packet_capture()
+ return res
- err = None
+ def run_recipe(self):
try:
res = self._run_recipe()
except Exception as exc:
@@ -518,43 +503,30 @@ class NetTestController:
def _run_recipe(self):
overall_res = {"passed": True}
- for task in self._tasks:
+ try:
self._res_serializer.add_task()
- try:
- res = self._run_task(task)
- except CommandException as exc:
- logging.debug(exc)
- overall_res["passed"] = False
- overall_res["err_msg"] = "Command exception raised."
- break
-
- for machine in self._machines.itervalues():
- machine.restore_system_config()
-
- # task failed, check if we should quit_on_fail
- if not res:
- overall_res["passed"] = False
- overall_res["err_msg"] = "At least one command
failed."
- if task["quit_on_fail"]:
- break
+ res = self._run_python_task()
+ except CommandException as exc:
+ logging.debug(exc)
+ overall_res["passed"] = False
+ overall_res["err_msg"] = "Command exception raised."
+
+ for machine in self._machines.itervalues():
+ machine.restore_system_config()
+
+ # task failed
+ if not res:
+ overall_res["passed"] = False
+ overall_res["err_msg"] = "At least one command failed."
return overall_res
- def _run_python_task(self, task):
+ def _run_python_task(self):
#backup of resource table
res_table_bkp = copy.deepcopy(self._resource_table)
- if 'module_dir' in task:
- modules = self._load_test_modules([task['module_dir']])
- self._resource_table['module'].update(modules)
- if 'tools_dir' in task:
- tools = self._load_test_tools([task['tools_dir']])
- self._resource_table['tools'].update(tools)
-
- # Initialize the API handle
- Task.ctl = Task.ControllerAPI(self, self._machines)
cwd = os.getcwd()
- task_path = task["python"]
+ task_path = self._recipe_path
name = os.path.basename(task_path.abs_path()).split(".")[0]
sys.path.append(os.path.dirname(task_path.resolve()))
os.chdir(os.path.dirname(task_path.resolve()))
--
2.4.11