Assaf Muller has uploaded a new change for review.

Change subject: Improve logging for misformed ip routes and rules
......................................................................

Improve logging for misformed ip routes and rules

Change-Id: Ie68187851964431ecb08dd791be0318b7767a554
Signed-off-by: Assaf Muller <amul...@redhat.com>
---
M lib/vdsm/ipwrapper.py
1 file changed, 15 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/39/17239/1

diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py
index 77659d7..57c8da9 100644
--- a/lib/vdsm/ipwrapper.py
+++ b/lib/vdsm/ipwrapper.py
@@ -39,10 +39,10 @@
 class Route(object):
     def __init__(self, network, ipaddr=None, device=None, table=None):
         if not _isValid(network, IPNetwork):
-            raise ValueError('network is not properly defined')
+            raise ValueError('network %s is not properly defined' % network)
 
         if ipaddr and not _isValid(ipaddr, IPAddress):
-            raise ValueError('ipaddr is not properly defined')
+            raise ValueError('ipaddr %s is not properly defined' % ipaddr)
 
         self.network = network
         self.ipaddr = ipaddr
@@ -62,7 +62,8 @@
         """
         if len(route) % 2 == 0:
             raise ValueError('The length of the textual representation of a '
-                             'route must be odd')
+                             'route must be odd. Route %s failed parsing' %
+                             route)
 
         network, params = route[0], route[1:]
         data = dict(params[i:i + 2] for i in range(0, len(params), 2))
@@ -85,11 +86,11 @@
         try:
             ipaddr = data['via']
         except KeyError:
-            raise ValueError('Routes require an IP address.')
+            raise ValueError('Route %s: Routes require an IP address.' % data)
         try:
             device = data['dev']
         except KeyError:
-            raise ValueError('Routes require a device.')
+            raise ValueError('Route %s: Routes require a device.' % data)
         table = data.get('table')
 
         return cls(data['network'], ipaddr=ipaddr, device=device, table=table)
@@ -113,13 +114,14 @@
             if not (_isValid(source, IPAddress) or
                     _isValid(source, IPNetwork)):
                 raise ValueError('Invalid source: Not an ip address '
-                                 'or network')
+                                 'or network. Source received: %s' % source)
 
         if destination:
             if not (_isValid(destination, IPAddress) or
                     _isValid(destination, IPNetwork)):
                 raise ValueError('Invalid destination: Not an ip address '
-                                 'or network')
+                                 'or network. Destination received: %s' %
+                                 destination)
 
         self.table = table
         self.source = source
@@ -145,17 +147,20 @@
 
         if len(rule) % 2 == 0:
             raise ValueError('The length of a textual representation of a '
-                             'rule must be odd')
+                             'rule must be odd.' +
+                             ' Rule that failed parsing: %s' % rule)
 
         data = dict(parameters[i:i + 2] for i in range(0, len(parameters), 2))
         try:
             table = data['lookup']
         except KeyError:
-            raise ValueError('Rules require "lookup" information.')
+            raise ValueError('Rules require "lookup" information.' +
+                             ' Rule that failed parsing: %s' % rule)
         try:
             source = data['from']
         except KeyError:
-            raise ValueError('Rules require "from" information.')
+            raise ValueError('Rules require "from" information.' +
+                             ' Rule that failed parsing: %s' % rule)
 
         destination = data.get('to')
         if source == 'all':


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie68187851964431ecb08dd791be0318b7767a554
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Assaf Muller <amul...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to