Ejemplo n.º 1
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)
Ejemplo n.º 2
0
 def _process_status_update(self,
                            repo,
                            object_name,
                            record,
                            delete_record=False):
     # Zero it out so that if the ID is missing from a record we do not
     # report the last LB as the failed record in the exception
     record_id = None
     try:
         record_id = record['id']
         record_kwargs = {}
         prov_status = record.get(consts.PROVISIONING_STATUS, None)
         if prov_status:
             if prov_status == consts.DELETED and delete_record:
                 repo.delete(self.db_session, id=record_id)
                 return
             else:
                 record_kwargs[consts.PROVISIONING_STATUS] = prov_status
         op_status = record.get(consts.OPERATING_STATUS, None)
         if op_status:
             record_kwargs[consts.OPERATING_STATUS] = op_status
         if prov_status or op_status:
             repo.update(self.db_session, record_id, **record_kwargs)
     except Exception as e:
         # We need to raise a failure here to notify the driver it is
         # sending bad status data.
         raise driver_exceptions.UpdateStatusError(
             fault_string=str(e),
             status_object_id=record_id,
             status_object=object_name)
Ejemplo n.º 3
0
 def _process_status_update(self, repo, object_name, record,
                            delete_record=False):
     # Zero it out so that if the ID is missing from a record we do not
     # report the last LB as the failed record in the exception
     record_id = None
     try:
         record_id = record['id']
         record_kwargs = {}
         prov_status = record.get(consts.PROVISIONING_STATUS, None)
         if prov_status:
             if (prov_status == consts.DELETED and
                     object_name == consts.LOADBALANCERS):
                 self._check_for_lb_vip_deallocate(repo, record_id)
             elif prov_status == consts.DELETED and delete_record:
                 repo.delete(self.db_session, id=record_id)
                 return
             record_kwargs[consts.PROVISIONING_STATUS] = prov_status
         op_status = record.get(consts.OPERATING_STATUS, None)
         if op_status:
             record_kwargs[consts.OPERATING_STATUS] = op_status
         if prov_status or op_status:
             repo.update(self.db_session, record_id, **record_kwargs)
     except Exception as e:
         # We need to raise a failure here to notify the driver it is
         # sending bad status data.
         raise driver_exceptions.UpdateStatusError(
             fault_string=str(e), status_object_id=record_id,
             status_object=object_name)
Ejemplo n.º 4
0
 def _update_status(session, repo, entity_type, entity_id, new_op_status,
                    old_op_status):
     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)
Ejemplo n.º 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})
Ejemplo n.º 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})
Ejemplo n.º 7
0
 def _update_status(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 compatibility
         if new_op_status == constants.DRAINING:
             new_op_status = constants.ONLINE
         message.update({constants.OPERATING_STATUS: new_op_status})
Ejemplo n.º 8
0
 def _update_status(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 compatibility
         if new_op_status == constants.DRAINING:
             new_op_status = constants.ONLINE
         message.update({constants.OPERATING_STATUS: new_op_status})
Ejemplo n.º 9
0
 def _update_status_and_emit_event(self, session, repo, entity_type,
                                   entity_id, new_op_status, old_op_status,
                                   current_prov_status):
     message = {}
     if old_op_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,
             old_op_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. "
                   "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)