diff --git a/bin/confetty b/bin/confetty index 8abaf782..44ca87ff 100755 --- a/bin/confetty +++ b/bin/confetty @@ -166,10 +166,10 @@ def do_command(command, server): argv = parse_command(command) if len(argv) == 0: return - if argv[0] == "exit": + if argv[0] == 'exit': server.close() sys.exit(0) - elif argv[0] == "cd": + elif argv[0] == 'cd': otarget = target if len(argv) > 1: target = fullpath_target(argv[1], forcepath=True) @@ -216,7 +216,6 @@ def do_command(command, server): notestr = '(' + ', '.join(notes) + ')' output = '{0:<40} {1:>39}'.format(attrstr, notestr) print output - elif argv[0] == 'start': targpath = fullpath_target(argv[1]) currconsole = targpath @@ -230,9 +229,29 @@ def do_command(command, server): print '[console session started]' startconsole() return + elif argv[0] == 'set': + setvalues(argv[1:]) else: sys.stderr.write("%s: command not found...\n" % argv[0]) +def setvalues(attribs): + if '=' in attribs[0]: # going straight to attribute + resource = attribs[0][:attribs[0].index("=")] + else: # an actual resource + resource = attribs[0] + attribs = attribs[1:] + keydata = {} + for attrib in attribs: + if '=' not in attrib: + sys.stderr.write("Invalid syntax %s" % attrib) + return + key = attrib[:attrib.index("=")] + value = attrib[attrib.index("=") + 1:] + keydata[key] = value + targpath = fullpath_target(resource) + tlvdata.send_tlvdata(server, {'operation': 'update', 'path': targpath, 'parameters': keydata}) + + def fullpath_target(path, forcepath=False): global target diff --git a/confluent/config/configmanager.py b/confluent/config/configmanager.py index 2375b056..df4f1007 100644 --- a/confluent/config/configmanager.py +++ b/confluent/config/configmanager.py @@ -441,7 +441,7 @@ class ConfigManager(object): if 'nodes' not in self._cfgstore: return None retdict = {} - if isinstance(nodelist,str): + if isinstance(nodelist,str) or isinstance(nodelist, unicode): nodelist = [nodelist] for node in nodelist: if node not in self._cfgstore['nodes']: @@ -575,7 +575,8 @@ class ConfigManager(object): if not isinstance(attribmap[group][attr], list): raise ValueError newdict = set(attribmap[group][attr]) - elif (isinstance(attribmap[group][attr], str)): + elif (isinstance(attribmap[group][attr], str) or + isinstance(attribmap[group][attr], unicode)): newdict = { 'value': attribmap[group][attr] } else: newdict = attribmap[group][attr] @@ -655,7 +656,8 @@ class ConfigManager(object): not isinstance(attribmap[node][attrname],allattributes.node[attrname]['type']))): raise ValueError newdict = {} - if (isinstance(attribmap[node][attrname], str)): + if (isinstance(attribmap[node][attrname], str) or + isinstance(attribmap[node][attrname], unicode)): newdict = {'value': attribmap[node][attrname] } else: newdict = attribmap[node][attrname]