Edward Haas has uploaded a new change for review. Change subject: net: Setup validation for OVS - Check nics usage ......................................................................
net: Setup validation for OVS - Check nics usage OVS is not properly failing when adding a port that is already slaved to a different device (bond as an example). Therefore, there is a need to extend the validation checks to include a check that looks for nics that may have multiple usages. Change-Id: Ie1ed8805f7e1b84e784feef14c5378b41af1cbf1 Signed-off-by: Edward Haas <edwa...@redhat.com> --- M lib/vdsm/network/ovs/switch.py M lib/vdsm/network/ovs/validator.py 2 files changed, 31 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/12/64212/1 diff --git a/lib/vdsm/network/ovs/switch.py b/lib/vdsm/network/ovs/switch.py index 7f84168..599dfc6 100644 --- a/lib/vdsm/network/ovs/switch.py +++ b/lib/vdsm/network/ovs/switch.py @@ -38,7 +38,13 @@ def validate_network_setup(nets, bonds): ovs_networks = info.create_netinfo(info.OvsInfo())['networks'] kernel_nics = nics() + kernel_bonds = Bond.bonds() + kernel_bonds_slaves = set() + for bond_name in kernel_bonds: + kernel_bonds_slaves |= Bond(bond_name).slaves + validator.validate_nic_usage(nets, bonds, kernel_bonds_slaves) + for net, attrs in six.iteritems(nets): validator.validate_net_configuration( net, attrs, bonds, kernel_bonds, kernel_nics) diff --git a/lib/vdsm/network/ovs/validator.py b/lib/vdsm/network/ovs/validator.py index 4911a71..3df65f2 100644 --- a/lib/vdsm/network/ovs/validator.py +++ b/lib/vdsm/network/ovs/validator.py @@ -23,8 +23,7 @@ from vdsm.network import errors as ne -def validate_net_configuration(net, attrs, to_be_configured_bonds, - running_bonds, kernel_nics): +def validate_net_configuration(net, attrs, bonds, running_bonds, kernel_nics): """Test if network meets logical Vdsm requiremets. Bridgeless networks are allowed in order to support Engine requirements. @@ -40,8 +39,9 @@ if nic and nic not in kernel_nics: raise ne.ConfigNetworkError( ne.ERR_BAD_NIC, 'Nic %s does not exist' % nic) - if bond and (bond not in running_bonds and - bond not in to_be_configured_bonds): + running_bond = bond in running_bonds + new_bond = bond in bonds and 'remove' not in bonds[bond] + if bond and not running_bond and not new_bond: raise ne.ConfigNetworkError( ne.ERR_BAD_BONDING, 'Bond %s does not exist' % bond) else: @@ -65,6 +65,27 @@ raise ne.ConfigNetworkError(ne.ERR_BAD_NIC, 'Missing nics attribute') +def validate_nic_usage(nets, bonds, kernel_bonds_slaves): + request_bonds_slaves = set() + for bond_attr in six.itervalues(bonds): + if 'remove' in bond_attr: + continue + request_bonds_slaves |= set(bond_attr['nics']) + + request_nets_nics = set() + for net_attr in six.itervalues(nets): + if 'remove' in net_attr: + continue + request_nets_nics |= set(net_attr.get('nic', ())) + + shared_nics = ((request_bonds_slaves | kernel_bonds_slaves) & + request_nets_nics) + if shared_nics: + raise ne.ConfigNetworkError(ne.ERR_USED_NIC, + 'Nic/s with multiple usages: ' + + shared_nics) + + def _validate_bond_addition(nics, kernel_nics): for nic in nics: if nic not in kernel_nics: -- To view, visit https://gerrit.ovirt.org/64212 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie1ed8805f7e1b84e784feef14c5378b41af1cbf1 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Edward Haas <edwa...@redhat.com> _______________________________________________ vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org