[PATCH] XmlTemplates: fix for ip function parameter
olichtne at redhat.com
olichtne at redhat.com
Thu Aug 23 08:44:45 UTC 2012
From: Ondrej Lichtner <olichtne at redhat.com>
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 file changed, 1 insertion(+), 1 deletion(-)
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)
--
1.7.11.4
More information about the LNST-developers
mailing list