Beispiel #1
0
    def set_status(self, result, reason=None):
        """Set action status based on return value from execute."""

        timestamp = wallclock()

        if result == self.RES_OK:
            status = self.SUCCEEDED
            db_api.action_mark_succeeded(self.context, self.id, timestamp)

        elif result == self.RES_ERROR:
            status = self.FAILED
            db_api.action_mark_failed(self.context, self.id, timestamp,
                                      reason=reason or 'ERROR')

        elif result == self.RES_TIMEOUT:
            status = self.FAILED
            db_api.action_mark_failed(self.context, self.id, timestamp,
                                      reason=reason or 'TIMEOUT')

        elif result == self.RES_CANCEL:
            status = self.CANCELLED
            db_api.action_mark_cancelled(self.context, self.id, timestamp)

        else:  # result == self.RES_RETRY:
            status = self.READY
            # Action failed at the moment, but can be retried
            # We abandon it and then notify other dispatchers to execute it
            db_api.action_abandon(self.context, self.id)

        if status == self.SUCCEEDED:
            EVENT.info(self.context, self, self.action, status, reason)
        elif status == self.READY:
            EVENT.warning(self.context, self, self.action, status, reason)
        else:
            EVENT.error(self.context, self, self.action, status, reason)

        self.status = status
        self.status_reason = reason
Beispiel #2
0
    def set_status(self, result, reason=None):
        '''Set action status based on return value from execute.'''

        timestamp = wallclock()

        if result == self.RES_OK:
            status = self.SUCCEEDED
            msg = _LI('Action %(name)s [%(id)s] completed with SUCCESS.')
            db_api.action_mark_succeeded(self.context, self.id, timestamp)

        elif result == self.RES_ERROR:
            status = self.FAILED
            msg = _LI('Action %(name)s [%(id)s] failed with ERROR.')
            db_api.action_mark_failed(self.context, self.id, timestamp,
                                      reason=reason or 'ERROR')

        elif result == self.RES_TIMEOUT:
            status = self.FAILED
            msg = _LI('Action %(name)s [%(id)s] failed with TIMEOUT.')
            db_api.action_mark_failed(self.context, self.id, timestamp,
                                      reason=reason or 'TIMEOUT')

        elif result == self.RES_CANCEL:
            status = self.CANCELLED
            msg = _LI('Action %(name)s [%(id)s] was cancelled.')
            db_api.action_mark_cancelled(self.context, self.id, timestamp)

        else:  # result == self.RES_RETRY:
            status = self.READY
            # Action failed at the moment, but can be retried
            # We abandon it and then notify other dispatchers to execute it
            db_api.action_abandon(self.context, self.id)
            msg = _LI('Action %(name)s [%(id)s] aborted with RETRY.')

        LOG.info(msg, {'name': self.action, 'id': self.id, 'status': status})
        self.status = status
        self.status_reason = reason
Beispiel #3
0
 def mark_succeeded(cls, context, action_id, timestamp):
     return db_api.action_mark_succeeded(context, action_id, timestamp)
Beispiel #4
0
 def mark_succeeded(cls, context, action_id, timestamp):
     return db_api.action_mark_succeeded(context, action_id, timestamp)