def delete(self, context, lb): # Discard any ports which are associated with LB filters = { 'device_id': [lb.id], 'device_owner': [constants.DEVICE_OWNER_NEUTRON_PREFIX + 'LB'] } lb_ports = self.core_plugin.get_ports(context.elevated(), filters=filters) for lb_port in lb_ports: self.core_plugin.delete_port(context.elevated(), lb_port['id']) binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding( context.session, lb.id) if binding: edge_binding = nsxv_db.get_nsxv_router_binding_by_edge( context.session, binding['edge_id']) # set LB default rule lb_common.set_lb_firewall_default_rule(self.vcns, binding['edge_id'], 'deny') if edge_binding: old_lb = lb_common.is_lb_on_router_edge( context, self.core_plugin, binding['edge_id']) if not old_lb: resource_id = lb_common.get_lb_resource_id(lb.id) self.core_plugin.edge_manager.delete_lrouter(context, resource_id, dist=False) else: # Edge was created on an exclusive router with the old code try: lb_common.del_vip_fw_rule(self.vcns, binding['edge_id'], binding['edge_fw_rule_id']) except nsxv_exc.VcnsApiException as e: LOG.error( 'Failed to delete loadbalancer %(lb)s ' 'FW rule. exception is %(exc)s', { 'lb': lb.id, 'exc': e }) try: lb_common.del_vip_as_secondary_ip( self.vcns, binding['edge_id'], lb.vip_address) except Exception as e: LOG.error( 'Failed to delete loadbalancer %(lb)s ' 'interface IP. exception is %(exc)s', { 'lb': lb.id, 'exc': e }) nsxv_db.del_nsxv_lbaas_loadbalancer_binding(context.session, lb.id) self.lbv2_driver.load_balancer.successful_completion(context, lb, delete=True)
def delete(self, context, lb): try: binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding( context.session, lb.id) if binding: lb_common.del_vip_fw_rule(self.vcns, binding['edge_id'], binding['edge_fw_rule_id']) lb_common.del_vip_as_secondary_ip(self.vcns, binding['edge_id'], lb.vip_address) nsxv_db.del_nsxv_lbaas_loadbalancer_binding(context.session, lb.id) self.lbv2_driver.load_balancer.successful_completion( context, lb, delete=True) except nsxv_exc.VcnsApiException: with excutils.save_and_reraise_exception(): self.lbv2_driver.load_balancer.failed_completion(context, lb) LOG.error(_LE('Failed to delete pool %s'), lb.id)
def delete(self, context, lb): try: binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding( context.session, lb.id) if binding: lb_common.del_vip_fw_rule(self.vcns, binding['edge_id'], binding['edge_fw_rule_id']) lb_common.del_vip_as_secondary_ip(self.vcns, binding['edge_id'], lb.vip_address) nsxv_db.del_nsxv_lbaas_loadbalancer_binding( context.session, lb.id) self.lbv2_driver.load_balancer.successful_completion(context, lb, delete=True) except nsxv_exc.VcnsApiException: with excutils.save_and_reraise_exception(): self.lbv2_driver.load_balancer.failed_completion(context, lb) LOG.error(_LE('Failed to delete pool %s'), lb.id)
def delete(self, context, lb): binding = nsxv_db.get_nsxv_lbaas_loadbalancer_binding( context.session, lb.id) if binding: try: lb_common.del_vip_fw_rule(self.vcns, binding['edge_id'], binding['edge_fw_rule_id']) except nsxv_exc.VcnsApiException as e: LOG.error(_LE('Failed to delete loadbalancer %(lb)s FW rule. ' 'exception is %(exc)s'), {'lb': lb.id, 'exc': e}) try: lb_common.del_vip_as_secondary_ip(self.vcns, binding['edge_id'], lb.vip_address) except Exception as e: LOG.error(_LE('Failed to delete loadbalancer %(lb)s interface' ' IP. exception is %(exc)s'), {'lb': lb.id, 'exc': e}) nsxv_db.del_nsxv_lbaas_loadbalancer_binding(context.session, lb.id) self.lbv2_driver.load_balancer.successful_completion(context, lb, delete=True)