Merge "Filter the ports by VNIC type"
This commit is contained in:
commit
aa30bd1821
@ -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
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user