Accept a Row as a result in AddCommand
Make AddCommand a little more lenient and accept Row/RowView objs as results. Conflicts: ovsdbapp/backend/ovs_idl/command.py Change-Id: I17c24fd88adecbea09c71741c0105df1d0240e66 Related-Bug: 1871104 (cherry picked from commit0338c0bb5c
) (cherry picked from commitfd0629f140
)
This commit is contained in:
parent
1cb33fa2d0
commit
1e538a2d71
|
@ -15,6 +15,7 @@
|
||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import ovs.db.idl
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from ovsdbapp import api
|
from ovsdbapp import api
|
||||||
|
@ -75,8 +76,17 @@ class AddCommand(BaseCommand):
|
||||||
def post_commit(self, txn):
|
def post_commit(self, txn):
|
||||||
# If get_insert_uuid fails, self.result was not a result of a
|
# If get_insert_uuid fails, self.result was not a result of a
|
||||||
# recent insert. Most likely we are post_commit after a lookup()
|
# recent insert. Most likely we are post_commit after a lookup()
|
||||||
real_uuid = txn.get_insert_uuid(self.result) or self.result
|
if isinstance(self.result, rowview.RowView):
|
||||||
row = self.api.tables[self.table_name].rows[real_uuid]
|
return
|
||||||
|
if isinstance(self.result, ovs.db.idl.Row):
|
||||||
|
row = self.result
|
||||||
|
else:
|
||||||
|
real_uuid = txn.get_insert_uuid(self.result) or self.result
|
||||||
|
# If we have multiple commands in a transation, post_commit can
|
||||||
|
# be called even if *this* command caused no change. Theoretically
|
||||||
|
# the subclass should have set a UUID/RowView result in that case
|
||||||
|
# which is handled above, so raise exception if real_uuid not found
|
||||||
|
row = self.api.tables[self.table_name].rows[real_uuid]
|
||||||
self.result = rowview.RowView(row)
|
self.result = rowview.RowView(row)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue