NSX|V3: Fix router check for LB service

A neutron router can be attached to multiple loadbalancers.
So the DB query to check if it has any loadbalancers should
epect more than one result.

Change-Id: I5a2aab53cd1e925f8e75d98cb15b979e1cf88c57
This commit is contained in:
Adit Sarfaty 2019-06-11 10:55:43 +03:00
parent 8d7b24f9b6
commit 77aa1ce80c
1 changed files with 3 additions and 3 deletions

View File

@ -587,9 +587,9 @@ def get_nsx_lbaas_loadbalancer_binding_by_service(session, lb_service_id):
def has_nsx_lbaas_loadbalancer_binding_by_router(session, nsx_router_id):
try:
session.query(nsx_models.NsxLbaasLoadbalancer).filter_by(
lb_router_id=nsx_router_id).one()
return True
bindings = session.query(nsx_models.NsxLbaasLoadbalancer).filter_by(
lb_router_id=nsx_router_id).all()
return len(bindings) > 0
except exc.NoResultFound:
return False