[lnst] XmlTemplates: fix for ip function parameter

Jiří Pírko jirka at fedoraproject.org
Thu Aug 23 09:26:34 UTC 2012


commit 47b8946ea1eab3c08134d0f152175fb66e775468
Author: Ondrej Lichtner <olichtne at redhat.com>
Date:   Thu Aug 23 10:44:45 2012 +0200

    XmlTemplates: fix for ip function parameter
    
    When the third parameter of template function ip was negative it would
    produce an IndexError exception instead of XmlTemplateError.
    This commit fixes that.
    
    Signed-off-by: Ondrej Lichtner <olichtne at redhat.com>

 Common/XmlTemplates.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/Common/XmlTemplates.py b/Common/XmlTemplates.py
index 6afcc05..9a62481 100644
--- a/Common/XmlTemplates.py
+++ b/Common/XmlTemplates.py
@@ -234,7 +234,7 @@ class XmlTemplates:
             msg = "Second parameter of function ip() is invalid: "\
                     "Interface %s does not exist." % if_id
             raise XmlTemplateError(msg)
-        if ip_id >= len(machine['netconfig'][if_id]['addresses']):
+        if ip_id >= len(machine['netconfig'][if_id]['addresses']) or ip_id < 0:
             msg = "Third parameter of function ip() is invalid: "\
                     "Address %s does not exist." % ip_id
             raise XmlTemplateError(msg)


More information about the LNST-developers mailing list