Edward Haas has uploaded a new change for review.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
net: netinfo.dhcp - dhcp info update refactoring
Change-Id: Ibd64d67f52ac30c97e0730035dbe35c9c4e3c098 Signed-off-by: Edward Haas edwardh@redhat.com --- M lib/vdsm/network/netinfo/cache.py M lib/vdsm/network/netinfo/dhcp.py 2 files changed, 15 insertions(+), 43 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/61457/1
diff --git a/lib/vdsm/network/netinfo/cache.py b/lib/vdsm/network/netinfo/cache.py index 96d2ff2..e55f8f8 100644 --- a/lib/vdsm/network/netinfo/cache.py +++ b/lib/vdsm/network/netinfo/cache.py @@ -35,8 +35,7 @@ from .addresses import getIpAddrs, getIpInfo, is_ipv6_local_auto from . import bonding from . import bridges -from .dhcp import (propose_updates_to_reported_dhcp, update_reported_dhcp, - dhcp_status, dhcp_faked_status) +from .dhcp import set_netdev_dhcp_info, dhcp_status, dhcp_faked_status from .dns import get_host_nameservers from .mtus import getMtu from . import nics @@ -89,8 +88,7 @@ devinfo.update(_devinfo(dev, routes, ipaddrs))
for network_name, network_info in six.iteritems(networking['networks']): - updates = propose_updates_to_reported_dhcp(network_info, networking) - update_reported_dhcp(updates, networking) + set_netdev_dhcp_info(network_info, networking) networking['networks'][network_name].update(LEGACY_SWITCH)
report_network_qos(networking) diff --git a/lib/vdsm/network/netinfo/dhcp.py b/lib/vdsm/network/netinfo/dhcp.py index 7fb0dee..892f46b 100644 --- a/lib/vdsm/network/netinfo/dhcp.py +++ b/lib/vdsm/network/netinfo/dhcp.py @@ -17,49 +17,15 @@ # # Refer to the README and COPYING files for full details of the license from __future__ import absolute_import -import six
from . import addresses
-# possible names of dhclient's lease files (e.g. as NetworkManager's slave) -DHCLIENT_LEASES_GLOBS = [ - '/var/lib/dhclient/dhclient*.lease*', # iproute2 configurator, initscripts - '/var/lib/NetworkManager/dhclient*-*.lease', -]
- -def propose_updates_to_reported_dhcp(network_info, networking): - """ - Report DHCPv4/6 of a network's topmost device based on the network's - configuration, to fix bug #1184497 (DHCP still being reported for hours - after a network got static IP configuration, as reporting is based on - dhclient leases). - """ - updated_networking = dict(bondings={}, bridges={}, nics={}, vlans={}) - network_device = network_info['iface'] - - for devices in ('bridges', 'vlans', 'bondings', 'nics'): - dev_info = networking[devices].get(network_device) - if dev_info: - updated_networking[devices][network_device] = { - 'dhcpv4': network_info['dhcpv4'], - 'dhcpv6': network_info['dhcpv6'], - } - break - - return updated_networking - - -def update_reported_dhcp(replacement, networking): - """ - For each network device (representing a network), apply updates to reported - DHCP-related fields, as prepared by _propose_updates_to_reported_dhcp. - """ - for device_type, devices in six.iteritems(replacement): - for device_name, replacement_device_info in six.iteritems(devices): - device_info = networking[device_type][device_name] - device_info['dhcpv4'] = replacement_device_info['dhcpv4'] - device_info['dhcpv6'] = replacement_device_info['dhcpv6'] +def set_netdev_dhcp_info(network_info, networking): + dev_info = _device_lookup(network_info['iface'], networking) + if dev_info: + dev_info['dhcpv4'] = network_info['dhcpv4'] + dev_info['dhcpv6'] = network_info['dhcpv6']
def dhcp_status(iface, ipaddrs): @@ -83,3 +49,11 @@ is_dhcpv4 = (net_attrs.get('bootproto', None) == 'dhcp') is_dhcpv6 = net_attrs.get('dhcpv6', False) return is_dhcpv4, is_dhcpv6 + + +def _device_lookup(netdev, networking): + for dev_type in ('bridges', 'vlans', 'bondings', 'nics'): + dev_info = networking[dev_type].get(netdev) + if dev_info: + return dev_info + return None
gerrit-hooks has posted comments on this change.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
Patch Set 1:
* Update tracker: IGNORE, no Bug-Url found * Check Bug-Url::WARN, no bug url found, make sure header matches 'Bug-Url: ' and is a valid url. * Check merged to previous::IGNORE, Not in stable branch (['ovirt-3.6', 'ovirt-4.0'])
Edward Haas has posted comments on this change.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
Patch Set 1: Verified+1
Unit and (legacy) Functional tests are passing.
Petr Horáček has posted comments on this change.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
Patch Set 1: Code-Review-1
(1 comment)
https://gerrit.ovirt.org/#/c/61457/1/lib/vdsm/network/netinfo/dhcp.py File lib/vdsm/network/netinfo/dhcp.py:
PS1, Line 27: dev_info['dhcpv4'] = network_info['dhcpv4'] : dev_info['dhcpv6'] = network_info['dhcpv6'] shouldn't this be the other way around? network_info[...] = dev_info[...]?
Edward Haas has posted comments on this change.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
Patch Set 1:
(1 comment)
https://gerrit.ovirt.org/#/c/61457/1/lib/vdsm/network/netinfo/dhcp.py File lib/vdsm/network/netinfo/dhcp.py:
PS1, Line 27: dev_info['dhcpv4'] = network_info['dhcpv4'] : dev_info['dhcpv6'] = network_info['dhcpv6']
shouldn't this be the other way around? network_info[...] = dev_info[...]?
Nope, it is setting the net device dhcp data, copying it from the already updated network data. (same logic as the original)
Petr Horáček has posted comments on this change.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
Patch Set 1: Code-Review+1
Dan Kenigsberg has posted comments on this change.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
Patch Set 1: Code-Review+2
raising
Dan Kenigsberg has submitted this change and it was merged.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
net: netinfo.dhcp - dhcp info update refactoring
Change-Id: Ibd64d67f52ac30c97e0730035dbe35c9c4e3c098 Signed-off-by: Edward Haas edwardh@redhat.com Reviewed-on: https://gerrit.ovirt.org/61457 Continuous-Integration: Jenkins CI Reviewed-by: Petr Horáček phoracek@redhat.com Reviewed-by: Dan Kenigsberg danken@redhat.com --- M lib/vdsm/network/netinfo/cache.py M lib/vdsm/network/netinfo/dhcp.py 2 files changed, 15 insertions(+), 43 deletions(-)
Approvals: Jenkins CI: Passed CI tests Petr Horáček: Looks good to me, but someone else must approve Dan Kenigsberg: Looks good to me, approved Edward Haas: Verified
gerrit-hooks has posted comments on this change.
Change subject: net: netinfo.dhcp - dhcp info update refactoring ......................................................................
Patch Set 2:
* Update tracker: IGNORE, no Bug-Url found * Set MODIFIED::IGNORE, no Bug-Url found.
vdsm-patches@lists.fedorahosted.org