commit 617f770b2473e89a7dbc0545f1e37b92723d1010
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Mar 3 16:00:42 2014 +0100
NetTestController: add support for {module,tools}_dir
This commit adds support for searching additional resource directories
specified by the module_dir and tools_dir attributes.
We create a deep copy of the original resource table and then update it
with the newly found modules or tools. After the task is processed we
restore the original resource table.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/NetTestController.py | 29 ++++++++++++++++++++++++++++-
1 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/NetTestController.py b/lnst/Controller/NetTestController.py
index 5adc8e9..ad5a2df 100644
--- a/lnst/Controller/NetTestController.py
+++ b/lnst/Controller/NetTestController.py
@@ -18,6 +18,7 @@ import re
import cPickle
import tempfile
import imp
+import copy
from time import sleep
from xmlrpclib import Binary
from lnst.Common.NetUtils import MacPool
@@ -217,10 +218,17 @@ class NetTestController:
recipe_name = os.path.basename(self._recipe_path)
machine.configure(recipe_name)
- res_table = self._resource_table
sync_table = {'module': {}, 'tools': {}}
if resource_sync:
for task in self._recipe['tasks']:
+ res_table = copy.deepcopy(self._resource_table)
+ if 'module_dir' in task:
+ modules = self._load_test_modules([task['module_dir']])
+ res_table['module'].update(modules)
+ if 'tools_dir' in task:
+ tools = self._load_test_tools([task['tools_dir']])
+ res_table['tools'].update(tools)
+
if 'commands' not in task:
if not self._reduce_sync:
sync_table = res_table
@@ -284,6 +292,12 @@ class NetTestController:
if "quit_on_fail" in task_data:
task["quit_on_fail"] =
bool_it(task_data["quit_on_fail"])
+ if "module_dir" in task_data:
+ task["module_dir"] = task_data["module_dir"]
+
+ if "tools_dir" in task_data:
+ task["tools_dir"] = task_data["tools_dir"]
+
if "python" in task_data:
root = RecipePath(None, self._recipe_path).get_root()
path = "%s/%s" % (root, task_data["python"])
@@ -597,11 +611,24 @@ class NetTestController:
return overall_res
def _run_python_task(self, task):
+ #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)
name = os.path.basename(task["python"]).split(".")[0]
module = imp.load_source(name, task["python"])
+
+ #restore resource table
+ self._resource_table = res_table_bkp
+
return module.ctl._result
def _run_task(self, task):
Show replies by date