Change in vdsm[master]: Makes getIfaceByIp return a set instead of a string
asegurap at redhat.com
asegurap at redhat.com
Tue Nov 12 22:04:20 UTC 2013
Antoni Segura Puimedon has uploaded a new change for review.
Change subject: Makes getIfaceByIp return a set instead of a string
......................................................................
Makes getIfaceByIp return a set instead of a string
It is perfectly permissible for an IP address to be assigned to
more than one interface. Thus, the method was missing part of
the information in a way that it could behave unexpectedly when
the machine had more than an interface for the same IP (breaking
even the tests).
Change-Id: Ie56ebc909d6a1ecd4218b11d680f49f85674717a
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M lib/vdsm/netinfo.py
M tests/netinfoTests.py
M vdsm/BindingXMLRPC.py
3 files changed, 7 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/97/21197/1
diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index 58d8c8c..2242245 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -612,17 +612,19 @@
def getIfaceByIP(ip):
+ """Returns the set of ifaces that are configured with the specified IP."""
+ ifaces = set()
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
+ ifaces.add(info.device)
for ipv6addr in info.get_ipv6_addresses():
if ip == ipv6addr.address:
- return info.device
+ ifaces.add(info.device)
- return ''
+ return ifaces
class NetInfo(object):
diff --git a/tests/netinfoTests.py b/tests/netinfoTests.py
index e139e96..7a11108 100644
--- a/tests/netinfoTests.py
+++ b/tests/netinfoTests.py
@@ -100,7 +100,7 @@
dev.get_ipv6_addresses())
ipaddrs.append(dev.ipv4_address)
for ip in ipaddrs:
- self.assertEqual(dev.device, netinfo.getIfaceByIP(ip))
+ self.assertIn(dev.device, netinfo.getIfaceByIP(ip))
def _dev_dirs_setup(self, dir_fixture):
"""
diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py
index 1602c5c..6ae72d7 100644
--- a/vdsm/BindingXMLRPC.py
+++ b/vdsm/BindingXMLRPC.py
@@ -89,7 +89,7 @@
lastserver = self.server.lastServerIP
return {'management_ip': self.serverIP,
'lastClient': last,
- 'lastClientIface': getIfaceByIP(lastserver)}
+ 'lastClientIface': getIfaceByIP(lastserver).pop()}
def _getKeyCertFilenames(self):
"""
--
To view, visit http://gerrit.ovirt.org/21197
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie56ebc909d6a1ecd4218b11d680f49f85674717a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Antoni Segura Puimedon <asegurap at redhat.com>
More information about the vdsm-patches
mailing list