diff --git a/neutron/db/l3_agentschedulers_db.py b/neutron/db/l3_agentschedulers_db.py index c0c2052eace..04425485082 100644 --- a/neutron/db/l3_agentschedulers_db.py +++ b/neutron/db/l3_agentschedulers_db.py @@ -312,12 +312,7 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase, query = query.options(orm.contains_eager( RouterL3AgentBinding.l3_agent)) query = query.join(RouterL3AgentBinding.l3_agent) - if len(router_ids) > 1: - query = query.filter( - RouterL3AgentBinding.router_id.in_(router_ids)) - else: - query = query.filter( - RouterL3AgentBinding.router_id == router_ids[0]) + query = query.filter(RouterL3AgentBinding.router_id.in_(router_ids)) if admin_state_up is not None: query = (query.filter(agents_db.Agent.admin_state_up == admin_state_up)) @@ -333,12 +328,8 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase, if not router_ids: return [] query = context.session.query(RouterL3AgentBinding) - if len(router_ids) > 1: - query = query.options(joinedload('l3_agent')).filter( - RouterL3AgentBinding.router_id.in_(router_ids)) - else: - query = query.options(joinedload('l3_agent')).filter( - RouterL3AgentBinding.router_id == router_ids[0]) + query = query.options(joinedload('l3_agent')).filter( + RouterL3AgentBinding.router_id.in_(router_ids)) return query.all() def list_l3_agents_hosting_router(self, context, router_id): diff --git a/neutron/db/portbindings_db.py b/neutron/db/portbindings_db.py index c8ab65c59da..a8feddcefa9 100644 --- a/neutron/db/portbindings_db.py +++ b/neutron/db/portbindings_db.py @@ -49,10 +49,7 @@ class PortBindingMixin(portbindings_base.PortBindingBaseMixin): values = filters and filters.get(portbindings.HOST_ID, []) if not values: return query - if len(values) == 1: - query = query.filter(PortBindingPort.host == values[0]) - else: - query = query.filter(PortBindingPort.host.in_(values)) + query = query.filter(PortBindingPort.host.in_(values)) return query db_base_plugin_v2.NeutronDbPluginV2.register_model_query_hook(