'Mark the resource as healthy or unhealthy.
Put the resource in CHECK_FAILED state if \'mark_unhealthy\'
is true. Put the resource in CHECK_COMPLETE if \'mark_unhealthy\'
is false and the resource is in CHECK_FAILED state.
Otherwise, make no change.
:param resource_name: either the logical name of the resource or the
physical resource ID.
:param mark_unhealthy: indicates whether the resource is unhealthy.
:param resource_status_reason: reason for health change.'

@context.request_context
def resource_mark_unhealthy(self, cnxt, stack_identity, resource_name, mark_unhealthy, resource_status_reason=None):

    def lock(rsrc):
        if rsrc.stack.convergence:
            return rsrc.lock(self.engine_id)
        else:
            return stack_lock.StackLock(cnxt, rsrc.stack.id, self.engine_id)
    if (not isinstance(mark_unhealthy, bool)):
        raise exception.Invalid(reason='mark_unhealthy    is    not    a    boolean')
    s = self._get_stack(cnxt, stack_identity)
    stack = parser.Stack.load(cnxt, stack=s)
    rsrc = self._find_resource_in_stack(cnxt, resource_name, stack)
    reason = (resource_status_reason or 'state    changed    by    resource_mark_unhealthy    api')
    try:
        with lock(rsrc):
            if mark_unhealthy:
                if (rsrc.action != rsrc.DELETE):
                    rsrc.state_set(rsrc.CHECK, rsrc.FAILED, reason=reason)
            elif (rsrc.state == (rsrc.CHECK, rsrc.FAILED)):
                rsrc.handle_metadata_reset()
                rsrc.state_set(rsrc.CHECK, rsrc.COMPLETE, reason=reason)
    except exception.UpdateInProgress:
        raise exception.ActionInProgress(stack_name=stack.name, action=stack.action)
