Signed-off-by: Jerry Cen <zhiw...@google.com>
Author: Mark Lentczner <mz...@google.com>
Date: Fri, 13 Mar 2015 22:45:50 -0700
Subject: [PATCH] yet more logging call cleanups

---
  ryu/app/bmpstation.py                              |  4 +-
  ryu/services/protocols/bgp/base.py                 |  2 +-
  ryu/services/protocols/bgp/core.py                 | 14 ++---
  .../protocols/bgp/core_managers/peer_manager.py    |  2 +-
  .../protocols/bgp/core_managers/table_manager.py   |  2 +-
  ryu/services/protocols/bgp/info_base/base.py       | 10 ++--
  ryu/services/protocols/bgp/info_base/vrf.py        | 10 ++--
  ryu/services/protocols/bgp/peer.py                 | 64  
+++++++++++-----------
  ryu/services/protocols/bgp/speaker.py              |  6 +-
  9 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/ryu/app/bmpstation.py b/ryu/app/bmpstation.py
index 2f576c6..ea8f2b5 100644
--- a/ryu/app/bmpstation.py
+++ b/ryu/app/bmpstation.py
@@ -79,8 +79,8 @@ class BMPStation(app_manager.RyuApp):
                      buf = buf[len_:]
                      self.failed_pkt_count += 1
                      self.logger.error("failed to parse: %s"
-                                      " (total fail count: %d)" %
-                                      (e, self.failed_pkt_count))
+                                      " (total fail count: %d)",
+                                      e, self.failed_pkt_count)
                  else:
                      t = time.strftime("%Y %b %d %H:%M:%S",  
time.localtime())
                      self.logger.debug("%s | %s | %s\n", t, addr[0], msg)
diff --git a/ryu/services/protocols/bgp/base.py  
b/ryu/services/protocols/bgp/base.py
index d9b5eb8..228c6f4 100644
--- a/ryu/services/protocols/bgp/base.py
+++ b/ryu/services/protocols/bgp/base.py
@@ -342,7 +342,7 @@ class Activity(object):
              sock, client_address = s.accept()
              client_address, port = self.get_remotename(sock)
              LOG.debug('Connect request received from client for port'
-                      ' %s:%s' % (client_address, port))
+                      ' %s:%s', client_address, port)
              client_name = self.name + '_client@' + client_address
              self._asso_socket_map[client_name] = sock
              self._spawn(client_name, conn_handle, sock)
diff --git a/ryu/services/protocols/bgp/core.py  
b/ryu/services/protocols/bgp/core.py
index dc8d177..f62509a 100644
--- a/ryu/services/protocols/bgp/core.py
+++ b/ryu/services/protocols/bgp/core.py
@@ -263,8 +263,8 @@ class CoreService(Factory, Activity):
              # If interested RTs for a peer changes
              if new_rts or old_rts:
                  LOG.debug('RT Filter for peer %s updated: '
-                          'Added RTs %s, Removed Rts %s' %
-                          (peer.ip_address, new_rts, old_rts))
+                          'Added RTs %s, Removed Rts %s',
+                          peer.ip_address, new_rts, old_rts)
                  self._on_update_rt_filter(peer, new_rts, old_rts)
                  # Update to new RT filters
           
self._peer_manager.set_peer_to_rtfilter_map(new_peer_to_rtfilter_map)
@@ -437,8 +437,8 @@ class CoreService(Factory, Activity):
          # 2) If this neighbor is not enabled according to configuration.
          if not peer or not peer.enabled:
              LOG.debug('Closed connection %s %s:%s as it is not a  
recognized'
-                      ' peer.' % ('from' if bgp_proto.is_reactive  
else 'to',
-                                  peer_addr, peer_port))
+                      ' peer.', 'from' if bgp_proto.is_reactive else 'to',
+                      peer_addr, peer_port)
              # Send connection rejected notification as per RFC
              code = BGP_ERROR_CEASE
              subcode = BGP_ERROR_SUB_CONNECTION_RESET
@@ -446,7 +446,7 @@ class CoreService(Factory, Activity):
          elif bgp_proto.is_reactive and \
                  peer.connect_mode is CONNECT_MODE_ACTIVE:
              LOG.debug('Closed connection from %s:%s as connect_mode is'
-                      ' configured ACTIVE.' % (peer_addr, peer_port))
+                      ' configured ACTIVE.', peer_addr, peer_port)
              # Send connection rejected notification as per RFC
              code = BGP_ERROR_CEASE
              subcode = BGP_ERROR_SUB_CONNECTION_RESET
@@ -454,8 +454,8 @@ class CoreService(Factory, Activity):
          elif not (peer.in_idle() or peer.in_active() or peer.in_connect()):
              LOG.debug('Closing connection to %s:%s as we have connection'
                        ' in state other than IDLE or ACTIVE,'
-                      ' i.e. connection resolution' %
-                      (peer_addr, peer_port))
+                      ' i.e. connection resolution',
+                      peer_addr, peer_port)
              # Send Connection Collision Resolution notification as per RFC.
              code = BGP_ERROR_CEASE
              subcode = BGP_ERROR_SUB_CONNECTION_COLLISION_RESOLUTION
diff --git a/ryu/services/protocols/bgp/core_managers/peer_manager.py  
b/ryu/services/protocols/bgp/core_managers/peer_manager.py
index 597bf30..0a1cb7c 100644
--- a/ryu/services/protocols/bgp/core_managers/peer_manager.py
+++ b/ryu/services/protocols/bgp/core_managers/peer_manager.py
@@ -258,7 +258,7 @@ class PeerManager(object):
              # UPDATE to any peers
              if comm_attr_na:
                  LOG.debug('New best path has community attr. NO_ADVERTISE  
= %s'
-                          '. Hence not advertising to any peer' %  
comm_attr_na)
+                          '. Hence not advertising to any peer',  
comm_attr_na)
                  return

          qualified_peers = self._collect_peers_of_interest(
diff --git a/ryu/services/protocols/bgp/core_managers/table_manager.py  
b/ryu/services/protocols/bgp/core_managers/table_manager.py
index 9d468fc..8de4f53 100644
--- a/ryu/services/protocols/bgp/core_managers/table_manager.py
+++ b/ryu/services/protocols/bgp/core_managers/table_manager.py
@@ -325,7 +325,7 @@ class TableCoreManager(object):
                      rt_specific_tables.remove(vrf_table)
                  except KeyError:
                      LOG.debug('Did not find table listed as interested '
-                              'for its import RT: %s' % rt)
+                              'for its import RT: %s', rt)
                  if len(rt_specific_tables) == 0:
                      rts_with_no_table.add(rt)

diff --git a/ryu/services/protocols/bgp/info_base/base.py  
b/ryu/services/protocols/bgp/info_base/base.py
index 9269afb..1b4189a 100644
--- a/ryu/services/protocols/bgp/info_base/base.py
+++ b/ryu/services/protocols/bgp/info_base/base.py
@@ -519,7 +519,7 @@ class Destination(object):
          # delete these withdraws.
          if not self._known_path_list:
              LOG.debug('Found %s withdrawals for path(s) that did not get'
-                      ' installed.' % len(self._withdraw_list))
+                      ' installed.', len(self._withdraw_list))
              del(self._withdraw_list[:])
              return

@@ -541,13 +541,13 @@ class Destination(object):
              # We do no have any match for this withdraw.
              if not match:
                  LOG.debug('No matching path for withdraw found, may be  
path '
-                          'was not installed into table: %s' %
+                          'was not installed into table: %s',
                            withdraw)
          # If we have partial match.
          if len(matches) != len(self._withdraw_list):
              LOG.debug('Did not find match for some withdrawals. Number of '
-                      'matches(%s), number of withdrawals (%s)' %
-                      (len(matches), len(self._withdraw_list)))
+                      'matches(%s), number of withdrawals (%s)',
+                      len(matches), len(self._withdraw_list))

          # Clear matching paths and withdrawals.
          for match in matches:
@@ -577,7 +577,7 @@ class Destination(object):
              for old_path in old_paths:
                  known_paths.remove(old_path)
                  LOG.debug('Implicit withdrawal of old path, since we have'
-                          ' learned new path from same source: %s' %  
old_path)
+                          ' learned new path from same source: %s',  
old_path)

      def _compute_best_known_path(self):
          """Computes the best path among known paths.
diff --git a/ryu/services/protocols/bgp/info_base/vrf.py  
b/ryu/services/protocols/bgp/info_base/vrf.py
index ded43cc..57e8259 100644
--- a/ryu/services/protocols/bgp/info_base/vrf.py
+++ b/ryu/services/protocols/bgp/info_base/vrf.py
@@ -358,7 +358,7 @@ class VrfDest(Destination):
          # delete these withdraws.
          if not self._known_path_list:
              LOG.debug('Found %s withdrawals for path(s) that did not get'
-                      ' installed.' % len(self._withdraw_list))
+                      ' installed.', len(self._withdraw_list))
              del (self._withdraw_list[:])
              return

@@ -380,13 +380,13 @@ class VrfDest(Destination):
                  # We do no have any match for this withdraw.
              if not match:
                  LOG.debug('No matching path for withdraw found, may be  
path '
-                          'was not installed into table: %s' %
+                          'was not installed into table: %s',
                            withdraw)
              # If we have partial match.
          if len(matches) != len(self._withdraw_list):
              LOG.debug('Did not find match for some withdrawals. Number of '
-                      'matches(%s), number of withdrawals (%s)' %
-                      (len(matches), len(self._withdraw_list)))
+                      'matches(%s), number of withdrawals (%s)',
+                      len(matches), len(self._withdraw_list))

          # Clear matching paths and withdrawals.
          for match in matches:
@@ -416,7 +416,7 @@ class VrfDest(Destination):
              for old_path in old_paths:
                  known_paths.remove(old_path)
                  LOG.debug('Implicit withdrawal of old path, since we have'
-                          ' learned new path from same source: %s' %  
old_path)
+                          ' learned new path from same source: %s',  
old_path)

      def _validate_path(self, path):
          if not path or not hasattr(path, 'label_list'):
diff --git a/ryu/services/protocols/bgp/peer.py  
b/ryu/services/protocols/bgp/peer.py
index 1dd83b0..4a305da 100644
--- a/ryu/services/protocols/bgp/peer.py
+++ b/ryu/services/protocols/bgp/peer.py
@@ -781,7 +781,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
                  rr_req = BGPRouteRefresh(route_family.afi,  
route_family.safi)
                  self.enque_outgoing_msg(rr_req)
                  LOG.debug('Enqueued Route Refresh message to '
-                          'peer %s for rf: %s' % (self, route_family))
+                          'peer %s for rf: %s', self, route_family)

      def enque_end_of_rib(self, route_family):
          # MP_UNREACH_NLRI Attribute.
@@ -866,7 +866,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
                      if path.route_family == RF_IPv6_VPN:
                          next_hop = self._ipv4_mapped_ipv6(next_hop)
                      LOG.debug('using %s as a next_hop address instead'
-                              ' of path.nexthop %s' % (next_hop,  
path.nexthop))
+                              ' of path.nexthop %s', next_hop,  
path.nexthop)
                  else:
                      next_hop = path.nexthop

@@ -1065,8 +1065,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):

                  if bind_addr:
                      LOG.debug('%s trying to connect from'
-                              '%s to %s' % (self, bind_addr,
-                                            peer_address))
+                              '%s to %s', self, bind_addr, peer_address)
                  else:
                      LOG.debug('%s trying to connect to %s', self,  
peer_address)
                  tcp_conn_timeout = self._common_conf.tcp_conn_timeout
@@ -1079,9 +1078,10 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
                                               password=password)
                  except socket.error:
                      self.state.bgp_state = const.BGP_FSM_ACTIVE
-                    LOG.debug('Socket could not be created in time (%s  
secs),'
-                              ' reason %s' % (tcp_conn_timeout,
-                                              traceback.format_exc()))
+                    if LOG.isEnabledFor(logging.DEBUG):
+                        LOG.debug('Socket could not be created in time'
+                                  ' (%s secs), reason %s',  
tcp_conn_timeout,
+                                  traceback.format_exc())
                      LOG.info('Will try to reconnect to %s after %s  
secs: %s',
                               self._neigh_conf.ip_address,
                               self._common_conf.bgp_conn_retry_time,
@@ -1140,8 +1140,8 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              # If existing protocol is already established, we raise  
exception.
              if self.state.bgp_state != const.BGP_FSM_IDLE:
                  LOG.debug('Currently in %s state, hence will send  
collision'
-                          ' Notification to close this protocol.'
-                          % self.state.bgp_state)
+                          ' Notification to close this protocol.',
+                          self.state.bgp_state)
                  self._send_collision_err_and_stop(proto)
                  return

@@ -1150,8 +1150,8 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
                  ('Tried to bind second protocol that is not colliding  
with '
                   'first/bound protocol')
              LOG.debug('Currently have one protocol in %s state and '
-                      'another protocol in %s state' %
-                      (self._protocol.state, proto.state))
+                      'another protocol in %s state',
+                      self._protocol.state, proto.state)
              # Protocol that is already bound
              first_protocol = self._protocol
              assert ((first_protocol.is_reactive and not proto.is_reactive)  
or
@@ -1242,7 +1242,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
          if not (mp_reach_attr or mp_unreach_attr):
              if not self.is_mpbgp_cap_valid(RF_IPv4_UC):
                  LOG.error('Got UPDATE message with un-available'
-                          ' afi/safi %s' % RF_IPv4_UC)
+                          ' afi/safi %s', RF_IPv4_UC)
              nlri_list = update_msg.nlri
              if len(nlri_list) > 0:
                  # Check for missing well-known mandatory attributes.
@@ -1272,7 +1272,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              if not self.is_mpbgp_cap_valid(mp_unreach_attr.route_family):
                  LOG.error('Got UPDATE message with un-available afi/safi  
for'
                            ' MP_UNREACH path attribute (non-negotiated'
-                          ' afi/safi) %s' % mp_unreach_attr.route_family)
+                          ' afi/safi) %s', mp_unreach_attr.route_family)
                  # raise bgp.OptAttrError()

          if mp_reach_attr:
@@ -1281,7 +1281,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              if not self.is_mpbgp_cap_valid(mp_reach_attr.route_family):
                  LOG.error('Got UPDATE message with un-available afi/safi  
for'
                            ' MP_UNREACH path attribute (non-negotiated'
-                          ' afi/safi) %s' % mp_reach_attr.route_family)
+                          ' afi/safi) %s', mp_reach_attr.route_family)
                  # raise bgp.OptAttrError()

              # Check for missing well-known mandatory attributes.
@@ -1303,9 +1303,9 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              if (not mp_reach_attr.next_hop or
                      (mp_reach_attr.next_hop == self.host_bind_ip)):
                  LOG.error('Nexthop of received UPDATE msg. (%s) same as  
local'
-                          ' interface address %s.' %
-                          (mp_reach_attr.next_hop,
-                           self.host_bind_ip))
+                          ' interface address %s.',
+                          mp_reach_attr.next_hop,
+                          self.host_bind_ip)
                  return False

          return True
@@ -1378,7 +1378,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
          # Check if AS_PATH has loops.
          if aspath.has_local_as(self._common_conf.local_as):
              LOG.error('Update message AS_PATH has loops. Ignoring this'
-                      ' UPDATE. %s' % update_msg)
+                      ' UPDATE. %s', update_msg)
              return

          next_hop = update_msg.get_path_attr(BGP_ATTR_TYPE_NEXT_HOP).value
@@ -1504,7 +1504,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
          # Check if AS_PATH has loops.
          if aspath.has_local_as(self._common_conf.local_as):
              LOG.error('Update message AS_PATH has loops. Ignoring this'
-                      ' UPDATE. %s' % update_msg)
+                      ' UPDATE. %s', update_msg)
              return

          if msg_rf in (RF_IPv4_VPN, RF_IPv6_VPN):
@@ -1514,7 +1514,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              # Check if we have at-least one RT is of interest to us.
              if not ext_comm_attr:
                  LOG.info('Missing Extended Communities Attribute. '
-                         'Ignoring paths from this UPDATE: %s' %  
update_msg)
+                         'Ignoring paths from this UPDATE: %s', update_msg)
                  return

              msg_rts = ext_comm_attr.rt_list
@@ -1522,7 +1522,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              # extract any paths.
              if not msg_rts:
                  LOG.info('Received route with no RTs. Ignoring paths in  
this'
-                         ' UPDATE: %s' % update_msg)
+                         ' UPDATE: %s', update_msg)
                  return

              # If none of the RTs in the message are of interest, we do not
@@ -1531,8 +1531,8 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              if not interested_rts.intersection(msg_rts):
                  LOG.info('Received route with RT %s that is of no interest  
to'
                           ' any VRFs or Peers %s.'
-                         ' Ignoring paths from this UPDATE: %s' %
-                         (msg_rts, interested_rts, update_msg))
+                         ' Ignoring paths from this UPDATE: %s',
+                         msg_rts, interested_rts, update_msg)
                  return

          next_hop = mpreach_nlri_attr.next_hop
@@ -1746,7 +1746,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
          # Check if peer has asked for route-refresh for af that was  
advertised
          if not self._protocol.is_route_family_adv(rr_af):
              LOG.info('Peer asked for route - refresh for un - advertised '
-                     'address - family % s' % str(rr_af))
+                     'address - family %s', rr_af)
              return

          self._fire_route_refresh(rr_af)
@@ -1803,7 +1803,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
          # Start timer for sending initial updates
          self._rtc_eor_timer.start(const.RTC_EOR_DEFAULT_TIME, now=False)
          LOG.debug('Scheduled sending of initial Non-RTC UPDATEs after:'
-                  ' %s sec' % const.RTC_EOR_DEFAULT_TIME)
+                  ' %s sec', const.RTC_EOR_DEFAULT_TIME)

      def _unschedule_sending_init_updates(self):
          """Un-schedules sending of initial updates
@@ -1814,7 +1814,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              - False if timer was already stopped and nothing was done
          """
          LOG.debug('Un-scheduling sending of initial Non-RTC UPDATEs'
-                  ' (init. UPDATEs already sent: %s)' %
+                  ' (init. UPDATEs already sent: %s)',
                    self._sent_init_non_rtc_update)
          if self._rtc_eor_timer:
              self._rtc_eor_timer.stop()
@@ -1867,14 +1867,14 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
          # We do not send anything to peer who is not in established state.
          if not self.in_established():
              LOG.debug('Skipping sending path as peer is not in '
-                      'ESTABLISHED state %s' % path)
+                      'ESTABLISHED state %s', path)
              return

          # Check if this session is available for given paths afi/safi
          path_rf = path.route_family
          if not self.is_mpbgp_cap_valid(path_rf):
              LOG.debug('Skipping sending path as %s route family is not'
-                      ' available for this session' % path_rf)
+                      ' available for this session', path_rf)
              return

          # If RTC capability is available and path afi/saif is other than   
RT
@@ -1887,8 +1887,8 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
              # peer
              if rtfilter and not path.has_rts_in(rtfilter):
                  LOG.debug('Skipping sending path as rffilter %s and path '
-                          'rts %s have no RT in common' %
-                          (rtfilter, path.get_rts()))
+                          'rts %s have no RT in common',
+                          rtfilter, path.get_rts())
                  return

          # Transmit side loop detection: We check if leftmost AS matches
@@ -1947,7 +1947,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
                  # UPDATE to any peers
                  if comm_attr_na:
                      LOG.debug('Path has community attr. NO_ADVERTISE = %s'
-                              '. Hence not advertising to peer' %
+                              '. Hence not advertising to peer',
                                comm_attr_na)
                      return

@@ -1963,7 +1963,7 @@ class Peer(Source, Sink, NeighborConfListener,  
Activity):
                  if ((comm_attr_nes or comm_attr_ne) and
                          (self.remote_as != self._core_service.asn)):
                      LOG.debug('Skipping sending UPDATE to peer: %s as per '
-                              'community attribute configuration' % self)
+                              'community attribute configuration', self)
                      return

              # Construct OutgoingRoute specific for this peer and put it in
diff --git a/ryu/services/protocols/bgp/speaker.py  
b/ryu/services/protocols/bgp/speaker.py
index 1d8e491..461b133 100644
--- a/ryu/services/protocols/bgp/speaker.py
+++ b/ryu/services/protocols/bgp/speaker.py
@@ -477,7 +477,7 @@ class BgpProtocol(Protocol, Activity):
                  self._signal_bus.bgp_notification_received(self._peer, msg)
              # If we receive notification message
              LOG.error('Received notification message, hence closing '
-                      'connection %s' % msg)
+                      'connection %s', msg)
              self._socket.close()
              return

@@ -503,7 +503,7 @@ class BgpProtocol(Protocol, Activity):
          neg_timer = min(self._holdtime, peer_holdtime)
          if neg_timer < self._holdtime:
              LOG.info('Negotiated hold time (%s) is lower then '
-                     'configured/default (%s).' % (neg_timer,  
self._holdtime))
+                     'configured/default (%s).', neg_timer, self._holdtime)
          # We use negotiated timer value.
          self._holdtime = neg_timer
          self._keepalive = self._create_timer('Keepalive Timer',
@@ -514,7 +514,7 @@ class BgpProtocol(Protocol, Activity):
          self._expiry = self._create_timer('Holdtime Timer', self._expired)
          self._expiry.start(self._holdtime, now=False)
          LOG.debug('Started keep-alive and expire timer for negotiated hold'
-                  'time %s' % self._holdtime)
+                  'time %s', self._holdtime)

      def _expired(self):
          """Hold timer expired event handler.
-- 
2.2.0.rc0.207.ga3a616c


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to