Change in vdsm[master]: Change netinfo gateway default value from 0.0.0.0 to ''

amuller at redhat.com amuller at redhat.com
Tue Nov 5 12:57:45 UTC 2013


Assaf Muller has uploaded a new change for review.

Change subject: Change netinfo gateway default value from 0.0.0.0 to ''
......................................................................

Change netinfo gateway default value from 0.0.0.0 to ''

Previously, if a device does not have an ip addr, netmask and
gateway then netinfo will report the ipaddr as '', netmask as ''
and gateway as '0.0.0.0'.

The change (From '0.0.0.0' to '') is important both for consistency
and because input verification during setupNetworks will fail
for an empty ipaddr+netmask but '0.0.0.0' as the gateway. This
can happen if the unified network persistence upgrade was performed
on a network with no ip.

Change-Id: I64ec08bb57f317b30038c3b53851d6a9a4a90e86
Signed-off-by: Assaf Muller <amuller at redhat.com>
---
M lib/vdsm/netinfo.py
1 file changed, 13 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/12/20912/1

diff --git a/lib/vdsm/netinfo.py b/lib/vdsm/netinfo.py
index e8f2b8d..a39a35b 100644
--- a/lib/vdsm/netinfo.py
+++ b/lib/vdsm/netinfo.py
@@ -340,6 +340,10 @@
     return prefix2netmask(netmask)
 
 
+def getgateway(dev):
+    return getRoutes().get(dev, '')
+
+
 def getIpInfo(dev):
     devInfo = ethtool.get_interfaces_info(dev.encode('utf8'))[0]
     addr = devInfo.ipv4_address
@@ -473,7 +477,7 @@
     return paddr
 
 
-def _getNetInfo(iface, bridged, routes, ipv6routes, qosInbound, qosOutbound):
+def _getNetInfo(iface, bridged, gateway, ipv6routes, qosInbound, qosOutbound):
     '''Returns a dictionary of properties about the network's interface status.
     Raises a KeyError if the iface does not exist.'''
     data = {}
@@ -490,7 +494,7 @@
         ipv4addr, ipv4netmask, ipv6addrs = getIpInfo(iface)
         data.update({'iface': iface, 'bridged': bridged,
                      'addr': ipv4addr, 'netmask': ipv4netmask,
-                     'gateway': routes.get(iface, '0.0.0.0'),
+                     'gateway': gateway,
                      'ipv6addrs': ipv6addrs,
                      'ipv6gateway': ipv6routes.get(iface, '::'),
                      'mtu': str(getMtu(iface)),
@@ -505,9 +509,9 @@
     return data
 
 
-def _bridgeinfo(bridge, routes, ipv6routes):
+def _bridgeinfo(bridge, gateway, ipv6routes):
     info = _devinfo(bridge)
-    info.update({'gateway': routes.get(bridge, '0.0.0.0'),
+    info.update({'gateway': gateway,
                 'ipv6gateway': ipv6routes.get(bridge, '::'),
                 'ports': ports(bridge), 'stp': bridge_stp_state(bridge)})
     return (bridge, info)
@@ -544,22 +548,23 @@
 
 def get():
     d = {}
-    routes = getRoutes()
     ipv6routes = getIPv6Routes()
     paddr = permAddr()
     d['networks'] = {}
 
     for net, netAttr in networks().iteritems():
         try:
-            d['networks'][net] = _getNetInfo(netAttr.get('iface', net),
-                                             netAttr['bridged'], routes,
+            iface = netAttr.get('iface', net)
+            d['networks'][net] = _getNetInfo(iface,
+                                             netAttr['bridged'],
+                                             getgateway(iface),
                                              ipv6routes,
                                              netAttr.get('qosInbound'),
                                              netAttr.get('qosOutbound'))
         except KeyError:
             continue  # Do not report missing libvirt networks.
 
-    d['bridges'] = dict([_bridgeinfo(bridge, routes, ipv6routes)
+    d['bridges'] = dict([_bridgeinfo(bridge, getgateway(bridge), ipv6routes)
                          for bridge in bridges()])
     d['nics'] = dict([_nicinfo(nic, paddr) for nic in nics()])
     d['bondings'] = dict([_bondinfo(bond) for bond in bondings()])


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I64ec08bb57f317b30038c3b53851d6a9a4a90e86
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Assaf Muller <amuller at redhat.com>


More information about the vdsm-patches mailing list