예제 #1
0
 def _decrement_quota(self, repo, object_name, record_id):
     lock_session = db_apis.get_session(autocommit=False)
     db_object = repo.get(lock_session, id=record_id)
     try:
         if db_object.provisioning_status == consts.DELETED:
             LOG.info(
                 '%(name)s with ID of %(id)s is already in the '
                 'DELETED state. Skipping quota update.', {
                     'name': object_name,
                     'id': record_id
                 })
             lock_session.rollback()
             return
         self.repos.decrement_quota(lock_session,
                                    repo.model_class.__data_model__,
                                    db_object.project_id)
         lock_session.commit()
     except Exception:
         with excutils.save_and_reraise_exception():
             LOG.error(
                 'Failed to decrement %(name)s quota for '
                 'project: %(proj)s the project may have excess '
                 'quota in use.', {
                     'proj': db_object.project_id,
                     'name': object_name
                 })
             lock_session.rollback()
예제 #2
0
 def _update_status_and_emit_event(self, session, repo, entity_type,
                                   entity_id, new_op_status, old_op_status):
     message = {}
     if old_op_status.lower() != new_op_status.lower():
         LOG.debug(
             "%s %s status has changed from %s to "
             "%s, updating db.", entity_type, entity_id, old_op_status,
             new_op_status)
         repo.update(session, entity_id, operating_status=new_op_status)
         # Map the status for neutron-lbaas
         if new_op_status == constants.DRAINING:
             new_op_status = constants.ONLINE
         message.update({constants.OPERATING_STATUS: new_op_status})
     if (CONF.health_manager.event_streamer_driver !=
             constants.NOOP_EVENT_STREAMER):
         if CONF.health_manager.sync_provisioning_status:
             current_prov_status = repo.get(
                 session, id=entity_id).provisioning_status
             LOG.debug("%s %s provisioning_status %s. "
                       "Sending event.", entity_type, entity_id,
                       current_prov_status)
             message.update(
                 {constants.PROVISIONING_STATUS: current_prov_status})
         if message:
             self.emit(entity_type, entity_id, message)
예제 #3
0
 def _check_for_lb_vip_deallocate(self, repo, lb_id):
     lb = repo.get(self.db_session, id=lb_id)
     if lb.vip.octavia_owned:
         vip = lb.vip
         # We need a backreference
         vip.load_balancer = lb
         # Only lookup the network driver if we have a VIP to deallocate
         network_driver = utils.get_network_driver()
         network_driver.deallocate_vip(vip)
예제 #4
0
 def _check_for_lb_vip_deallocate(self, repo, lb_id):
     lb = repo.get(self.db_session, id=lb_id)
     if lb.vip.octavia_owned:
         vip = lb.vip
         # We need a backreference
         vip.load_balancer = lb
         # Only lookup the network driver if we have a VIP to deallocate
         network_driver = utils.get_network_driver()
         network_driver.deallocate_vip(vip)
예제 #5
0
 def _update_status_and_emit_event(self, session, repo, entity_type,
                                   entity_id, new_op_status):
     entity = repo.get(session, id=entity_id)
     if entity.operating_status.lower() != new_op_status.lower():
         LOG.debug(
             "%s %s status has changed from %s to "
             "%s. Updating db and sending event.", entity_type, entity_id,
             entity.operating_status, new_op_status)
         repo.update(session, entity_id, operating_status=new_op_status)
         self.emit(entity_type, entity_id,
                   {constants.OPERATING_STATUS: new_op_status})
예제 #6
0
 def _update_status_and_emit_event(self, session, repo, entity_type,
                                   entity_id, new_op_status):
     entity = repo.get(session, id=entity_id)
     if entity.operating_status.lower() != new_op_status.lower():
         LOG.debug("%s %s status has changed from %s to "
                   "%s. Updating db and sending event.",
                   entity_type, entity_id, entity.operating_status,
                   new_op_status)
         repo.update(session, entity_id, operating_status=new_op_status)
         self.emit(
             entity_type, entity_id,
             {constants.OPERATING_STATUS: new_op_status})
예제 #7
0
 def _update_status_and_emit_event(self, session, repo, entity_type,
                                   entity_id, new_op_status):
     entity = repo.get(session, id=entity_id)
     message = {}
     if entity.operating_status.lower() != new_op_status.lower():
         LOG.debug(
             "%s %s status has changed from %s to "
             "%s. Updating db and sending event.", entity_type, entity_id,
             entity.operating_status, new_op_status)
         repo.update(session, entity_id, operating_status=new_op_status)
         if new_op_status == constants.DRAINING:
             new_op_status = constants.ONLINE
         message.update({constants.OPERATING_STATUS: new_op_status})
     if self.sync_prv_status:
         LOG.debug(
             "%s %s provisioning_status %s. Updating db and sending"
             " event.", entity_type, entity_id, entity.provisioning_status)
         message.update(
             {constants.PROVISIONING_STATUS: entity.provisioning_status})
     if message:
         self.emit(entity_type, entity_id, message)
예제 #8
0
    def _get_db_obj_until_pending_update(self, repo, id):

        return repo.get(db_apis.get_session(), id=id)
예제 #9
0
    def _get_db_obj_until_pending_update(self, repo, id):

        return repo.get(db_apis.get_session(), id=id)