Ejemplo n.º 1
0
static void
master_update_pseudo_status(
	resource_t *rsc, gboolean *demoting, gboolean *promoting) 
{	
	if(rsc->children) {
	    slist_iter(child, resource_t, rsc->children, lpc,
		       master_update_pseudo_status(child, demoting, promoting)
		);
	    return;
	}
    
	CRM_ASSERT(demoting != NULL);
	CRM_ASSERT(promoting != NULL);

	slist_iter(
		action, action_t, rsc->actions, lpc,

		if(*promoting && *demoting) {
			return;

		} else if(action->optional) {
Ejemplo n.º 2
0
static void
master_update_pseudo_status(resource_t * rsc, gboolean * demoting, gboolean * promoting)
{
    GListPtr gIter = NULL;

    if (rsc->children) {
        gIter = rsc->children;
        for (; gIter != NULL; gIter = gIter->next) {
            resource_t *child = (resource_t *) gIter->data;

            master_update_pseudo_status(child, demoting, promoting);
        }
        return;
    }

    CRM_ASSERT(demoting != NULL);
    CRM_ASSERT(promoting != NULL);

    gIter = rsc->actions;
    for (; gIter != NULL; gIter = gIter->next) {
        action_t *action = (action_t *) gIter->data;

        if (*promoting && *demoting) {
            return;

        } else if (is_set(action->flags, pe_action_optional)) {
            continue;

        } else if (safe_str_eq(RSC_DEMOTE, action->task)) {
            *demoting = TRUE;

        } else if (safe_str_eq(RSC_PROMOTE, action->task)) {
            *promoting = TRUE;
        }
    }
}
Ejemplo n.º 3
0
void
master_create_actions(resource_t * rsc, pe_working_set_t * data_set)
{
    action_t *action = NULL;
    GListPtr gIter = rsc->children;
    action_t *action_complete = NULL;
    gboolean any_promoting = FALSE;
    gboolean any_demoting = FALSE;
    resource_t *last_promote_rsc = NULL;
    resource_t *last_demote_rsc = NULL;

    clone_variant_data_t *clone_data = NULL;

    get_clone_variant_data(clone_data, rsc);

    crm_debug("Creating actions for %s", rsc->id);

    /* create actions as normal */
    clone_create_actions(rsc, data_set);

    for (; gIter != NULL; gIter = gIter->next) {
        gboolean child_promoting = FALSE;
        gboolean child_demoting = FALSE;
        resource_t *child_rsc = (resource_t *) gIter->data;

        crm_trace("Creating actions for %s", child_rsc->id);
        child_rsc->cmds->create_actions(child_rsc, data_set);
        master_update_pseudo_status(child_rsc, &child_demoting, &child_promoting);

        any_demoting = any_demoting || child_demoting;
        any_promoting = any_promoting || child_promoting;
        crm_trace("Created actions for %s: %d %d", child_rsc->id, child_promoting,
                    child_demoting);
    }

    /* promote */
    action = promote_action(rsc, NULL, !any_promoting);
    action_complete = custom_action(rsc, promoted_key(rsc),
                                    RSC_PROMOTED, NULL, !any_promoting, TRUE, data_set);

    action_complete->priority = INFINITY;
    update_action_flags(action, pe_action_pseudo);
    update_action_flags(action, pe_action_runnable);
    update_action_flags(action_complete, pe_action_pseudo);
    update_action_flags(action_complete, pe_action_runnable);

    if (clone_data->masters_allocated > 0) {
        update_action_flags(action, pe_action_runnable);
        update_action_flags(action_complete, pe_action_runnable);
    }

    child_promoting_constraints(clone_data, pe_order_optional,
                                rsc, NULL, last_promote_rsc, data_set);

    if (clone_data->promote_notify == NULL) {
        clone_data->promote_notify =
            create_notification_boundaries(rsc, RSC_PROMOTE, action, action_complete, data_set);
    }

    /* demote */
    action = demote_action(rsc, NULL, !any_demoting);
    action_complete = custom_action(rsc, demoted_key(rsc),
                                    RSC_DEMOTED, NULL, !any_demoting, TRUE, data_set);
    action_complete->priority = INFINITY;

    update_action_flags(action, pe_action_pseudo);
    update_action_flags(action, pe_action_runnable);
    update_action_flags(action_complete, pe_action_pseudo);
    update_action_flags(action_complete, pe_action_runnable);

    child_demoting_constraints(clone_data, pe_order_optional, rsc, NULL, last_demote_rsc, data_set);

    if (clone_data->demote_notify == NULL) {
        clone_data->demote_notify =
            create_notification_boundaries(rsc, RSC_DEMOTE, action, action_complete, data_set);

        if (clone_data->promote_notify) {
            /* If we ever wanted groups to have notifications we'd need to move this to native_internal_constraints() one day
             * Requires exposing *_notify
             */
            order_actions(clone_data->stop_notify->post_done, clone_data->promote_notify->pre,
                          pe_order_optional);
            order_actions(clone_data->start_notify->post_done, clone_data->promote_notify->pre,
                          pe_order_optional);
            order_actions(clone_data->demote_notify->post_done, clone_data->promote_notify->pre,
                          pe_order_optional);
            order_actions(clone_data->demote_notify->post_done, clone_data->start_notify->pre,
                          pe_order_optional);
            order_actions(clone_data->demote_notify->post_done, clone_data->stop_notify->pre,
                          pe_order_optional);
        }
    }

    /* restore the correct priority */

    gIter = rsc->children;
    for (; gIter != NULL; gIter = gIter->next) {
        resource_t *child_rsc = (resource_t *) gIter->data;

        child_rsc->priority = rsc->priority;
    }
}