commit baefa67cb37bfba69a8c57ee141f908afd2606d3
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Wed Aug 13 18:34:56 2014 +0200
recipe: network namespace support
This patch extends the recipe XML files to support network namespaces.
This is a pretty simple change:
* all device elemenets (eth, bond, bridge, ...) now support the "netns"
attribute which can be an arbitrary string
* command elements config, run, kill, intr and wait now also support the
"netns" attribute
At the moment there are no checks whether or not the value of the
attribute makes sense. The controller will create the namespaces based
on the device configuration so if a command uses a different namespace
it will fail. The same goes for background commands - the corresponding
signal command needs to be run in the same namespace or it will fail.
This probably can be improved in the future.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
lnst/Controller/RecipeParser.py | 12 ++++++++++++
schema-recipe.rng | 21 +++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py
index df0b47a..76da1c6 100644
--- a/lnst/Controller/RecipeParser.py
+++ b/lnst/Controller/RecipeParser.py
@@ -86,6 +86,10 @@ class RecipeParser(XmlParser):
iface["id"] = self._get_attribute(iface_tag, "id")
iface["type"] = iface_tag.tag
+ iface["netns"] = None
+ if self._has_attribute(iface_tag, "netns"):
+ iface["netns"] = self._get_attribute(iface_tag, "netns")
+
# params
params_tag = iface_tag.find("params")
params = self._process_params(params_tag)
@@ -283,6 +287,10 @@ class RecipeParser(XmlParser):
cmd = XmlData(cmd_tag)
cmd["host"] = self._get_attribute(cmd_tag, "host")
+ cmd["netns"] = None
+ if self._has_attribute(cmd_tag, "netns"):
+ cmd["netns"] = self._get_attribute(cmd_tag, "netns")
+
has_module = self._has_attribute(cmd_tag, "module")
has_command = self._has_attribute(cmd_tag, "command")
has_from = self._has_attribute(cmd_tag, "from")
@@ -323,6 +331,10 @@ class RecipeParser(XmlParser):
cmd["type"] = "config"
cmd["host"] = self._get_attribute(cmd_tag, "host")
+ cmd["netns"] = None
+ if self._has_attribute(cmd_tag, "netns"):
+ cmd["netns"] = self._get_attribute(cmd_tag, "netns")
+
if self._has_attribute(cmd_tag, "persistent"):
cmd["persistent"] = self._get_attribute(cmd_tag,
"persistent")
diff --git a/schema-recipe.rng b/schema-recipe.rng
index b623a99..6795f72 100644
--- a/schema-recipe.rng
+++ b/schema-recipe.rng
@@ -146,6 +146,9 @@
<element name="eth">
<attribute name="id"/>
<attribute name="label"/>
+ <optional>
+ <attribute name="netns"/>
+ </optional>
<interleave>
<optional>
<ref name="define"/>
@@ -179,6 +182,9 @@
<define name="ovs_bridge">
<element name="ovs_bridge">
<attribute name="id"/>
+ <optional>
+ <attribute name="netns"/>
+ </optional>
<interleave>
<optional>
@@ -275,6 +281,9 @@
</define>
<define name="softdevice">
+ <optional>
+ <attribute name="netns"/>
+ </optional>
<interleave>
<optional>
<ref name="define"/>
@@ -383,6 +392,10 @@
<attribute name="host"/>
<optional>
+ <attribute name="netns"/>
+ </optional>
+
+ <optional>
<attribute name="option"/>
<attribute name="value"/>
</optional>
@@ -421,6 +434,10 @@
<element name="run">
<attribute name="host"/>
+ <optional>
+ <attribute name="netns"/>
+ </optional>
+
<choice>
<attribute name="module"/>
<ref name="run_command"/>
@@ -483,6 +500,10 @@
<define name="signal_command">
<attribute name="host"/>
<attribute name="bg_id"/>
+
+ <optional>
+ <attribute name="netns"/>
+ </optional>
</define>
<define name="ctl_wait">
Show replies by date