From: Ondrej Lichtner <olichtne(a)redhat.com>
When the first match of a recipe failed the result serializer still
tried to print the match description resulting in an Exception.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/NetTestResultSerializer.py | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/lnst/Controller/NetTestResultSerializer.py
b/lnst/Controller/NetTestResultSerializer.py
index ae8bc7e..c007945 100644
--- a/lnst/Controller/NetTestResultSerializer.py
+++ b/lnst/Controller/NetTestResultSerializer.py
@@ -86,18 +86,21 @@ class NetTestResultSerializer:
recipe_head = "%s match: %d" % (recipe["name"],
recipe["match_num"])
output_pairs.append((recipe_head, recipe["result"]))
- output_pairs.append((4*" " + "Pool match description:",
""))
match = recipe["pool_match"]
- if "virtual" in match and match["virtual"]:
- output_pairs.append((4*" " + "Setup is using virtual
machines.",
- ""))
- for m_id, m in match["machines"].iteritems():
- output_pairs.append((4*" " + "host \"%s\" uses
\"%s\"" %\
- (m_id, m["target"]), ""))
- for if_id, pool_id in m["interfaces"].iteritems():
- output_pairs.append((6*" " + "interface
\"%s\" "\
- "matched to \"%s\""
%\
- (if_id, pool_id), ""))
+ if match != {}:
+ output_pairs.append((4*" " + "Pool match
description:", ""))
+ if "virtual" in match and match["virtual"]:
+ output_pairs.append((4*" " +\
+ "Setup is using virtual machines.",
+ ""))
+
+ for m_id, m in match["machines"].iteritems():
+ output_pairs.append((4*" " + "host \"%s\"
uses \"%s\"" %\
+ (m_id, m["target"]), ""))
+ for if_id, pool_id in m["interfaces"].iteritems():
+ output_pairs.append((6*" " + "interface
\"%s\" "\
+ "matched to
\"%s\"" %\
+ (if_id, pool_id), ""))
if recipe["result"] == "FAIL" and \
"err_msg" in recipe and recipe["err_msg"] !=
"":
--
1.9.3