From: Ondrej Lichtner olichtne@redhat.com
This patch fixes a problem with Open vSwitch bridge bonds. Adding a bond requires specifying ports that should be bonded, however this command also adds those ports to the ovs bridge so they shouldn't be added by the ovs-vsctl add-port command.
This patch also adds support for specifying bond options. These are verified by the ovs-vsctl command so LNST doesn't check their validity.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com --- lnst/Controller/RecipeParser.py | 5 +++++ lnst/Slave/NetConfigDevice.py | 26 +++++++++++++++++++++++--- schema-recipe.rng | 4 ++++ 3 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/lnst/Controller/RecipeParser.py b/lnst/Controller/RecipeParser.py index 3201719..1109b35 100644 --- a/lnst/Controller/RecipeParser.py +++ b/lnst/Controller/RecipeParser.py @@ -248,6 +248,11 @@ class RecipeParser(XmlParser):
bond_slaves.append(slave_id)
+ opts_tag = bond_tag.find("options") + opts = self._proces_options(opts_tag) + if len(opts) > 0: + bonds[bond_id]["options"] = opts + return [iface]
def _proces_options(self, opts_tag): diff --git a/lnst/Slave/NetConfigDevice.py b/lnst/Slave/NetConfigDevice.py index bdcab5a..77074a6 100644 --- a/lnst/Slave/NetConfigDevice.py +++ b/lnst/Slave/NetConfigDevice.py @@ -341,7 +341,14 @@ class NetConfigDeviceOvsBridge(NetConfigDeviceGeneric):
br_name = self._dev_config["name"]
+ bond_ports = [] + for bond in self._dev_config["ovs_conf"]["bonds"].itervalues(): + for slave_id in bond["slaves"]: + bond_ports.append(slave_id) + for slave_id in slaves: + if slave_id in bond_ports: + continue slave_dev = self._if_manager.get_mapped_device(slave_id) slave_name = slave_dev.get_name()
@@ -362,7 +369,14 @@ class NetConfigDeviceOvsBridge(NetConfigDeviceGeneric):
br_name = self._dev_config["name"]
+ bond_ports = [] + for bond in self._dev_config["ovs_conf"]["bonds"].itervalues(): + for slave_id in bond["slaves"]: + bond_ports.append(slave_id) + for slave_id in slaves: + if slave_id in bond_ports: + continue slave_dev = self._if_manager.get_mapped_device(slave_id) slave_name = slave_dev.get_name()
@@ -374,9 +388,15 @@ class NetConfigDeviceOvsBridge(NetConfigDeviceGeneric): bonds = self._dev_config["ovs_conf"]["bonds"] for bond_id, bond in bonds.iteritems(): ifaces = "" - for slave in bond["slaves"]: - ifaces += " %s" % slave - exec_cmd("ovs-vsctl add-bond %s %s %s" % (br_name, bond_id, ifaces)) + for slave_id in bond["slaves"]: + slave_dev = self._if_manager.get_mapped_device(slave_id) + slave_name = slave_dev.get_name() + ifaces += " %s" % slave_name + opts = "" + for option in bond["options"]: + opts += " %s=%s" % (option["name"], option["value"]) + exec_cmd("ovs-vsctl add-bond %s %s %s %s" % (br_name, bond_id, + ifaces, opts))
def _del_bonds(self): br_name = self._dev_config["name"] diff --git a/schema-recipe.rng b/schema-recipe.rng index 2391085..81a60aa 100644 --- a/schema-recipe.rng +++ b/schema-recipe.rng @@ -217,6 +217,10 @@ <ref name="define"/> </optional>
+ <optional> + <ref name="options"/> + </optional> + <element name="slaves"> <interleave> <optional>