Allow read-only Commands to bypass txns in execute()

This patch continues https://review.opendev.org/#/c/633070/.

Since the ovs_idl backend maintains an in-memory copy of the DB,
read-only commands can be executed w/o creating a transaction.
Since it is possible for a function that calls execute() to be
automatically nested into an existing transaction, execute()
wasn't able to access the result since it only happens once the
parent transaction completed. Handling these read-only commands
w/o creating a transaction allows the results to be read and
avoids wasting resources by creating needless transactions.

ReadOnlyCommands can still be used in with transaction(): blocks
with no changes.

Change-Id: Ic3f7cd5733b7a28acc74345e7faa182ebd3a69b0
Closes-Bug: #1873305
This commit is contained in:
Rodolfo Alonso Hernandez 2020-04-16 15:55:25 +00:00 committed by Terry Wilson
parent 3598631558
commit aadf1624ef
1 changed files with 4 additions and 4 deletions

View File

@ -414,7 +414,7 @@ class LspGetCommand(cmd.BaseGetRowCommand):
table = 'Logical_Switch_Port'
class LspGetParentCommand(cmd.BaseCommand):
class LspGetParentCommand(cmd.ReadOnlyCommand):
def __init__(self, api, port):
super(LspGetParentCommand, self).__init__(api)
self.port = port
@ -424,7 +424,7 @@ class LspGetParentCommand(cmd.BaseCommand):
self.result = next(iter(lsp.parent_name), "")
class LspGetTagCommand(cmd.BaseCommand):
class LspGetTagCommand(cmd.ReadOnlyCommand):
def __init__(self, api, port):
super(LspGetTagCommand, self).__init__(api)
self.port = port
@ -453,7 +453,7 @@ class LspSetAddressesCommand(cmd.BaseCommand):
lsp.addresses = self.addresses
class LspGetAddressesCommand(cmd.BaseCommand):
class LspGetAddressesCommand(cmd.ReadOnlyCommand):
def __init__(self, api, port):
super(LspGetAddressesCommand, self).__init__(api)
self.port = port
@ -476,7 +476,7 @@ class LspSetPortSecurityCommand(cmd.BaseCommand):
lsp.port_security = self.addresses
class LspGetPortSecurityCommand(cmd.BaseCommand):
class LspGetPortSecurityCommand(cmd.ReadOnlyCommand):
def __init__(self, api, port):
super(LspGetPortSecurityCommand, self).__init__(api)
self.port = port