2
0
mirror of https://github.com/xcat2/confluent.git synced 2025-01-27 19:37:57 +00:00

Fix confetty interactive behavior after set

After set, confetty client would fail to follow protocol and
end up leaving followup commands in an off by one state.  One
TODO out of this is to refactor send_request into a library function
This commit is contained in:
Jarrod Johnson 2014-02-22 20:22:23 -05:00
parent 387523f46b
commit 11138aa3de

View File

@ -149,8 +149,11 @@ def parse_command(command):
currchildren = None
def send_request(operation, path, server):
tlvdata.send_tlvdata(server, {'operation': operation, 'path': path})
def send_request(operation, path, server, parameters=None):
payload = {'operation': operation, 'path': path}
if parameters is not None:
payload['parameters'] = parameters
tlvdata.send_tlvdata(server, payload)
result = tlvdata.recv_tlvdata(server)
while '_requestdone' not in result:
yield result
@ -249,7 +252,12 @@ def setvalues(attribs):
value = attrib[attrib.index("=") + 1:]
keydata[key] = value
targpath = fullpath_target(resource)
tlvdata.send_tlvdata(server, {'operation': 'update', 'path': targpath, 'parameters': keydata})
for res in send_request('update', targpath, server, keydata):
if 'error' in res:
if 'errorcode' in res:
exitcode = res['errorcode']
sys.stderr.write('Error: ' + res['error'] + '\n')
return