def delete(self, context, hm, completor): lb_id = hm['pool']['loadbalancer_id'] pool_id = hm['pool']['id'] pool_client = self.core_plugin.nsxlib.load_balancer.pool monitor_client = self.core_plugin.nsxlib.load_balancer.monitor binding = nsx_db.get_nsx_lbaas_monitor_binding( context.session, lb_id, pool_id, hm['id']) if binding: lb_monitor_id = binding['lb_monitor_id'] lb_pool_id = binding['lb_pool_id'] try: pool_client.remove_monitor_from_pool(lb_pool_id, lb_monitor_id) except nsxlib_exc.ManagerError as exc: LOG.error('Failed to remove monitor %(monitor)s from pool ' '%(pool)s with exception from nsx %(exc)s)', {'monitor': lb_monitor_id, 'pool': lb_pool_id, 'exc': exc}) try: monitor_client.delete(lb_monitor_id) except nsxlib_exc.ManagerError as exc: LOG.error('Failed to delete monitor %(monitor)s from ' 'backend with exception %(exc)s', {'monitor': lb_monitor_id, 'exc': exc}) nsx_db.delete_nsx_lbaas_monitor_binding(context.session, lb_id, pool_id, hm['id']) else: # Do not fail a delete action pass completor(success=True)
def delete(self, context, hm): lb_id = hm.pool.loadbalancer_id pool_id = hm.pool.id pool_client = self.core_plugin.nsxlib.load_balancer.pool monitor_client = self.core_plugin.nsxlib.load_balancer.monitor binding = nsx_db.get_nsx_lbaas_monitor_binding(context.session, lb_id, pool_id, hm.id) if binding: lb_monitor_id = binding['lb_monitor_id'] lb_pool_id = binding['lb_pool_id'] try: pool_client.remove_monitor_from_pool(lb_pool_id, lb_monitor_id) except nsxlib_exc.ManagerError: self.lbv2_driver.health_monitor.failed_completion(context, hm) msg = _('Failed to remove monitor %(monitor)s from pool ' '%(pool)s') % { 'monitor': lb_monitor_id, 'pool': lb_pool_id } raise n_exc.BadRequest(resource='lbaas-hm', msg=msg) try: monitor_client.delete(lb_monitor_id) except nsxlib_exc.ManagerError: self.lbv2_driver.health_monitor.failed_completion(context, hm) msg = _('Failed to delete monitor %(monitor)s from ' 'backend') % { 'monitor': lb_monitor_id } raise n_exc.BadRequest(resource='lbaas-hm', msg=msg) nsx_db.delete_nsx_lbaas_monitor_binding(context.session, lb_id, pool_id, hm.id) self.lbv2_driver.health_monitor.successful_completion(context, hm, delete=True)
def delete(self, context, hm, completor): lb_id = hm['pool']['loadbalancer_id'] pool_id = hm['pool']['id'] pool_client = self.core_plugin.nsxlib.load_balancer.pool monitor_client = self.core_plugin.nsxlib.load_balancer.monitor binding = nsx_db.get_nsx_lbaas_monitor_binding( context.session, lb_id, pool_id, hm['id']) if binding: lb_monitor_id = binding['lb_monitor_id'] lb_pool_id = binding['lb_pool_id'] try: pool_client.remove_monitor_from_pool(lb_pool_id, lb_monitor_id) except nsxlib_exc.ResourceNotFound: pass except nsxlib_exc.ManagerError as exc: completor(success=False) msg = _('Failed to remove monitor %(monitor)s from pool ' '%(pool)s with exception from nsx %(exc)s)') % { 'monitor': lb_monitor_id, 'pool': lb_pool_id, 'exc': exc} raise n_exc.BadRequest(resource='lbaas-hm', msg=msg) try: monitor_client.delete(lb_monitor_id) except nsxlib_exc.ResourceNotFound: pass except nsxlib_exc.ManagerError as exc: completor(success=False) msg = _('Failed to delete monitor %(monitor)s from ' 'backend with exception %(exc)s') % { 'monitor': lb_monitor_id, 'exc': exc} raise n_exc.BadRequest(resource='lbaas-hm', msg=msg) nsx_db.delete_nsx_lbaas_monitor_binding(context.session, lb_id, pool_id, hm['id']) else: # Do not fail a delete action pass completor(success=True)
def update(self, context, old_hm, new_hm, completor): lb_id = new_hm['pool']['loadbalancer_id'] pool_id = new_hm['pool']['id'] monitor_client = self.core_plugin.nsxlib.load_balancer.monitor binding = nsx_db.get_nsx_lbaas_monitor_binding( context.session, lb_id, pool_id, new_hm['id']) if binding: lb_monitor_id = binding['lb_monitor_id'] monitor_body = self._build_monitor_args(new_hm) monitor_name = utils.get_name_and_uuid(new_hm['name'] or 'monitor', new_hm['id']) monitor_client.update(lb_monitor_id, display_name=monitor_name, **monitor_body) else: completor(success=False) msg = _('Failed to update monitor %(monitor)s: NSX monitor was ' 'not found in DB') % {'monitor': new_hm['id'], 'pool': pool_id} raise n_exc.BadRequest(resource='lbaas-hm', msg=msg) completor(success=True)
def update(self, context, old_hm, new_hm, completor): lb_id = new_hm['pool']['loadbalancer_id'] pool_id = new_hm['pool']['id'] monitor_client = self.core_plugin.nsxlib.load_balancer.monitor binding = nsx_db.get_nsx_lbaas_monitor_binding( context.session, lb_id, pool_id, new_hm['id']) if binding: lb_monitor_id = binding['lb_monitor_id'] monitor_body = self._build_monitor_args(new_hm) monitor_name = utils.get_name_and_uuid(new_hm['name'] or 'monitor', new_hm['id']) monitor_client.update(lb_monitor_id, display_name=monitor_name, **monitor_body) else: completor(success=False) msg = _('Failed to update monitor %(monitor)s: NSX monitor was ' 'not found in DB') % {'monitor': new_hm['id'], 'pool': pool_id} raise n_exc.BadRequest(resource='lbaas-hm', msg=msg) completor(success=True)
def delete(self, context, hm): lb_id = hm.pool.loadbalancer_id pool_id = hm.pool.id pool_client = self.core_plugin.nsxlib.load_balancer.pool monitor_client = self.core_plugin.nsxlib.load_balancer.monitor binding = nsx_db.get_nsx_lbaas_monitor_binding(context.session, lb_id, pool_id, hm.id) if binding: lb_monitor_id = binding['lb_monitor_id'] lb_pool_id = binding['lb_pool_id'] try: pool_client.remove_monitor_from_pool(lb_pool_id, lb_monitor_id) except nsxlib_exc.ManagerError as exc: LOG.error( 'Failed to remove monitor %(monitor)s from pool ' '%(pool)s with exception from nsx %(exc)s)', { 'monitor': lb_monitor_id, 'pool': lb_pool_id, 'exc': exc }) try: monitor_client.delete(lb_monitor_id) except nsxlib_exc.ManagerError as exc: LOG.error( 'Failed to delete monitor %(monitor)s from ' 'backend with exception %(exc)s', { 'monitor': lb_monitor_id, 'exc': exc }) nsx_db.delete_nsx_lbaas_monitor_binding(context.session, lb_id, pool_id, hm.id) self.lbv2_driver.health_monitor.successful_completion(context, hm, delete=True)