From 29794985f133f6f468e43992e17a6b13d6cb5a0f Mon Sep 17 00:00:00 2001 From: Eric K Date: Thu, 5 Apr 2018 17:55:19 -0700 Subject: [PATCH] update cfgvalidator for oslo.config 6.0.1 New oslo.config version changed signature of a method cfgvalidator relies on. Updated accordingly to work for both new and old oslo.config. Closes-Bug: 1761258 Change-Id: Icd2e489eb73754fee41d9d4324be6802caae7ec4 --- congress/cfg_validator/parsing.py | 17 ++++++++++++++++- congress/datasources/cfgvalidator_driver.py | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/congress/cfg_validator/parsing.py b/congress/cfg_validator/parsing.py index 99ad2f03c..75241c56a 100644 --- a/congress/cfg_validator/parsing.py +++ b/congress/cfg_validator/parsing.py @@ -15,6 +15,7 @@ # """Unmarshaling of options sent by the agent.""" +import inspect import sys from oslo_config import cfg @@ -195,7 +196,21 @@ def add_parsed_conf(conf, normalized): if conf: # pylint: disable=protected-access conf._namespace = cfg._Namespace(conf) - conf._namespace._add_parsed_config_file(None, normalized[0]) + + # oslo.config version 6.0.1 added extra arg to _add_parsed_config_file + # we determine the number of args required to use appropriately + if six.PY2: + _add_parsed_config_file_args_len = len(inspect.getargspec( + conf._namespace._add_parsed_config_file).args) - 1 + # - 1 to not count the first param self + else: + _add_parsed_config_file_args_len = len(inspect.signature( + conf._namespace._add_parsed_config_file).parameters) + if _add_parsed_config_file_args_len == 3: # oslo.config>=6.0.1 + conf._namespace._add_parsed_config_file( + '', [], normalized[0]) + else: + conf._namespace._add_parsed_config_file([], normalized[0]) def parse_config_file(namespaces, path): diff --git a/congress/datasources/cfgvalidator_driver.py b/congress/datasources/cfgvalidator_driver.py index 320f7e798..8eea9cb33 100644 --- a/congress/datasources/cfgvalidator_driver.py +++ b/congress/datasources/cfgvalidator_driver.py @@ -488,6 +488,8 @@ class ValidatorDriver(datasource_driver.PollingDataSourceDriver): try: value = option._get_from_namespace(cfg_ns, group_name) + if hasattr(cfg, 'LocationInfo'): + value = value[0] except KeyError: # No value parsed for this option return