From ca27385eaa869ecf9f83b8a7be1166abf4e88b4c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 27 Feb 2018 14:51:37 -0500 Subject: [PATCH] Fix confluentdbutil restore with typed attributes Typed attributes would fail the check. Additionally, the error itself was buggy, so fix that while we are at it. --- confluent_server/confluent/config/configmanager.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluent/config/configmanager.py index d2ef9236..7bad6802 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -255,6 +255,11 @@ def attribute_is_invalid(attrname, attrval): return True if 'type' in allattributes.node[attrname]: if not isinstance(attrval, allattributes.node[attrname]['type']): + # it is valid if it is {'value': actualvalue} + if (isinstance(attrval, dict) and 'value' in attrval and + isinstance(attrval['value'], + allattributes.node[attrname]['type'])): + return False # provide type checking for attributes with a specific type return True return False @@ -1047,7 +1052,7 @@ class ConfigManager(object): if attr not in ('nodes', 'noderange'): attrval = fixup_attribute(attr, attribmap[group][attr]) if attribute_is_invalid(attr, attrval): - errstr = "{0} attribute is invalid".format(attrname) + errstr = "{0} attribute is invalid".format(attr) raise ValueError(errstr) attribmap[group][attr] = attrval if attr == 'nodes':