summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-11-02 11:26:29 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-11-02 11:18:03 +0900
commit5bde6ae440c6aa67dafe02b5ad1cd2d933ee4350 (patch)
tree8369b0de868acd1520d2d24fc85f747342a94565
parenteda4940eb86f874f7b218b75f2e3a8c11e62c9ae (diff)
flags: Inject __class__ attribute to LooseVersion
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.yusuke0@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/flags.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/ryu/flags.py b/ryu/flags.py
index b63b9b5e..400df86f 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,