Change in vdsm[master]: libnl_wrapper: remove link_cache dependency from route.py

asegurap at redhat.com asegurap at redhat.com
Mon Sep 15 15:24:02 UTC 2014


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: libnl_wrapper: remove link_cache dependency from route.py
......................................................................

libnl_wrapper: remove link_cache dependency from route.py

Change-Id: I765cbe080f3bcff8b5d9f2eb48adf2be797d2f2f
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M lib/vdsm/netlink/route.py
1 file changed, 8 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/50/32950/1

diff --git a/lib/vdsm/netlink/route.py b/lib/vdsm/netlink/route.py
index 5d1c3b0..5fb13bb 100644
--- a/lib/vdsm/netlink/route.py
+++ b/lib/vdsm/netlink/route.py
@@ -24,7 +24,7 @@
 from . import _char_proto, _int_proto, _void_proto
 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
+from .link import _get_link_name_from_index
 
 _RT_TABLE_COMPAT = 252
 _RT_TABLE_MAIN = 254
@@ -35,14 +35,14 @@
     system."""
     with _pool.socket() as sock:
         with _nl_route_cache(sock) as route_cache:
-            with _nl_link_cache(sock) as link_cache:  # for index to label
-                route = _nl_cache_get_first(route_cache)
-                while route:
-                    yield _route_info(link_cache, route)
-                    route = _nl_cache_get_next(route)
+            _index_to_name = partial(_get_link_name_from_index, sock=sock)
+            route = _nl_cache_get_first(route_cache)
+            while route:
+                yield _route_info(route, _index_to_name)
+                route = _nl_cache_get_next(route)
 
 
-def _route_info(link_cache, route):
+def _route_info(route, _index_to_name):
     data = {
         'destination': _addr_to_str(_rtnl_route_get_dst(route)),  # network
         'source': _addr_to_str(_rtnl_route_get_src(route)),
@@ -51,7 +51,7 @@
         'scope': _scope_to_str(_rtnl_route_get_scope(route))}
     oif_index = _rtnl_route_get_oif(route)
     if oif_index > 0:
-        data['oif'] = _link_index_to_name(link_cache, oif_index)
+        data['oif'] = _index_to_name(oif_index)
     table = _rtnl_route_get_table(route)
     if LIBNL != LIBNL_ROUTE or table != _RT_TABLE_COMPAT:
         data['table'] = table


-- 
To view, visit http://gerrit.ovirt.org/32950
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I765cbe080f3bcff8b5d9f2eb48adf2be797d2f2f
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