From 4ee25ad6af354e23992e19079b16c3d39a871930 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Tue, 12 Feb 2019 11:14:49 -0600 Subject: [PATCH] Break out match_fn from matches The condition matching functionality is kind of limited. Since matching table and event is very common, break out a match_fn method to allow users to create custom matching w/o replicating table and event matching. Change-Id: I5b48863499375c40295504bae41c5fffdbcd747c --- ovsdbapp/backend/ovs_idl/event.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ovsdbapp/backend/ovs_idl/event.py b/ovsdbapp/backend/ovs_idl/event.py index ae3dcc96..6fc3ed12 100644 --- a/ovsdbapp/backend/ovs_idl/event.py +++ b/ovsdbapp/backend/ovs_idl/event.py @@ -19,11 +19,7 @@ LOG = logging.getLogger(__name__) class RowEvent(ovsdb_event.RowEvent): # pylint: disable=abstract-method - def matches(self, event, row, old=None): - if event not in self.events: - return False - if row._table.name != self.table: - return False + def match_fn(self, event, row, old): if self.conditions and not idlutils.row_match(row, self.conditions): return False if self.old_conditions: @@ -35,7 +31,15 @@ class RowEvent(ovsdb_event.RowEvent): # pylint: disable=abstract-method except (KeyError, AttributeError): # Its possible that old row may not have all columns in it return False + return True + def matches(self, event, row, old=None): + if event not in self.events: + return False + if row._table.name != self.table: + return False + if not self.match_fn(event, row, old): + return False LOG.debug("%s : Matched %s, %s, %s %s", self.event_name, self.table, self.events, self.conditions, self.old_conditions) return True