Change in vdsm[master]: net: native ovs: ovs bonding setup
phoracek at redhat.com
phoracek at redhat.com
Wed Apr 20 15:25:54 UTC 2016
Petr Horáček has uploaded a new change for review.
Change subject: net: native ovs: ovs bonding setup
......................................................................
net: native ovs: ovs bonding setup
Basic OVS bonding devices handling.
Change-Id: Id2a3b698524d448fbc968c96a2c8104e57e770d6
Bug-Url: https://bugzilla.redhat.com/1195208
Signed-off-by: Petr Horáček <phoracek at redhat.com>
---
M lib/vdsm/network/ovs/devices.py
M lib/vdsm/network/ovs/switch.py
2 files changed, 52 insertions(+), 8 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/56416/1
diff --git a/lib/vdsm/network/ovs/devices.py b/lib/vdsm/network/ovs/devices.py
index 50490ec..85170e1 100644
--- a/lib/vdsm/network/ovs/devices.py
+++ b/lib/vdsm/network/ovs/devices.py
@@ -20,6 +20,9 @@
import six
+from vdsm.netinfo.bonding import parse_bond_options
+from vdsm.utils import rget
+
from .driver import create
@@ -95,31 +98,72 @@
return commands
-def _prepare_addition(nets, running_config):
+def _setup_ovs_bond(bond, attrs, running_config):
+ commands = []
+ commands.append(ovsdb.add_bond(BRIDGE_NAME, bond, attrs.get('nics'),
+ fake_iface=True, may_exist=True))
+
+ bond_options = parse_bond_options(attrs.get('options'))
+ mode = rget(bond_options, ('custom', 'ovs_mode')) or 'active-backup'
+ lacp = rget(bond_options, ('custom', 'ovs_lacp')) or 'off'
+ commands.append(ovsdb.set_port_attr(bond, 'bond_mode', mode))
+ commands.append(ovsdb.set_port_attr(bond, 'lacp', lacp))
+
+ running_config.setBonding(bond, {'nics': attrs.get('nics'),
+ 'options': attrs.get('options'),
+ 'switch': 'ovs'})
+ return commands
+
+
+def _edit_ovs_bond(bond, attrs, running_config):
+ commands = []
+ current = set(rget(running_config.bonds, (bond, 'nics')))
+ new = set(attrs.get('nics'))
+ add = new - current
+ remove = current - new
+ for nic in add:
+ commands.append(ovsdb.attach_bond_slave(bond, nic))
+ for nic in remove:
+ commands.append(ovsdb.detach_bond_slave(bond, nic))
+
+ commands.extend(_setup_ovs_bond(bond, attrs, running_config))
+ return commands
+
+
+def _prepare_addition(nets, bonds, running_config):
commands = []
nets_by_nics = _get_nets_by_nics(running_config.networks)
+
+ for bond, attrs in six.iteritems(bonds):
+ if bond in running_config.bonds:
+ commands.extend(_edit_ovs_bond(bond, attrs, running_config))
+ else:
+ commands.extend(_setup_ovs_bond(bond, attrs, running_config))
for net, attrs in six.iteritems(nets):
commands.extend(
_add_ovs_net(net, attrs, running_config, nets_by_nics))
return commands
-def _prepare_removal(nets, running_config):
+def _prepare_removal(nets, bonds, running_config):
commands = []
nets_by_nics = _get_nets_by_nics(running_config.networks)
for net in nets:
commands.extend(_remove_ovs_net(net, running_config, nets_by_nics))
+ for bond in bonds:
+ commands.append(ovsdb.del_port(BRIDGE_NAME, bond))
+ running_config.removeBonding(bond)
return commands
-def remove(nets, running_config):
- commands = _prepare_removal(nets, running_config)
+def remove(nets, bonds, running_config):
+ commands = _prepare_removal(nets, bonds, running_config)
with ovsdb.transaction() as t:
t.add(*commands)
-def add(nets, running_config):
- commands = _prepare_addition(nets, running_config)
+def add(nets, bonds, running_config):
+ commands = _prepare_addition(nets, bonds, running_config)
with ovsdb.transaction() as t:
t.add(ovsdb.add_br(BRIDGE_NAME, may_exist=True))
t.add(*commands)
diff --git a/lib/vdsm/network/ovs/switch.py b/lib/vdsm/network/ovs/switch.py
index dc9bfd5..f723000 100644
--- a/lib/vdsm/network/ovs/switch.py
+++ b/lib/vdsm/network/ovs/switch.py
@@ -62,8 +62,8 @@
bonds_to_be_added_or_edited, bonds_to_be_removed = _split_bonds_action(
bonds, running_config.bonds)
- devices.remove(nets_to_be_removed, running_config)
- devices.add(nets_to_be_added, running_config)
+ devices.remove(nets_to_be_removed, bonds_to_be_removed, running_config)
+ devices.add(nets_to_be_added, bonds_to_be_added_or_edited, running_config)
def _split_nets_action(nets, configured_nets):
--
To view, visit https://gerrit.ovirt.org/56416
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id2a3b698524d448fbc968c96a2c8104e57e770d6
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>
More information about the vdsm-patches
mailing list