commit 7146d553c3fd54b48ea9c7cd41210b68ac4722f8
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon May 12 15:43:30 2014 +0200
RecipeParser: sepparate vlan parsing/validation
This commit separates the parsing/validation of <vlan> elements from the
group of virtual devices. The main reason is to check that the element
has _exactly one_ slave defined. Checking this in a different place
would be problematic...
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/RecipeParser.py | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py
index 046d6d9..df0b47a 100644
--- a/lnst/Controller/RecipeParser.py
+++ b/lnst/Controller/RecipeParser.py
@@ -105,7 +105,7 @@ class RecipeParser(XmlParser):
if iface["type"] == "eth":
iface["network"] = self._get_attribute(iface_tag,
"label")
- elif iface["type"] in ["bond", "bridge",
"vlan", "macvlan", "team"]:
+ elif iface["type"] in ["bond", "bridge",
"macvlan", "team"]:
# slaves
slaves_tag = iface_tag.find("slaves")
if slaves_tag is not None and len(slaves_tag) > 0:
@@ -127,6 +127,27 @@ class RecipeParser(XmlParser):
opts = self._proces_options(opts_tag)
if len(opts) > 0:
iface["options"] = opts
+ elif iface["type"] in ["vlan"]:
+ # real_dev of the VLAN interface
+ slaves_tag = iface_tag.find("slaves")
+ if slaves_tag is None or len(slaves_tag) != 1:
+ msg = "VLAN '%s' need exactly one slave definition."\
+ % iface["id"]
+ raise RecipeError(msg, vlan)
+
+ iface["slaves"] = XmlCollection(slaves_tag)
+
+ slave_tag = slaves_tag[0]
+ slave = XmlData(slave_tag)
+ slave["id"] = self._get_attribute(slave_tag, "id")
+
+ iface["slaves"].append(slave)
+
+ # interface options
+ opts_tag = iface_tag.find("options")
+ opts = self._proces_options(opts_tag)
+ if len(opts) > 0:
+ iface["options"] = opts
elif iface["type"] == "ovs_bridge":
slaves_tag = iface_tag.find("slaves")
iface["slaves"] = XmlCollection(slaves_tag)
Show replies by thread