From f15d014fc7cb4111c132e7e2b3b3f35e0dbf5e82 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Thu, 19 Jul 2018 17:43:14 +0000 Subject: [PATCH] Use api.lookup instead of idlutils.row_by_record idlutils.row_by_record is a holdover from when there was only one schema. api.lookup() supports per-class lookup tables instead of using the hardcoded Open_vSwitch lookup table. Change-Id: I93a883e3afafb35f8e667afda99c77350da83ed4 --- ovsdbapp/backend/ovs_idl/command.py | 14 ++++++-------- ovsdbapp/schema/open_vswitch/impl_idl.py | 2 ++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ovsdbapp/backend/ovs_idl/command.py b/ovsdbapp/backend/ovs_idl/command.py index 80cc2e3c..fa2a998e 100644 --- a/ovsdbapp/backend/ovs_idl/command.py +++ b/ovsdbapp/backend/ovs_idl/command.py @@ -95,7 +95,7 @@ class DbDestroyCommand(BaseCommand): self.record = record def run_idl(self, txn): - record = idlutils.row_by_record(self.api.idl, self.table, self.record) + record = self.api.lookup(self.table, self.record) record.delete() @@ -107,7 +107,7 @@ class DbSetCommand(BaseCommand): self.col_values = col_values def run_idl(self, txn): - record = idlutils.row_by_record(self.api.idl, self.table, self.record) + record = self.api.lookup(self.table, self.record) for col, val in self.col_values: # TODO(twilson) Ugh, the OVS library doesn't like OrderedDict # We're only using it to make a unit test work, so we should fix @@ -132,7 +132,7 @@ class DbAddCommand(BaseCommand): self.values = values def run_idl(self, txn): - record = idlutils.row_by_record(self.api.idl, self.table, self.record) + record = self.api.lookup(self.table, self.record) for value in self.values: if isinstance(value, collections.Mapping): # We should be doing an add on a 'map' column. If the key is @@ -165,7 +165,7 @@ class DbClearCommand(BaseCommand): self.column = column def run_idl(self, txn): - record = idlutils.row_by_record(self.api.idl, self.table, self.record) + record = self.api.lookup(self.table, self.record) # Create an empty value of the column type value = type(getattr(record, self.column))() setattr(record, self.column, value) @@ -179,7 +179,7 @@ class DbGetCommand(BaseCommand): self.column = column def run_idl(self, txn): - record = idlutils.row_by_record(self.api.idl, self.table, self.record) + record = self.api.lookup(self.table, self.record) # TODO(twilson) This feels wrong, but ovs-vsctl returns single results # on set types without the list. The IDL is returning them as lists, # even if the set has the maximum number of items set to 1. Might be @@ -211,9 +211,7 @@ class DbListCommand(BaseCommand): rows = [] for record in self.records: try: - rows.append(idlutils.row_by_record( - self.api.idl, self.table, record)) - + rows.append(self.api.idl.lookup(self.table, record)) except idlutils.RowNotFound: if self.if_exists: continue diff --git a/ovsdbapp/schema/open_vswitch/impl_idl.py b/ovsdbapp/schema/open_vswitch/impl_idl.py index afc90f2c..95f79d68 100644 --- a/ovsdbapp/schema/open_vswitch/impl_idl.py +++ b/ovsdbapp/schema/open_vswitch/impl_idl.py @@ -15,6 +15,7 @@ import logging from ovsdbapp.backend import ovs_idl +from ovsdbapp.backend.ovs_idl import idlutils from ovsdbapp.backend.ovs_idl import transaction from ovsdbapp import exceptions from ovsdbapp.schema.open_vswitch import api @@ -75,6 +76,7 @@ class OvsVsctlTransaction(transaction.Transaction): class OvsdbIdl(ovs_idl.Backend, api.API): schema = 'Open_vSwitch' + lookup_table = idlutils._LOOKUP_TABLE @property def connection(self):