Change in vdsm[master]: netlink: link info without cache

phoracek at redhat.com phoracek at redhat.com
Fri Sep 12 14:23:20 UTC 2014


Petr Horáček has uploaded a new change for review.

Change subject: netlink: link info without cache
......................................................................

netlink: link info without cache

Get information about object, even when we have not got cache.

We need this in netlink: event monitor patch.

Change-Id: Icbca2ce597f3103f3614366894fa45c14b2a8d21
Signed-off-by: Petr Horáček <phoracek at redhat.com>
---
M lib/vdsm/netlink/addr.py
M lib/vdsm/netlink/link.py
M lib/vdsm/netlink/route.py
3 files changed, 10 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/64/32864/1

diff --git a/lib/vdsm/netlink/addr.py b/lib/vdsm/netlink/addr.py
index 960f4ee..08a84bd 100644
--- a/lib/vdsm/netlink/addr.py
+++ b/lib/vdsm/netlink/addr.py
@@ -41,9 +41,13 @@
 def _addr_info(link_cache, addr):
     """Returns a dictionary with the address information."""
     index = _rtnl_addr_get_ifindex(addr)
+    if link_cache:
+        label = (_rtnl_addr_get_label(addr) or
+                 _link_index_to_name(link_cache, index))
+    else:
+        label = _rtnl_addr_get_label(addr)
     return {
-        'label': (_rtnl_addr_get_label(addr) or
-                  _link_index_to_name(link_cache, index)),
+        'label': label,
         'index': index,
         'family': _af_to_str(_rtnl_addr_get_family(addr)),
         'prefixlen': _rtnl_addr_get_prefixlen(addr),
diff --git a/lib/vdsm/netlink/link.py b/lib/vdsm/netlink/link.py
index 13d00c4..7139079 100644
--- a/lib/vdsm/netlink/link.py
+++ b/lib/vdsm/netlink/link.py
@@ -74,7 +74,7 @@
         info['device'] = _link_index_to_name(cache, underlying_device_index)
 
     master_index = _rtnl_link_get_master(link)
-    if master_index > 0:
+    if master_index > 0 and cache:
         info['master'] = _link_index_to_name(cache, master_index)
 
     vlanid = _rtnl_link_vlan_get_id(link)
diff --git a/lib/vdsm/netlink/route.py b/lib/vdsm/netlink/route.py
index 5d1c3b0..4d4d583 100644
--- a/lib/vdsm/netlink/route.py
+++ b/lib/vdsm/netlink/route.py
@@ -50,8 +50,10 @@
         'family': _af_to_str(_rtnl_route_get_family(route)),
         'scope': _scope_to_str(_rtnl_route_get_scope(route))}
     oif_index = _rtnl_route_get_oif(route)
-    if oif_index > 0:
+    if oif_index > 0 and link_cache:
         data['oif'] = _link_index_to_name(link_cache, oif_index)
+    elif oif_index > 0:
+        data['index'] = 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/32864
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icbca2ce597f3103f3614366894fa45c14b2a8d21
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Petr Horáček <phoracek at redhat.com>


More information about the vdsm-patches mailing list