From: Ondrej Lichtner <olichtne(a)redhat.com>
The _process_interface method now returns a list of parsed interfaces.
This is because when parsing the veth_pair tag the method parses both
child veth tags and returns 2 interfaces at once. Both interfaces
contain a reference (by id) to their peer.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/RecipeParser.py | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py
index 76da1c6..3960c97 100644
--- a/lnst/Controller/RecipeParser.py
+++ b/lnst/Controller/RecipeParser.py
@@ -66,7 +66,7 @@ class RecipeParser(XmlParser):
machine["interfaces"] = XmlCollection(interfaces_tag)
for interface_tag in interfaces_tag:
interface = self._process_interface(interface_tag)
- machine["interfaces"].append(interface)
+ machine["interfaces"].extend(interface)
return machine
@@ -83,9 +83,19 @@ class RecipeParser(XmlParser):
def _process_interface(self, iface_tag):
iface = XmlData(iface_tag)
- iface["id"] = self._get_attribute(iface_tag, "id")
iface["type"] = iface_tag.tag
+ if iface["type"] == "veth_pair":
+ iface = self._process_interface(iface_tag[0])[0]
+ iface2 = self._process_interface(iface_tag[1])[0]
+
+ iface["peer"] = iface2["id"]
+ iface2["peer"] = iface["id"]
+
+ return [iface, iface2]
+
+ iface["id"] = self._get_attribute(iface_tag, "id")
+
iface["netns"] = None
if self._has_attribute(iface_tag, "netns"):
iface["netns"] = self._get_attribute(iface_tag, "netns")
@@ -222,7 +232,7 @@ class RecipeParser(XmlParser):
bond_slaves.append(slave_id)
- return iface
+ return [iface]
def _proces_options(self, opts_tag):
options = XmlCollection(opts_tag)
--
1.9.3