Merge "NSXv3: Fix load balancer delete issue"

This commit is contained in:
Zuul 2017-10-26 10:56:49 +00:00 committed by Gerrit Code Review
commit cf80ee0cc9

View File

@ -63,22 +63,27 @@ class EdgeLoadBalancerManager(base_mgr.Nsxv3LoadbalancerBaseManager):
if lb_binding: if lb_binding:
lb_service_id = lb_binding['lb_service_id'] lb_service_id = lb_binding['lb_service_id']
nsx_router_id = lb_binding['lb_router_id'] nsx_router_id = lb_binding['lb_router_id']
lb_service = service_client.get(lb_service_id) try:
vs_list = lb_service.get('virtual_server_ids') lb_service = service_client.get(lb_service_id)
if not vs_list: except nsxlib_exc.ManagerError:
try: LOG.warning("LB service %(lbs)s is not found",
service_client.delete(lb_service_id) {'lbs': lb_service_id})
# If there is no lb service attached to the router, else:
# update the router advertise_lb_vip flag to false. vs_list = lb_service.get('virtual_server_ids')
router_client = self.core_plugin.nsxlib.logical_router if not vs_list:
router_client.update_advertisement(nsx_router_id, try:
advertise_lb_vip=False) service_client.delete(lb_service_id)
except nsxlib_exc.ManagerError: # If there is no lb service attached to the router,
self.lbv2_driver.load_balancer.failed_completion( # update the router advertise_lb_vip flag to false.
context, lb, delete=True) router_client = self.core_plugin.nsxlib.logical_router
msg = (_('Failed to delete lb service %(lbs)s from nsx') % router_client.update_advertisement(
{'lbs': lb_service_id}) nsx_router_id, advertise_lb_vip=False)
raise n_exc.BadRequest(resource='lbaas-lb', msg=msg) except nsxlib_exc.ManagerError:
self.lbv2_driver.load_balancer.failed_completion(
context, lb, delete=True)
msg = (_('Failed to delete lb service %(lbs)s from nsx'
) % {'lbs': lb_service_id})
raise n_exc.BadRequest(resource='lbaas-lb', msg=msg)
nsx_db.delete_nsx_lbaas_loadbalancer_binding( nsx_db.delete_nsx_lbaas_loadbalancer_binding(
context.session, lb.id) context.session, lb.id)
self.lbv2_driver.load_balancer.successful_completion( self.lbv2_driver.load_balancer.successful_completion(