Change in vdsm[master]: ethtool: remove vdsm dependency on ethtool
asegurap at redhat.com
asegurap at redhat.com
Wed Sep 3 11:58:56 UTC 2014
Antoni Segura Puimedon has uploaded a new change for review.
Change subject: ethtool: remove vdsm dependency on ethtool
......................................................................
ethtool: remove vdsm dependency on ethtool
We only leave a dependency in the bootstrap package as it is
deprecated anyway and touching it would do more harm than good.
Change-Id: I71f97e182f3fc74cfa9e8288b1071aad1082fb6f
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M lib/vdsm/netlink/__init__.py
M lib/vdsm/netlink/addr.py
M lib/vdsm/netlink/link.py
M lib/vdsm/netlink/route.py
M tests/netinfoTests.py
M vdsm.spec.in
6 files changed, 21 insertions(+), 30 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/82/32382/1
diff --git a/lib/vdsm/netlink/__init__.py b/lib/vdsm/netlink/__init__.py
index a292e23..2ef8cfa 100644
--- a/lib/vdsm/netlink/__init__.py
+++ b/lib/vdsm/netlink/__init__.py
@@ -24,8 +24,6 @@
from Queue import Empty, Queue
from threading import BoundedSemaphore
-import ethtool
-
_POOL_SIZE = 5
_NETLINK_ROUTE = 0
CHARBUFFSIZE = 40 # Increased to fit IPv6 expanded representations
@@ -119,19 +117,14 @@
_none_proto = CFUNCTYPE(None, c_void_p)
-def _ethtool_uses_libnl3():
- """Returns whether ethtool uses libnl3."""
- return (StrictVersion('0.9') <=
- StrictVersion(ethtool.version.split()[1].lstrip('v')))
-
-if _ethtool_uses_libnl3():
+try:
LIBNL = CDLL('libnl-3.so.200', use_errno=True)
LIBNL_ROUTE = CDLL('libnl-route-3.so.200', use_errno=True)
_nl_socket_alloc = CFUNCTYPE(c_void_p)(('nl_socket_alloc', LIBNL))
_nl_socket_free = _none_proto(('nl_socket_free', LIBNL))
-else: # libnl-1
+except OSError: # CDLL failed to lead libnl3, assume libnl-1
# Change from handle to socket as it is now more accurately called in
# libnl-3
LIBNL_ROUTE = LIBNL = CDLL('libnl.so.1', use_errno=True)
diff --git a/lib/vdsm/netlink/addr.py b/lib/vdsm/netlink/addr.py
index 649a1d5..960f4ee 100644
--- a/lib/vdsm/netlink/addr.py
+++ b/lib/vdsm/netlink/addr.py
@@ -21,7 +21,7 @@
from . import _cache_manager, _nl_cache_get_first, _nl_cache_get_next
from . import _char_proto, _int_char_proto, _int_proto, _void_proto
-from . import _ethtool_uses_libnl3, LIBNL_ROUTE, _nl_geterror, _pool
+from . import LIBNL, LIBNL_ROUTE, _nl_geterror, _pool
from . import _addr_to_str, _af_to_str, _scope_to_str, CHARBUFFSIZE
from .link import _nl_link_cache, _link_index_to_name
@@ -64,7 +64,7 @@
# This helps ctypes know the calling conventions it should use to communicate
# with the binary interface of libnl and which types it should allocate and
# cast. Without it ctypes fails when not running on the main thread.
-if _ethtool_uses_libnl3():
+if LIBNL != LIBNL_ROUTE:
_addr_alloc_cache = CFUNCTYPE(c_int, c_void_p, c_void_p)(
('rtnl_addr_alloc_cache', LIBNL_ROUTE))
diff --git a/lib/vdsm/netlink/link.py b/lib/vdsm/netlink/link.py
index c66dc4a..13d00c4 100644
--- a/lib/vdsm/netlink/link.py
+++ b/lib/vdsm/netlink/link.py
@@ -24,7 +24,7 @@
from . import _cache_manager, _nl_cache_get_first, _nl_cache_get_next
from . import _char_proto, _int_char_proto, _int_proto, _void_proto
-from . import _ethtool_uses_libnl3, LIBNL_ROUTE, _nl_geterror, _pool
+from . import LIBNL, LIBNL_ROUTE, _nl_geterror, _pool
from . import _addr_to_str, CHARBUFFSIZE
@@ -64,7 +64,7 @@
# libnl-1 has a bug when getting type information.
# https://github.com/tgraf/libnl-1.1-stable/issues/1
# TODO: Add for libnl1 if the bug is fixed
- if _ethtool_uses_libnl3():
+ if LIBNL != LIBNL_ROUTE:
link_type = _rtnl_link_get_type(link)
if link_type is not None:
info['type'] = link_type
@@ -102,7 +102,7 @@
# This helps ctypes know the calling conventions it should use to communicate
# with the binary interface of libnl and which types it should allocate and
# cast. Without it ctypes fails when not running on the main thread.
-if _ethtool_uses_libnl3():
+if LIBNL != LIBNL_ROUTE:
_link_alloc_cache = CFUNCTYPE(c_int, c_void_p, c_int, c_void_p)(
('rtnl_link_alloc_cache', LIBNL_ROUTE))
_link_is_vlan = _int_proto(('rtnl_link_is_vlan', LIBNL_ROUTE))
diff --git a/lib/vdsm/netlink/route.py b/lib/vdsm/netlink/route.py
index fc1048e..5d1c3b0 100644
--- a/lib/vdsm/netlink/route.py
+++ b/lib/vdsm/netlink/route.py
@@ -22,7 +22,7 @@
from . import _cache_manager, _nl_cache_get_first, _nl_cache_get_next
from . import _char_proto, _int_proto, _void_proto
-from . import _ethtool_uses_libnl3, LIBNL_ROUTE, _nl_geterror, _pool
+from . import LIBNL, LIBNL_ROUTE, _nl_geterror, _pool
from . import _addr_to_str, _af_to_str, _scope_to_str
from .link import _nl_link_cache, _link_index_to_name
@@ -53,11 +53,11 @@
if oif_index > 0:
data['oif'] = _link_index_to_name(link_cache, oif_index)
table = _rtnl_route_get_table(route)
- if _ethtool_uses_libnl3() or table != _RT_TABLE_COMPAT:
+ if LIBNL != LIBNL_ROUTE or table != _RT_TABLE_COMPAT:
data['table'] = table
return data
-if _ethtool_uses_libnl3():
+if LIBNL != LIBNL_ROUTE:
_route_alloc_cache = CFUNCTYPE(c_int, c_void_p, c_int, c_int, c_void_p)(
('rtnl_route_alloc_cache', LIBNL_ROUTE))
_route_get_nnexthops = _int_proto(('rtnl_route_get_nnexthops',
diff --git a/tests/netinfoTests.py b/tests/netinfoTests.py
index 810e3dc..50b5c62 100644
--- a/tests/netinfoTests.py
+++ b/tests/netinfoTests.py
@@ -24,13 +24,12 @@
import time
from xml.dom import minidom
-import ethtool
-
from vdsm import ipwrapper
from vdsm import netconfpersistence
from vdsm import netinfo
from vdsm.netinfo import (getBootProtocol, getDhclientIfaces, BONDING_MASTERS,
BONDING_OPT, _randomIfaceName, _getBondingOptions)
+from vdsm.netlink import addr as nl_addr
from functional import dummy, veth
from ipwrapperTests import _fakeTypeDetection
@@ -95,18 +94,16 @@
self.assertEqual('::ffff:127.0.0.1', netinfo.IPv4toMapped('127.0.0.1'))
def testGetDeviceByIP(self):
- for dev in ethtool.get_interfaces_info(ethtool.get_active_devices()):
+ for addr in nl_addr.iter_addrs():
# 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.getDeviceByIP(ip))
+ if addr['scope'] != 'link':
+ self.assertEqual(
+ addr['label'],
+ netinfo.getDeviceByIP(addr['address'].split('/')[0]))
def _testNics(self):
"""Creates a test fixture so that nics() reports:
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 323b586..6f21278 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -78,7 +78,6 @@
# BuildRequires needed by the tests during the build
BuildRequires: dosfstools
BuildRequires: psmisc
-BuildRequires: python-ethtool
BuildRequires: python-inotify
BuildRequires: python-pthreading
BuildRequires: python-cpopen >= 1.3
@@ -125,7 +124,6 @@
Requires: python-cpopen >= 1.3
Requires: python-ioprocess >= 0.10
Requires: python-pthreading >= 0.1.3-3
-Requires: python-ethtool >= 0.6-3
Requires: %{name}-python-zombiereaper = %{version}-%{release}
Requires: rpm-python
Requires: nfs-utils
@@ -176,7 +174,6 @@
Requires: sanlock >= 2.8, sanlock-python
%if 0%{?rhel}
-Requires: python-ethtool >= 0.6-3
%if 0%{?rhel} >= 7
Requires: device-mapper-multipath
Requires: e2fsprogs
@@ -210,7 +207,6 @@
Requires: python >= 2.7.3
Requires: qemu-kvm >= 2:0.15.0-4
Requires: qemu-img >= 2:0.15.0-4
-Requires: python-ethtool >= 0.8-1
Requires: initscripts >= 9.42.2-1
Requires: device-mapper-multipath >= 0.4.9-18
Requires: e2fsprogs >= 1.41.14
@@ -316,6 +312,11 @@
%package bootstrap
Summary: VDSM bootstrapping package
BuildArch: noarch
+%if 0%{?rhel} < 7
+Requires: python-ethtool >= 0.6-3
+else
+Requires: python-ethtool >= 0.8-1
+%endif
%description bootstrap
VDSM bootstrapping package. Used for delivering the bootstrap code onto the
--
To view, visit http://gerrit.ovirt.org/32382
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I71f97e182f3fc74cfa9e8288b1071aad1082fb6f
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