ControllerAPI doesn't need hosts for __init__ now
new method match() - removes previous configuration from slaves,
if the run has first_run flag, then set_machine requirements
then it prepares the test environment meaning it runs the matching
algorithm and prepares network, hosts and interfaces for test run
Signed-off-by: Jiri Prochazka <jprochaz(a)redhat.com>
---
lnst/Controller/Task.py | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
index 4f9e23a..af9c201 100644
--- a/lnst/Controller/Task.py
+++ b/lnst/Controller/Task.py
@@ -56,14 +56,43 @@ def add_host(params=None):
ctl.add_host(m_id, handle)
return handle
+def match():
+ ctl.cleanup_slaves()
+
+ if ctl.first_run:
+ ctl.first_run = False
+ ctl.set_machine_requirements()
+
+ if ctl.prepare_test_env():
+ if ctl.get_run_mode == "match_setup":
+ return False
+ if ctl.packet_capture():
+ ctl.start_packet_capture()
+ return True
+ else:
+ if ctl._ctl._multi_match:
+ if ctl.prepare_test_env():
+ if ctl.get_run_mode == "match_setup":
+ return False
+ if ctl.packet_capture():
+ ctl.start_packet_capture()
+ return True
+ else:
+ return False
+ else:
+ return False
+
+
class TaskError(Exception): pass
class ControllerAPI(object):
""" An API class representing the controller. """
- def __init__(self, ctl, hosts):
+ def __init__(self, ctl):
self._ctl = ctl
+ self._run_mode = ctl._get_run_mode()
self._result = True
+ self.first_run = True
self._m_id_seq = 0
self.mreq = {}
--
2.4.11