mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ovsdb: Fix mutation of newly inserted rows from Python IDL.
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 <abiswas@us.ibm.com> Suggested-by: Richard Theis <rtheis@us.ibm.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
committed by
Ben Pfaff
parent
58026109d5
commit
b3220c677a
2
AUTHORS
2
AUTHORS
@@ -12,6 +12,7 @@ Alfredo Finelli alf@computationes.de
|
||||
Alin Serdean aserdean@cloudbasesolutions.com
|
||||
Ambika Arora ambika.arora@tcs.com
|
||||
Amit Bose bose@noironetworks.com
|
||||
Amitabha Biswas azbiswas@gmail.com
|
||||
Andrew Evans aevans@nicira.com
|
||||
Andrew Kampjes a.kampjes@gmail.com
|
||||
Andrew Lambeth wal@nicira.com
|
||||
@@ -416,6 +417,7 @@ Ralf Heiringhoff ralf@frosty-geek.net
|
||||
Ram Jothikumar rjothikumar@nicira.com
|
||||
Ramana Reddy gtvrreddy@gmail.com
|
||||
Ray Li rayli1107@gmail.com
|
||||
Richard Theis rtheis@us.ibm.com
|
||||
RishiRaj Maulick rishi.raj2509@gmail.com
|
||||
Rob Sherwood rob.sherwood@bigswitch.com
|
||||
Robert Strickler anomalyst@gmail.com
|
||||
|
@@ -1271,6 +1271,12 @@ class Transaction(object):
|
||||
addop = False
|
||||
op = {"table": row._table.name}
|
||||
op["op"] = "mutate"
|
||||
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():
|
||||
|
@@ -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],
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user