Fix broken behavior after recent OVS update
After the monitor_cond_since/update3 support patch in ovs
(46d44cf3be0), directly setting table.condition is broken. This
isn't something that was every truly supported. Ultimately, it
would be good if we could make this code less dependent on exactly
what happens in Idl.__init__()--maybe adding an update_tables()
method in python-ovs.
To avoid stomping on the state stored in ConditionState, instead
of replacing Idl.tables, this removes deletions and adds new
tables that were passed. Existing tables are left alone.
Closes-Bug: 1965819
Change-Id: Iad0d7472a7adce4a79111f94a2f33fc5b1a5c530
(cherry picked from commit 06207b33e3
)
This commit is contained in:
parent
a73fbf1e5e
commit
a7a1d5cfd3
|
@ -209,13 +209,25 @@ class OvsdbIdl(idl.Idl):
|
|||
|
||||
schema = schema_helper.get_idl_schema()
|
||||
self._db = schema
|
||||
self.tables = schema.tables
|
||||
for table in schema.tables.values():
|
||||
removed = self.tables.keys() - schema.tables.keys()
|
||||
added = schema.tables.keys() - self.tables.keys()
|
||||
|
||||
# stop monitoring removed tables
|
||||
for table in removed:
|
||||
self.cond_change(table, [False])
|
||||
del self.tables[table]
|
||||
|
||||
# add new tables as Idl.__init__ does
|
||||
for table in (schema.tables[table] for table in added):
|
||||
self.tables[table.name] = table
|
||||
for column in table.columns.values():
|
||||
if not hasattr(column, 'alert'):
|
||||
column.alert = True
|
||||
table.need_table = False
|
||||
table.rows = custom_index.IndexedRows(table)
|
||||
table.idl = self
|
||||
table.condition = [True]
|
||||
try:
|
||||
table.condition = idl.ConditionState()
|
||||
except AttributeError:
|
||||
table.condition = [True]
|
||||
table.cond_changed = False
|
||||
|
|
|
@ -64,6 +64,9 @@ class TestOvsdbIdl(base.FunctionalTestCase):
|
|||
for table in tables:
|
||||
valid_func(table, self.idl.tables)
|
||||
|
||||
# ensure that the Idl still works after we update the tables
|
||||
self.idl.run()
|
||||
|
||||
def test_add_new_table(self):
|
||||
tables = ["Port", "Interface"]
|
||||
|
||||
|
|
Loading…
Reference in New Issue