From 1e538a2d714d0a1ae8944450f07a024c98ca73ec Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Tue, 7 Apr 2020 10:52:20 -0500 Subject: [PATCH] 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 commit 0338c0bb5cd6368edc14bff8e64f980d4a6286ac) (cherry picked from commit fd0629f140fe34d24b567ec6d6a10a833f826ce9) --- ovsdbapp/backend/ovs_idl/command.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ovsdbapp/backend/ovs_idl/command.py b/ovsdbapp/backend/ovs_idl/command.py index e0056729..08597df4 100644 --- a/ovsdbapp/backend/ovs_idl/command.py +++ b/ovsdbapp/backend/ovs_idl/command.py @@ -15,6 +15,7 @@ import collections import logging +import ovs.db.idl import six from ovsdbapp import api @@ -75,8 +76,17 @@ class AddCommand(BaseCommand): def post_commit(self, txn): # If get_insert_uuid fails, self.result was not a result of a # recent insert. Most likely we are post_commit after a lookup() - real_uuid = txn.get_insert_uuid(self.result) or self.result - row = self.api.tables[self.table_name].rows[real_uuid] + if isinstance(self.result, rowview.RowView): + 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)