Edward Haas has uploaded a new change for review. Change subject: net: Refactor _canonize_networks for readablity ......................................................................
net: Refactor _canonize_networks for readablity _canonize_networks is growing, refactoring it by extracting a method per processed attribute. Change-Id: I296cd3f1dacf69fc1968fe0ca74b49e40ed72a9e Signed-off-by: Edward Haas <[email protected]> --- M lib/vdsm/network/api.py 1 file changed, 21 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/78/52478/1 diff --git a/lib/vdsm/network/api.py b/lib/vdsm/network/api.py index abb5187..465bb17 100755 --- a/lib/vdsm/network/api.py +++ b/lib/vdsm/network/api.py @@ -964,19 +964,30 @@ for attrs in six.itervalues(nets): # If net is marked for removal, normalize the mark to boolean and # ignore all other attributes canonization. - if 'remove' in attrs: - attrs['remove'] = utils.tobool(attrs['remove']) - if attrs['remove']: + if _normalize_remove(attrs): continue - attrs['mtu'] = int(attrs['mtu']) if 'mtu' in attrs else ( - mtus.DEFAULT_MTU) + _normalize_mtu(attrs) + _normalize_vlan(attrs) - vlan = attrs.get('vlan', None) - if vlan in (None, ''): - attrs.pop('vlan', None) - else: - attrs['vlan'] = int(vlan) + +def _normalize_remove(attrs): + if 'remove' in attrs: + attrs['remove'] = utils.tobool(attrs['remove']) + return attrs['remove'] + return False + + +def _normalize_mtu(attrs): + attrs['mtu'] = int(attrs['mtu']) if 'mtu' in attrs else mtus.DEFAULT_MTU + + +def _normalize_vlan(attrs): + vlan = attrs.get('vlan', None) + if vlan in (None, ''): + attrs.pop('vlan', None) + else: + attrs['vlan'] = int(vlan) def setSafeNetworkConfig(): -- To view, visit https://gerrit.ovirt.org/52478 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I296cd3f1dacf69fc1968fe0ca74b49e40ed72a9e Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Edward Haas <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
