Signed-off-by: IWASE Yusuke <[email protected]>
---
 ryu/services/protocols/bgp/api/base.py             |  2 +-
 ryu/services/protocols/bgp/base.py                 |  9 ++----
 .../protocols/bgp/core_managers/__init__.py        |  8 ++---
 ryu/services/protocols/bgp/info_base/base.py       |  4 +++
 .../protocols/bgp/operator/commands/show/rib.py    |  2 +-
 .../commands/show/route_formatter_mixin.py         |  7 +----
 .../protocols/bgp/operator/commands/show/vrf.py    |  4 ++-
 ryu/services/protocols/bgp/utils/circlist.py       |  4 ++-
 ryu/services/protocols/bgp/utils/dictconfig.py     |  1 +
 ryu/services/protocols/bgp/utils/internable.py     | 35 ++++++++++++----------
 10 files changed, 39 insertions(+), 37 deletions(-)

diff --git a/ryu/services/protocols/bgp/api/base.py 
b/ryu/services/protocols/bgp/api/base.py
index 489e318..d0c0d79 100644
--- a/ryu/services/protocols/bgp/api/base.py
+++ b/ryu/services/protocols/bgp/api/base.py
@@ -208,7 +208,7 @@ def call(symbol, **kwargs):
     LOG.info("API method %s called with args: %s", symbol, str(kwargs))
 
     # TODO(PH, JK) improve the way api function modules are loaded
-    import all  # noqa
+    from . import all  # noqa
     if not is_call_registered(symbol):
         message = 'Did not find any method registered by symbol %s' % symbol
         raise MethodNotFound(message)
diff --git a/ryu/services/protocols/bgp/base.py 
b/ryu/services/protocols/bgp/base.py
index a8ef621..2086953 100644
--- a/ryu/services/protocols/bgp/base.py
+++ b/ryu/services/protocols/bgp/base.py
@@ -16,6 +16,7 @@
   Defines some base class related to managing green threads.
 """
 import abc
+from collections import OrderedDict
 import logging
 import socket
 import time
@@ -38,12 +39,6 @@ from ryu.services.protocols.bgp.utils.evtlet import 
LoopingCall
 # Logger instance for this module.
 LOG = logging.getLogger('bgpspeaker.base')
 
-
-try:
-    from collections import OrderedDict
-except ImportError:
-    from ordereddict import OrderedDict
-
 # Pointer to active/available OrderedDict.
 OrderedDict = OrderedDict
 
@@ -456,7 +451,7 @@ class Sink(object):
         self.index = Sink.next_index()
 
         # Event used to signal enqueing.
-        from utils.evtlet import EventletIOFactory
+        from .utils.evtlet import EventletIOFactory
         self.outgoing_msg_event = EventletIOFactory.create_custom_event()
 
         self.messages_queued = 0
diff --git a/ryu/services/protocols/bgp/core_managers/__init__.py 
b/ryu/services/protocols/bgp/core_managers/__init__.py
index 883de2d..4ed6e64 100644
--- a/ryu/services/protocols/bgp/core_managers/__init__.py
+++ b/ryu/services/protocols/bgp/core_managers/__init__.py
@@ -14,9 +14,9 @@
 # limitations under the License.
 
 
-from configuration_manager import ConfigurationManager
-from import_map_manager import ImportMapManager
-from peer_manager import PeerManager
-from table_manager import TableCoreManager
+from .configuration_manager import ConfigurationManager
+from .import_map_manager import ImportMapManager
+from .peer_manager import PeerManager
+from .table_manager import TableCoreManager
 __all__ = ['ImportMapManager', 'TableCoreManager', 'PeerManager',
            'ConfigurationManager']
diff --git a/ryu/services/protocols/bgp/info_base/base.py 
b/ryu/services/protocols/bgp/info_base/base.py
index 7ec54ce..da1a480 100644
--- a/ryu/services/protocols/bgp/info_base/base.py
+++ b/ryu/services/protocols/bgp/info_base/base.py
@@ -226,6 +226,10 @@ class NonVrfPathProcessingMixin(object):
     because they are processed at VRF level, so different logic applies.
     """
 
+    def __init__(self):
+        self._core_service = None  # not assigned yet
+        self._known_path_list = []
+
     def _best_path_lost(self):
         self._best_path = None
 
diff --git a/ryu/services/protocols/bgp/operator/commands/show/rib.py 
b/ryu/services/protocols/bgp/operator/commands/show/rib.py
index 440234c..b838aa3 100644
--- a/ryu/services/protocols/bgp/operator/commands/show/rib.py
+++ b/ryu/services/protocols/bgp/operator/commands/show/rib.py
@@ -1,4 +1,4 @@
-from route_formatter_mixin import RouteFormatterMixin
+from .route_formatter_mixin import RouteFormatterMixin
 
 from ryu.services.protocols.bgp.operator.command import Command
 from ryu.services.protocols.bgp.operator.command import CommandsResponse
diff --git 
a/ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py 
b/ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py
index c20c97c..e29c7c7 100644
--- a/ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py
+++ b/ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py
@@ -17,12 +17,7 @@ class RouteFormatterMixin(object):
 
     @classmethod
     def _format_family(cls, dest_list):
-        if six.PY3:
-            import io
-            msg = io.StringIO()
-        else:
-            import StringIO
-            msg = StringIO.StringIO()
+        msg = six.StringIO()
 
         def _append_path_info(buff, path, is_best, show_prefix):
             aspath = path.get('aspath')
diff --git a/ryu/services/protocols/bgp/operator/commands/show/vrf.py 
b/ryu/services/protocols/bgp/operator/commands/show/vrf.py
index b78a7cf..81eca99 100644
--- a/ryu/services/protocols/bgp/operator/commands/show/vrf.py
+++ b/ryu/services/protocols/bgp/operator/commands/show/vrf.py
@@ -9,7 +9,7 @@ from ryu.services.protocols.bgp.operator.commands.responses 
import \
     WrongParamResp
 from ryu.services.protocols.bgp.operator.views.conf import ConfDetailView
 from ryu.services.protocols.bgp.operator.views.conf import ConfDictView
-from route_formatter_mixin import RouteFormatterMixin
+from .route_formatter_mixin import RouteFormatterMixin
 
 LOG = logging.getLogger('bgpspeaker.operator.commands.show.vrf')
 
@@ -77,6 +77,8 @@ class Routes(Command, RouteFormatterMixin):
 
 
 class CountRoutesMixin(object):
+    api = None  # not assigned yet
+
     def _count_routes(self, vrf_name, vrf_rf):
         return len(self.api.get_single_vrf_routes(vrf_name, vrf_rf))
 
diff --git a/ryu/services/protocols/bgp/utils/circlist.py 
b/ryu/services/protocols/bgp/utils/circlist.py
index d22ec21..4a04f4f 100644
--- a/ryu/services/protocols/bgp/utils/circlist.py
+++ b/ryu/services/protocols/bgp/utils/circlist.py
@@ -13,7 +13,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from six.moves import intern
+import six
+if six.PY3:
+    from sys import intern
 
 
 class CircularListType(object):
diff --git a/ryu/services/protocols/bgp/utils/dictconfig.py 
b/ryu/services/protocols/bgp/utils/dictconfig.py
index e21e8ee..e8746e1 100644
--- a/ryu/services/protocols/bgp/utils/dictconfig.py
+++ b/ryu/services/protocols/bgp/utils/dictconfig.py
@@ -15,6 +15,7 @@
 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 # Source: 
https://bitbucket.org/vinay.sajip/dictconfig/raw/53b3c32dea4694cd3fb2f14b3159d66d3da10bc0/src/dictconfig.py
 # flake8: noqa
+import logging
 import logging.handlers
 import re
 import sys
diff --git a/ryu/services/protocols/bgp/utils/internable.py 
b/ryu/services/protocols/bgp/utils/internable.py
index 9f5e8d9..2029bf0 100644
--- a/ryu/services/protocols/bgp/utils/internable.py
+++ b/ryu/services/protocols/bgp/utils/internable.py
@@ -14,9 +14,6 @@
 # limitations under the License.
 
 import weakref
-from six.moves import intern
-
-dict_name = intern('_internable_dict')
 
 
 #
@@ -40,6 +37,12 @@ class Internable(object):
     Internable to work.
     """
 
+    _internable_stats = None
+    _internable_dict = None
+
+    def __init__(self):
+        self._interned = False
+
     class Stats(object):
 
         def __init__(self):
@@ -55,17 +58,17 @@ class Internable(object):
             return str(self.d)
 
     @classmethod
-    def _internable_init(kls):
+    def _internable_init(cls):
         # Objects to be interned are held as keys in a dictionary that
         # only holds weak references to keys. As a result, when the
         # last reference to an interned object goes away, the object
         # will be removed from the dictionary.
-        kls._internable_dict = weakref.WeakKeyDictionary()
-        kls._internable_stats = Internable.Stats()
+        cls._internable_dict = weakref.WeakKeyDictionary()
+        cls._internable_stats = Internable.Stats()
 
     @classmethod
-    def intern_stats(kls):
-        return kls._internable_stats
+    def intern_stats(cls):
+        return cls._internable_stats
 
     def intern(self):
         """Returns either itself or a canonical copy of itself."""
@@ -78,26 +81,26 @@ class Internable(object):
         # Got to find or create an interned object identical to this
         # one. Auto-initialize the class if need be.
         #
-        kls = self.__class__
+        cls = self.__class__
 
-        if not hasattr(kls, dict_name):
-            kls._internable_init()
+        if not cls._internable_dict:
+            cls._internable_init()
 
-        obj = kls._internable_dict.get(self)
+        obj = cls._internable_dict.get(self)
         if (obj):
             # Found an interned copy.
-            kls._internable_stats.incr('found')
+            cls._internable_stats.incr('found')
             return obj
 
         # Create an interned copy. Take care to only keep a weak
         # reference to the object itself.
         def object_collected(obj):
-            kls._internable_stats.incr('collected')
+            cls._internable_stats.incr('collected')
             # print("Object %s garbage collected" % obj)
             pass
 
         ref = weakref.ref(self, object_collected)
-        kls._internable_dict[self] = ref
+        cls._internable_dict[self] = ref
         self._interned = True
-        kls._internable_stats.incr('inserted')
+        cls._internable_stats.incr('inserted')
         return self
-- 
2.7.4


------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are 
consuming the most bandwidth. Provides multi-vendor support for NetFlow, 
J-Flow, sFlow and other flows. Make informed decisions using capacity 
planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to