Assaf Muller has uploaded a new change for review.
Change subject: BindingXMLRPC bugfix: Fix netinfo:getIfaceByIP unit test ......................................................................
BindingXMLRPC bugfix: Fix netinfo:getIfaceByIP unit test
Change-Id: Iee4757958ea5554043c6dc7169a8df05b1887687 Signed-off-by: Assaf Muller amuller@redhat.com --- M lib/vdsm/netinfo.py M tests/netinfoTests.py 2 files changed, 9 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/68/22968/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py index 790c099..2f54413 100644 --- a/lib/vdsm/netinfo.py +++ b/lib/vdsm/netinfo.py @@ -599,7 +599,6 @@
def getIfaceByIP(ip): for info in ethtool.get_interfaces_info(ethtool.get_active_devices()): - for ipv4addr in info.get_ipv4_addresses(): if ip == ipv4addr.address or ip == IPv4toMapped(ipv4addr.address): return info.device diff --git a/tests/netinfoTests.py b/tests/netinfoTests.py index 18e71c3..fb8c584 100644 --- a/tests/netinfoTests.py +++ b/tests/netinfoTests.py @@ -98,10 +98,15 @@
def testGetIfaceByIP(self): for dev in ethtool.get_interfaces_info(ethtool.get_active_devices()): - ipaddrs = map( - lambda etherinfo_ipv6addr: etherinfo_ipv6addr.address, - dev.get_ipv6_addresses()) - ipaddrs.append(dev.ipv4_address) + # Link-local IPv6 addresses are generated from the MAC address, + # which is shared between a nic and its bridge. Since We don't + # support having the same IP address on two different NICs, and + # link-local IPv6 addresses aren't interesting for 'getDeviceByIP' + # then ignore them in the test + ipaddrs = [ipv6.address for ipv6 in dev.get_ipv6_addresses() + if ipv6.scope != 'link'] + if dev.ipv4_address is not None: + ipaddrs.append(dev.ipv4_address) for ip in ipaddrs: self.assertEqual(dev.device, netinfo.getIfaceByIP(ip))