Add protection from DatapathNotFound exception

Ensure methods get_virtual_ports_on_datapath_by_chassis returns
an empty list if the datapath no longer exists

Change-Id: Ia50da1c8366ea645f64ce6f422551c8dad282cce
This commit is contained in:
Luis Tomas Bolivar 2023-03-10 14:47:47 +01:00
parent 8cc374eb32
commit 99c416deec

View File

@ -310,8 +310,11 @@ class OvsdbSbOvnIdl(sb_impl_idl.OvnSbApiIdlImpl, Backend):
return port
def get_virtual_ports_on_datapath_by_chassis(self, datapath, chassis):
rows = self.get_ports_on_datapath(
datapath, port_type=constants.OVN_VIRTUAL_VIF_PORT_TYPE)
try:
rows = self.get_ports_on_datapath(
datapath, port_type=constants.OVN_VIRTUAL_VIF_PORT_TYPE)
except exceptions.DatapathNotFound:
return []
return [r for r in rows if r.chassis and r.chassis[0].name == chassis]
def get_ovn_lb(self, name):