From 5bde6ae440c6aa67dafe02b5ad1cd2d933ee4350 Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Thu, 2 Nov 2017 11:26:29 +0900 Subject: 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 Signed-off-by: FUJITA Tomonori --- ryu/flags.py | 7 +++++++ 1 file changed, 7 insertions(+) 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, -- cgit v1.2.3