2016-07-12 14:42 GMT+02:00 Jiri Pirko <jiri@resnulli.us>:
Tue, Jul 12, 2016 at 11:00:28AM CEST, jprochaz@redhat.com wrote:
>This patch adds several methods which will be used in upcoming PyRecipes
>implementation (I'll describe only those which are not self-explanatory):
>
> breakpoint(): new functionality which will work as debugging
>   breakpoints - it stops execution of the test and wait for user's signal
>   to continue the test.
>
> add_host(): prepares HostAPI object which will be initialized later
>   (after the match).
>
> match(): runs matching algorithm and returns True when the following
>   code should be executed (first run of the test and/or multi match
>   runs). It also calls the method for provisioning of the machines.
>
>Signed-off-by: Jiri Prochazka <jprochaz@redhat.com>
>---
> lnst/Controller/Task.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 51 insertions(+)
>
>diff --git a/lnst/Controller/Task.py b/lnst/Controller/Task.py
>index 178d774..9fc11e3 100644
>--- a/lnst/Controller/Task.py
>+++ b/lnst/Controller/Task.py
>@@ -32,6 +32,57 @@ except:
> # The handle to be imported from each task
> ctl = None
>
>+def get_alias(alias, default=None):
>+    return ctl.get_alias(alias, default)
>+
>+def get_mreq():
>+    return ctl.get_mreq()
>+
>+def wait(seconds):
>+    return ctl.wait(seconds)
>+
>+def get_module(name, options={}):
>+    return ctl.get_module(name, options)
>+
>+def breakpoint():
>+    if ctl.run_mode != "config_only":
>+        return
>+    raw_input("Breakpoint reached. Press enter to continue: ")

Why ": " ?


​My bad, will fix in v3, thanks!​


>+
>+def add_host(params=None):
>+    m_id = ctl.gen_m_id()
>+    ctl.mreq[m_id] = {'interfaces' : {}, 'params' : {}}
>+    handle =  HostAPI(ctl, m_id)
>+    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.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.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):
>--
>2.4.11
>_______________________________________________
>LNST-developers mailing list
>lnst-developers@lists.fedorahosted.org
>https://lists.fedorahosted.org/admin/lists/lnst-developers@lists.fedorahosted.org