This patch fixes the scenario, where the mutate operation on a row
is sent in the same transaction as row insert operation. It was
obvserved that this mutate operation was not getting committed
to the OVSDB.

To get around the above problem the "where" condition in an
mutate operation is modified to use the named-uuid to identify
a row created in the current transaction.

Signed-off-by: Amitabha Biswas <abis...@us.ibm.com>
Suggested-by: Richard Theis <rth...@us.ibm.com>
---
 python/ovs/db/idl.py |  8 +++++++-
 tests/ovsdb-idl.at   | 14 ++++++++++----
 tests/test-ovsdb.py  |  6 ++++++
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/python/ovs/db/idl.py b/python/ovs/db/idl.py
index 1e5c20f..187e902 100644
--- a/python/ovs/db/idl.py
+++ b/python/ovs/db/idl.py
@@ -1271,7 +1271,13 @@ class Transaction(object):
                 addop = False
                 op = {"table": row._table.name}
                 op["op"] = "mutate"
-                op["where"] = _where_uuid_equals(row.uuid)
+                if row._data is None:
+                    # New row
+                    op["where"] = self._substitute_uuids(
+                        _where_uuid_equals(row.uuid))
+                else:
+                    # Existing row
+                    op["where"] = _where_uuid_equals(row.uuid)
                 op["mutations"] = []
                 if '_removes' in row._mutations.keys():
                     for col, dat in six.iteritems(row._mutations['_removes']):
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index 2804419..d633dbb 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -1160,10 +1160,13 @@ OVSDB_CHECK_IDL_PARTIAL_UPDATE_SET_COLUMN([set, simple3 
idl-partial-update-set-c
 ]])
 
 OVSDB_CHECK_IDL_PY([partial-set idl],
-[['["idltest", {"op":"insert", "table":"simple3",
-                "row":{"name":"mySet1","uset":["set", [[ "uuid", 
"0005b872-f9e5-43be-ae02-3184b9680e75" ], [ "uuid", 
"000d2f6a-76af-412f-b59d-e7bcd3e84eff" ]]]} }, {"op":"insert", 
"table":"simple4", "row":{"name":"seed"}}]']
+[['["idltest", {"op":"insert", "table":"simple3", "uuid-name":"newrow",
+                    "row":{"name":"mySet1","uset":["set", [[ "uuid", 
"0005b872-f9e5-43be-ae02-3184b9680e75" ]]]} },
+               {"op":"insert", "table":"simple4", "row":{"name":"seed"}},
+               {"op":"mutate", "table":"simple3", "where":[["_uuid", "==", 
["named-uuid", "newrow"]]],
+                    "mutations": [["uset", "insert", ["set", [["uuid", 
"000d2f6a-76af-412f-b59d-e7bcd3e84eff"]]]]]}]']
 ],
-  ['partialrenamesetadd' 'partialduplicateadd' 'partialsetdel' 'partialsetref' 
'partialsetoverrideops'],
+  ['partialrenamesetadd' 'partialduplicateadd' 'partialsetdel' 'partialsetref' 
'partialsetoverrideops' 'partialsetmutatenew'],
 [[000: name=mySet1 uset=[<0> <1>]
 001: commit, status=success
 002: name=String2 uset=[<0> <1> <2>]
@@ -1175,7 +1178,10 @@ OVSDB_CHECK_IDL_PY([partial-set idl],
 008: name=String2 uset=[<0> <1> <3>]
 009: commit, status=success
 010: name=String2 uset=[<3>]
-011: done
+011: commit, status=success
+012: name=String2 uset=[<3>]
+012: name=String3 uset=[<4>]
+013: done
 ]])
 
 m4_define([OVSDB_CHECK_IDL_NOTIFY_PY],
diff --git a/tests/test-ovsdb.py b/tests/test-ovsdb.py
index e4e3395..e1cfdad 100644
--- a/tests/test-ovsdb.py
+++ b/tests/test-ovsdb.py
@@ -470,6 +470,12 @@ def idl_set(idl, commands, step):
                          uuid.UUID("0026b3ba-571b-4729-8227-d860a5210ab8"))
             row.__setattr__('uset',
                 [uuid.UUID("0026b3ba-571b-4729-8227-d860a5210ab8")])
+        elif name == 'partialsetmutatenew':
+            new_row41 = txn.insert(idl.tables["simple4"])
+            new_row41.__setattr__('name', 'new_row41')
+            new_row3 = txn.insert(idl.tables["simple3"])
+            setattr(new_row3, 'name', 'String3')
+            new_row3.addvalue('uset', new_row41.uuid)
         else:
             sys.stderr.write("unknown command %s\n" % name)
             sys.exit(1)
-- 
2.7.4 (Apple Git-66)

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to