From: Ondrej Lichtner olichtne@redhat.com
The wait method implements the old "wait for x seconds" functionality we've had in the old LNST. The method is exported to the tester/recipe throught the Controller class and uses the newly implemented wait_for_condition MessageDispatched method.
This implementation is an improvement compared to the older functionality as the Controller is still receiving and processing messages from slaves so conditions can wait for a specific update to the state of a slave and logging will still work during while we're waiting.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Controller/Controller.py | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/lnst/Controller/Controller.py b/lnst/Controller/Controller.py index 3415f63..0d30026 100644 --- a/lnst/Controller/Controller.py +++ b/lnst/Controller/Controller.py @@ -14,6 +14,7 @@ olichtne@redhat.com (Ondrej Lichtner)
import os import sys +import time import datetime import logging from lnst.Common.Logs import LoggingCtl, log_exc_traceback @@ -128,6 +129,17 @@ class Controller(object): finally: self._cleanup_slaves()
+ def wait(self, sec): + finish_time = time.time() + sec + logging.info("Suspending recipe execution for {} seconds, " + "messages from slaves will still be processed.". + format(sec)) + + def condition(): + return time.time() > finish_time + + self._msg_dispatcher.wait_for_condition(condition) + def _map_match(self, match, requested): self._machines = {} self._hosts = Hosts()