'Update the stack state.'

@profiler.trace('Stack.state_set', hide_args=False)
def state_set(self, action, status, reason):

    if (action not in self.ACTIONS):
        raise ValueError((_('Invalid    action    %s') % action))
    if (status not in self.STATUSES):
        raise ValueError((_('Invalid    status    %s') % status))
    self.action = action
    self.status = status
    self.status_reason = reason
    self._log_status()
    if (self.convergence and (action in (self.UPDATE, self.DELETE, self.CREATE, self.ADOPT, self.ROLLBACK, self.RESTORE))):
        updated = self._persist_state()
        if (not updated):
            LOG.warning('Failed    to    set    state    of    stack    %(name)s    with    traversal    ID    %(trvsl_id)s,    to    %(action)s_%(status)s', {'name': self.name, 'trvsl_id': self.current_traversal, 'action': action, 'status': status})
        return updated
    if ((status == self.IN_PROGRESS) or (action in (self.UPDATE, self.DELETE, self.ROLLBACK, self.RESTORE))):
        self._persist_state()
