Currently, ryu-manager uses distutils.version.LooseVersion for
"--zapi-frr-version" to parse the given version sting.
With custom type class for oslo_config.cfg.Opt, oslo_config might access
__class__ attribute for equal comparison.
But in case on Python 2, LooseVersion does not have __class__ attribute
and it causes AttributeError. (This error is not always reproduced)

This patch injects required attribute into LooseVersion and avoids this
problem.

Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com>
---
 ryu/flags.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ryu/flags.py b/ryu/flags.py
index b63b9b5..400df86 100644
--- a/ryu/flags.py
+++ b/ryu/flags.py
@@ -86,6 +86,13 @@ DEFAULT_ZSERV_ROUTER_ID = '1.1.1.1'
 # should be None.
 DEFAULT_ZSERV_FRR_VERSION = '0.0'
 
+# Hack: In oslo_config.cfg.Opt, ConfigType might access __class__ attribute
+# for equal comparison, but on Python 2, LooseVersion does not have __class__
+# attribute and it causes AttributeError. So here inject __class__ attribute
+# into LooseVersion class.
+if not hasattr(LooseVersion, '__class__'):
+    LooseVersion.__class__ = LooseVersion
+
 CONF.register_cli_opts([
     cfg.StrOpt(
         'server-host', default=DEFAULT_ZSERV_HOST,
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to