jsonrpc.py: Don't swallow errors in transact_block().
authorEthan Jackson <ethan@nicira.com>
Fri, 17 Feb 2012 04:26:35 +0000 (20:26 -0800)
committerEthan Jackson <ethan@nicira.com>
Fri, 2 Mar 2012 21:30:25 +0000 (13:30 -0800)
If a server returned an error in response to a request,
transact_block() would ignore it.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
python/ovs/jsonrpc.py
tests/test-ovsdb.py

index 25b0229183c19adae430fae364362c0541b45bce..1c3f099c5e1620b6bdf9f0ab9578b1bf90470830 100644 (file)
@@ -301,7 +301,10 @@ class Connection(object):
         reply = None
         while not error:
             error, reply = self.recv_block()
-            if reply and reply.type == Message.T_REPLY and reply.id == id_:
+            if (reply
+                and (reply.type == Message.T_REPLY
+                     or reply.type == Message.T_ERROR)
+                and reply.id == id_):
                 break
         return error, reply
 
index df29fdb0503f5b2bff2900728e2d9ce9498e1e49..5f3cb995457f2a5ddfed89bf675143f8e79600cd 100644 (file)
@@ -375,6 +375,11 @@ def do_idl(schema_file, remote, *commands):
                 sys.stderr.write("jsonrpc transaction failed: %s"
                                  % os.strerror(error))
                 sys.exit(1)
+            elif reply.error is not None:
+                sys.stderr.write("jsonrpc transaction failed: %s"
+                                 % reply.error)
+                sys.exit(1)
+
             sys.stdout.write("%03d: " % step)
             sys.stdout.flush()
             step += 1