diff --git a/bin/confetty b/bin/confetty index bb666d4e..6ef5f1f5 100755 --- a/bin/confetty +++ b/bin/confetty @@ -37,6 +37,7 @@ import sys import termios import tty +exitcode = 0 consoleonly = False target = "/" path = os.path.dirname(os.path.realpath(__file__)) @@ -156,9 +157,11 @@ def send_request(operation, path, server): result = tlvdata.recv_tlvdata(server) def do_command(command, server): + global exitcode global target global currconsole global currchildren + exitcode = 0 command = command.lower() argv = parse_command(command) if len(argv) == 0: @@ -166,14 +169,16 @@ def do_command(command, server): if argv[0] == "exit": server.close() sys.exit(0) - if argv[0] == "cd": + elif argv[0] == "cd": otarget = target target = fullpath_target(argv[1], forcepath=True) for res in send_request('retrieve', target, server): + if 'errorcode' in res: + exitcode = res['errorcode'] if 'error' in res: - print target + ': ' + res['error'] + sys.stderr.write(target + ': ' + res['error'] + '\n') target = otarget - if argv[0] in ('cat', 'show', 'ls', 'dir'): + elif argv[0] in ('cat', 'show', 'ls', 'dir'): if len(argv) > 1: targpath = fullpath_target(argv[1]) else: @@ -196,17 +201,21 @@ def do_command(command, server): print "%s=********" % key else: print "%s=" % key - if argv[0] == 'start': + elif argv[0] == 'start': targpath = fullpath_target(argv[1]) currconsole = targpath tlvdata.send_tlvdata(server, {'operation': 'start', 'path': targpath}) status = tlvdata.recv_tlvdata(server) if 'error' in status: - print 'Error: ' + status['error'] + if 'errorcode' in status: + exitcode = status['errorcode'] + sys.stderr.write('Error: ' + status['error'] + '\n') return print '[console session started]' startconsole() return + else: + sys.stderr.write("%s: command not found...\n" % argv[0]) def fullpath_target(path, forcepath=False): diff --git a/confluent/config/configmanager.py b/confluent/config/configmanager.py index 0af26b0e..2375b056 100644 --- a/confluent/config/configmanager.py +++ b/confluent/config/configmanager.py @@ -643,6 +643,7 @@ class ConfigManager(object): # TODO(jbjohnso): multi mgr support, here if we have peers, # pickle the arguments and fire them off in eventlet # flows to peers, all should have the same result + exprmgr = None for node in attribmap.iterkeys(): if node not in self._cfgstore['nodes']: self._cfgstore['nodes'][node] = {} diff --git a/confluent/messages.py b/confluent/messages.py index 827dd766..3a533587 100644 --- a/confluent/messages.py +++ b/confluent/messages.py @@ -138,7 +138,7 @@ def get_input_message(path, operation, inputdata, nodes=None): if path[0] == 'power' and path[1] == 'state' and operation != 'retrieve': return InputPowerMessage(path, nodes, inputdata) elif path[0] == 'attributes' and operation != 'retrieve': - return InputAttributes(path, nodes, inputdata) + return InputAttributes(path, inputdata, nodes) elif path == ['boot', 'device'] and operation != 'retrieve': return InputBootDevice(path, nodes, inputdata) elif inputdata: @@ -147,7 +147,10 @@ def get_input_message(path, operation, inputdata, nodes=None): class InputAttributes(ConfluentMessage): - def __init__(self, path, nodes, inputdata): + def __init__(self, path, inputdata, nodes=None): + print "DEBUG: making input attributes " + print repr(nodes) + print repr(inputdata) self.nodeattribs = {} nestedmode = False if not inputdata: diff --git a/confluent/pluginapi.py b/confluent/pluginapi.py index 92e2385b..c3e12dba 100644 --- a/confluent/pluginapi.py +++ b/confluent/pluginapi.py @@ -163,7 +163,7 @@ def create_group(inputdata, configmanager): del inputdata['name'] attribmap = {groupname: inputdata} except KeyError: - raise exc.InvalidArgumenTException() + raise exc.InvalidArgumentException() configmanager.set_group_attributes(attribmap) @@ -202,7 +202,8 @@ def handle_path(path, operation, configmanager, inputdata=None): group = pathcomponents[1] except IndexError: if operation == "create": - create_group(inputdata, configmanager) + inputdata = msg.InputAttributes(pathcomponents, inputdata) + create_group(inputdata.attribs, configmanager) return iterate_collections(configmanager.get_groups()) if iscollection: if operation == "delete": @@ -231,7 +232,8 @@ def handle_path(path, operation, configmanager, inputdata=None): if operation == "delete": raise exc.InvalidArgumentException() if operation == "create": - create_node(inputdata, configmanager) + inputdata = msg.InputAttributes(pathcomponents, inputdata) + create_node(inputdata.attribs, configmanager) return iterate_collections(configmanager.get_nodes()) if iscollection: if operation == "delete":