commit 3e30eaa99ce33f43aa1a48f65a9bef2e4fd4bde7
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Oct 27 17:11:41 2014 +0100
lnst-ctl: fix get_recipe_results for single matches
This patch spparates the code for the first match of a recipe from the
code for additional matches. This fixes a few issues introduced in the
multi match support patches, such as wrong error reporting when no
suitable match was found.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst-ctl | 49 ++++++++++++++++++++++++++++++-------------------
1 files changed, 30 insertions(+), 19 deletions(-)
---
diff --git a/lnst-ctl b/lnst-ctl
index 9d72503..5f3b22f 100755
--- a/lnst-ctl
+++ b/lnst-ctl
@@ -98,29 +98,40 @@ def get_recipe_result(action, file_path, log_ctl, res_serializer,
no_match = False
while True:
res = {}
- try:
- nettestctl.provision_machines()
- log_ctl.set_recipe(file_path, expand="match_%d" % matches)
- recipe_head_log_entry(file_path, matches)
- nettestctl.print_match_description()
- res_serializer.add_recipe(file_path, matches)
- res = exec_action(action, nettestctl)
- except NoMatchError as err:
- no_match = True
- if matches == 1:
+ if matches == 1:
+ try:
+ log_ctl.set_recipe(file_path, expand="match_%d" % matches)
+ recipe_head_log_entry(file_path, matches)
+ res_serializer.add_recipe(file_path, matches)
+ nettestctl.provision_machines()
+ nettestctl.print_match_description()
+ res = exec_action(action, nettestctl)
+ except Exception as err:
+ no_match = True
+ log_exc_traceback()
+ logging.error(err)
res["passed"] = False
+ res["err_msg"] = str(err)
retval = RETVAL_ERR
- raise err
- else:
+ elif matches > 1:
+ try:
+ nettestctl.provision_machines()
+ log_ctl.set_recipe(file_path, expand="match_%d" % matches)
+ recipe_head_log_entry(file_path, matches)
+ res_serializer.add_recipe(file_path, matches)
+ nettestctl.print_match_description()
+ res = exec_action(action, nettestctl)
+ except NoMatchError as err:
+ no_match = True
log_ctl.unset_recipe()
logging.warning("Match %d not possible." % matches)
- except Exception as err:
- no_match = True
- log_exc_traceback()
- logging.error(err)
- res["passed"] = False
- res["err_msg"] = str(err)
- retval = RETVAL_ERR
+ except Exception as err:
+ no_match = True
+ log_exc_traceback()
+ logging.error(err)
+ res["passed"] = False
+ res["err_msg"] = str(err)
+ retval = RETVAL_ERR
if no_match and matches > 1:
break
Show replies by date