Merge "Filter the ports by VNIC type"

This commit is contained in:
Zuul 2022-06-27 15:22:10 +00:00 committed by Gerrit Code Review
commit aa30bd1821
2 changed files with 8 additions and 7 deletions

View File

@ -684,13 +684,12 @@ class Port(base.NeutronDbObject):
@classmethod
@db_api.CONTEXT_READER
def get_ports_by_vnic_type_and_host(
cls, context, vnic_type, host):
def get_ports_by_vnic_type_and_host(cls, context, vnic_type, host=None):
query = context.session.query(models_v2.Port).join(
ml2_models.PortBinding)
query = query.filter(
ml2_models.PortBinding.vnic_type == vnic_type,
ml2_models.PortBinding.host == host)
query = query.filter(ml2_models.PortBinding.vnic_type == vnic_type)
if host:
query = query.filter(ml2_models.PortBinding.host == host)
return [cls._load_object(context, db_obj) for db_obj in query.all()]
@classmethod

View File

@ -35,6 +35,7 @@ from neutron.common.ovn import utils
from neutron.conf.plugins.ml2.drivers.ovn import ovn_conf
from neutron.db import ovn_hash_ring_db as hash_ring_db
from neutron.db import ovn_revision_numbers_db as revision_numbers_db
from neutron.objects import ports as ports_obj
from neutron.plugins.ml2.drivers.ovn.mech_driver.ovsdb import ovn_db_sync
@ -749,9 +750,10 @@ class DBInconsistenciesPeriodics(SchemaAwarePeriodicsBase):
return
context = n_context.get_admin_context()
ports = ports_obj.Port.get_ports_by_vnic_type_and_host(
context, portbindings.VNIC_BAREMETAL)
ports = self._ovn_client._plugin.get_ports(
context,
filters={portbindings.VNIC_TYPE: portbindings.VNIC_BAREMETAL})
context, filters={'id': [p.id for p in ports]})
if not ports:
raise periodics.NeverAgain()