[PATCH] Fix issue 124

Jiri Prochazka jprochaz at redhat.com
Thu Jun 25 13:24:36 UTC 2015


Signed-off-by: Jiri Prochazka <jprochaz at redhat.com>
---
 lnst/Controller/RecipeParser.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py
index 73422f1..936a870 100644
--- a/lnst/Controller/RecipeParser.py
+++ b/lnst/Controller/RecipeParser.py
@@ -66,10 +66,18 @@ class RecipeParser(XmlParser):
             machine["interfaces"] = XmlCollection(interfaces_tag)
 
             lo_netns = []
+            unique_ids = []
             for interface_tag in interfaces_tag:
                 interfaces = self._process_interface(interface_tag)
 
                 for interface in interfaces:
+                    if interface['id'] in unique_ids:
+                        msg = "Interface with ID \"%s\" has already been "\
+                              "defined for this machine." % interface['id']
+                        raise RecipeError(msg, interface_tag)
+                    else:
+                        unique_ids.append(interface['id'])
+
                     if interface['type'] != 'lo':
                         continue
                     elif interface['netns'] in lo_netns:
@@ -77,6 +85,7 @@ class RecipeParser(XmlParser):
                         raise RecipeError(msg, interface_tag)
                     else:
                         lo_netns.append(interface['netns'])
+
                 machine["interfaces"].extend(interfaces)
 
         return machine
-- 
2.4.3



More information about the LNST-developers mailing list