Change in vdsm[master]: cleanup: Networking code logging and docstring fixes

asegurap at redhat.com asegurap at redhat.com
Fri Oct 25 11:14:34 UTC 2013


Antoni Segura Puimedon has uploaded a new change for review.

Change subject: cleanup: Networking code logging and docstring fixes
......................................................................

cleanup: Networking code logging and docstring fixes

Change-Id: Ia50c60e6cd4aab0a4ef49d1d9a2d43b52b187ce2
Signed-off-by: Antoni S. Puimedon <asegurap at redhat.com>
---
M vdsm/netmodels.py
M vdsm/sourceRoute.py
2 files changed, 19 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/53/20553/1

diff --git a/vdsm/netmodels.py b/vdsm/netmodels.py
index 554ce4b..e6feeb5 100644
--- a/vdsm/netmodels.py
+++ b/vdsm/netmodels.py
@@ -139,7 +139,7 @@
 
 
 class Bridge(NetDevice):
-    '''This class represents traditional kernel bridges.'''
+    """This class represents traditional kernel bridges."""
     MAX_NAME_LEN = 15
     ILLEGAL_CHARS = frozenset(':. \t')
 
@@ -270,7 +270,7 @@
 
     @classmethod
     def validateOptions(cls, bonding, bondingOptions):
-        'Example: BONDING_OPTS="mode=802.3ad miimon=150"'
+        """Example: BONDING_OPTS="mode=802.3ad miimon=150\""""
         with cls._validationBond(bonding) as bond:
             try:
                 for option in bondingOptions.split():
@@ -348,7 +348,7 @@
 
     @classmethod
     def validateGateway(cls, gateway):
-        '''Validates the gateway form.'''
+        """Validates the gateway form."""
         try:
             cls.validateAddress(gateway)
         except ConfigNetworkError as cne:
diff --git a/vdsm/sourceRoute.py b/vdsm/sourceRoute.py
index 73fe075..72519d9 100644
--- a/vdsm/sourceRoute.py
+++ b/vdsm/sourceRoute.py
@@ -65,7 +65,7 @@
 
     def configure(self, ipaddr, mask, gateway):
         if gateway in (None, '0.0.0.0') or not ipaddr or not mask:
-            logging.error("ipaddr, mask or gateway not received")
+            logging.error('ipaddr, mask or gateway not received')
             return
 
         self.ipaddr = ipaddr
@@ -75,10 +75,10 @@
         network = netaddr.IPNetwork(str(self.ipaddr) + '/' + str(self.mask))
         self.network = "%s/%s" % (network.network, network.prefixlen)
 
-        logging.info(("Configuring gateway - ip: %s, network: %s, " +
-                      "subnet: %s, gateway: %s, table: %s, device: %s") %
-                     (self.ipaddr, self.network, self.mask, self.gateway,
-                      self.table, self.device))
+        logging.info('Configuring gateway - ip: %s, network: %s, subnet: %s, '
+                     'gateway: %s, table: %s, device: %s', self.ipaddr,
+                     self.network, self.mask, self.gateway, self.table,
+                     self.device)
 
         self.routes = self._buildRoutes()
         self.rules = self._buildRules()
@@ -87,8 +87,8 @@
             self.configurator.configureSourceRoute(self.routes, self.rules,
                                                    self.device)
         except IPRoute2Error as e:
-            logging.error('ip binary failed during source route configuration',
-                          ': %s' % e.message)
+            logging.error('ip binary failed during source route configuration'
+                          ': %s', e.message)
 
     def remove(self):
         self.configurator.removeSourceRoute(None, None, self.device)
@@ -116,13 +116,11 @@
             try:
                 route = Route.fromText(entry)
             except ValueError:
-                logging.debug("Could not parse route %s" % entry)
+                logging.debug('Could not parse route %s', entry)
             else:
                 if route.device == device:
-                    """
-                    When displaying routes from a table, the table is omitted,
-                    so add it back again
-                    """
+                    # When displaying routes from a table, the table is
+                    # omitted, so add it back again
                     route.table = table
                     routes.append(route)
 
@@ -133,7 +131,7 @@
         if rules:
             return rules[0].table
         else:
-            logging.error("Table not found")
+            logging.error('Table not found')
             return None
 
     @staticmethod
@@ -151,7 +149,7 @@
             try:
                 rule = Rule.fromText(entry)
             except ValueError:
-                logging.debug("Could not parse rule %s" % entry)
+                logging.debug('Could not parse rule %s', entry)
             else:
                 allRules.append(rule)
 
@@ -159,7 +157,7 @@
         rules = [rule for rule in allRules if rule.srcDevice == device]
 
         if not rules:
-            logging.error("Routing rules not found for device %s" % device)
+            logging.error('Routing rules not found for device %s', device)
             return
 
         # Extract its destination network
@@ -172,7 +170,7 @@
         return rules
 
     def remove(self):
-        logging.info("Removing gateway - device: %s" % self.device)
+        logging.info('Removing gateway - device: %s', self.device)
 
         rules = self._getRules(self.device)
         if rules:
@@ -184,7 +182,7 @@
                         self.device)
                 except IPRoute2Error as e:
                     logging.error('ip binary failed during source route '
-                                  'removal: %s' % e.message)
+                                  'removal: %s', e.message)
 
     def _isLibvirtInterfaceFallback(self):
         """
@@ -209,7 +207,7 @@
         except libvirtError:  # libvirt might not be started or it just fails
             logging.error('Libvirt failed to answer. It might be the case that'
                           ' this script is being run before libvirt startup. '
-                          ' Thus, check if vdsm owns %s an alternative way' %
+                          ' Thus, check if vdsm owns %s an alternative way',
                           self.device)
             return self._isLibvirtInterfaceFallback()
         trackedInterfaces = [network.get('bridge') or network.get('iface')


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

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