Ido Barkan has uploaded a new change for review. Change subject: net: factor out _find_bonds_with_available_nics ......................................................................
net: factor out _find_bonds_with_available_nics Aiming to break _filter_nets_bonds apart so it will be simpler and easier to read. Change-Id: I09dc7278607b3f908a82ec1c523052c79e6269c8 Signed-off-by: Ido Barkan <ibar...@redhat.com> --- M vdsm/vdsm-restore-net-config 1 file changed, 14 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/40539/1 diff --git a/vdsm/vdsm-restore-net-config b/vdsm/vdsm-restore-net-config index eb19a1a..6f0f195 100755 --- a/vdsm/vdsm-restore-net-config +++ b/vdsm/vdsm-restore-net-config @@ -116,14 +116,10 @@ def _filter_nets_bonds(persisted_nets, persisted_bonds): """Returns only nets and bonds that can be configured with the devices present in the system""" - available_nets, available_bonds = {}, {} + available_nets = {} available_nics = netinfo.nics() - for bond, attrs in persisted_bonds.iteritems(): - available_bond_nics = [nic for nic in attrs['nics'] if - nic in available_nics] - if available_bond_nics: - available_bonds[bond] = attrs.copy() - available_bonds[bond]['nics'] = available_bond_nics + available_bonds = _find_bonds_with_available_nics(available_nics, + persisted_bonds) for net, attrs in persisted_nets.iteritems(): bond = attrs.get('bonding') @@ -155,6 +151,17 @@ return available_nets, available_bonds +def _find_bonds_with_available_nics(available_nics, persisted_bonds): + available_bonds = {} + for bond, attrs in persisted_bonds.iteritems(): + available_bond_nics = [nic for nic in attrs['nics'] if + nic in available_nics] + if available_bond_nics: + available_bonds[bond] = attrs.copy() + available_bonds[bond]['nics'] = available_bond_nics + return available_bonds + + def _get_all_configurators(): """Returns the class objects of all the configurators in the netconf pkg""" prefix = configurators.__name__ + '.' -- To view, visit https://gerrit.ovirt.org/40539 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I09dc7278607b3f908a82ec1c523052c79e6269c8 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ido Barkan <ibar...@redhat.com> _______________________________________________ vdsm-patches mailing list vdsm-patches@lists.fedorahosted.org https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches