void
send_stonith_update(stonith_ops_t * op)
{
	enum cib_errors rc = cib_ok;
	const char *target = op->node_name;
	const char *uuid   = op->node_uuid;
	
	/* zero out the node-status & remove all LRM status info */
	xmlNode *node_state = create_xml_node(NULL, XML_CIB_TAG_STATE);
	
	CRM_CHECK(op->node_name != NULL, return);
	CRM_CHECK(op->node_uuid != NULL, return);
	
	crm_xml_add(node_state, XML_ATTR_UUID,  uuid);
	crm_xml_add(node_state, XML_ATTR_UNAME, target);
	crm_xml_add(node_state, XML_CIB_ATTR_HASTATE,   DEADSTATUS);
	crm_xml_add(node_state, XML_CIB_ATTR_INCCM,     XML_BOOLEAN_NO);
	crm_xml_add(node_state, XML_CIB_ATTR_CRMDSTATE, OFFLINESTATUS);
	crm_xml_add(node_state, XML_CIB_ATTR_JOINSTATE, CRMD_JOINSTATE_DOWN);
	crm_xml_add(node_state, XML_CIB_ATTR_EXPSTATE,  CRMD_JOINSTATE_DOWN);
	crm_xml_add(node_state, XML_ATTR_ORIGIN,   __FUNCTION__);
	
	rc = fsa_cib_conn->cmds->update(
		fsa_cib_conn, XML_CIB_TAG_STATUS, node_state,
		cib_quorum_override|cib_scope_local|cib_can_create);	
	
	if(rc < cib_ok) {
		crm_err("CIB update failed: %s", cib_error2string(rc));
		abort_transition(
			INFINITY, tg_shutdown, "CIB update failed", node_state);
		
	} else {
		/* delay processing the trigger until the update completes */
	    add_cib_op_callback(fsa_cib_conn, rc, FALSE, crm_strdup(target), cib_fencing_updated);
	}

	erase_status_tag(op->node_name, XML_CIB_TAG_LRM, cib_scope_local);
	erase_status_tag(op->node_name, XML_TAG_TRANSIENT_NODEATTRS, cib_scope_local);
	
	free_xml(node_state);

#if 0
	/* Make sure the membership cache is accurate */ 
	crm_update_peer(0, 0, 0, -1, 0, uuid, target, NULL, CRM_NODE_LOST);
#endif
	
	return;
}
Exemplo n.º 2
0
crm_node_t *crm_update_ais_node(xmlNode *member, long long seq)
{
    const char *id_s = crm_element_value(member, "id");
    const char *addr = crm_element_value(member, "addr");
    const char *uname = crm_element_value(member, "uname");
    const char *state = crm_element_value(member, "state");
    const char *born_s = crm_element_value(member, "born");
    const char *seen_s = crm_element_value(member, "seen");
    const char *votes_s = crm_element_value(member, "votes");
    const char *procs_s = crm_element_value(member, "processes");

    int votes = crm_int_helper(votes_s, NULL);
    unsigned int id = crm_int_helper(id_s, NULL);
    unsigned int procs = crm_int_helper(procs_s, NULL);

    /* TODO: These values will contain garbage if version < 0.7.1 */
    uint64_t born = crm_int_helper(born_s, NULL);
    uint64_t seen = crm_int_helper(seen_s, NULL);

    return crm_update_peer(id, born, seen, votes, procs, uname, uname, addr, state);
}
Exemplo n.º 3
0
void
send_stonith_update(crm_action_t * action, const char *target, const char *uuid)
{
    enum cib_errors rc = cib_ok;

    /* zero out the node-status & remove all LRM status info */
    xmlNode *node_state = create_xml_node(NULL, XML_CIB_TAG_STATE);

    CRM_CHECK(target != NULL, return);
    CRM_CHECK(uuid != NULL, return);

    crm_xml_add(node_state, XML_ATTR_UUID, uuid);
    crm_xml_add(node_state, XML_ATTR_UNAME, target);
    crm_xml_add(node_state, XML_CIB_ATTR_HASTATE, DEADSTATUS);
    crm_xml_add(node_state, XML_CIB_ATTR_INCCM, XML_BOOLEAN_NO);
    crm_xml_add(node_state, XML_CIB_ATTR_CRMDSTATE, OFFLINESTATUS);
    crm_xml_add(node_state, XML_CIB_ATTR_JOINSTATE, CRMD_JOINSTATE_DOWN);
    crm_xml_add(node_state, XML_CIB_ATTR_EXPSTATE, CRMD_JOINSTATE_DOWN);
    crm_xml_add(node_state, XML_ATTR_ORIGIN, __FUNCTION__);

    rc = fsa_cib_conn->cmds->update(fsa_cib_conn, XML_CIB_TAG_STATUS, node_state,
                                    cib_quorum_override | cib_scope_local | cib_can_create);

    /* Delay processing the trigger until the update completes */
    crm_info("Sending fencing update %d for %s", rc, target);
    add_cib_op_callback(fsa_cib_conn, rc, FALSE, crm_strdup(target), cib_fencing_updated);

    /* Make sure it sticks */
    /* fsa_cib_conn->cmds->bump_epoch(fsa_cib_conn, cib_quorum_override|cib_scope_local);    */

    erase_status_tag(target, XML_CIB_TAG_LRM, cib_scope_local);
    erase_status_tag(target, XML_TAG_TRANSIENT_NODEATTRS, cib_scope_local);

    free_xml(node_state);

    /* Make sure the membership cache is accurate */
    crm_update_peer(0, 0, 0, -1, crm_proc_none, uuid, target, NULL, CRM_NODE_LOST);

    return;
}
Exemplo n.º 4
0
crm_node_t *crm_update_ccm_node(
    const oc_ev_membership_t *oc, int offset, const char *state, uint64_t seq)
{
    crm_node_t *node = NULL;
    const char *uuid = NULL;
    CRM_CHECK(oc->m_array[offset].node_uname != NULL, return NULL);
    uuid = get_uuid(oc->m_array[offset].node_uname);
    node = crm_update_peer(oc->m_array[offset].node_id,
			   oc->m_array[offset].node_born_on, seq, -1, 0,
			   uuid, oc->m_array[offset].node_uname, NULL, state);

    if(safe_str_eq(CRM_NODE_ACTIVE, state)) {
	/* Heartbeat doesn't send status notifications for nodes that were already part of the cluster */
	crm_update_peer_proc(
	    oc->m_array[offset].node_uname, crm_proc_ais, ONLINESTATUS);

	/* Nor does it send status notifications for processes that were already active */
	crm_update_peer_proc(
	   oc->m_array[offset].node_uname, crm_proc_crmd, ONLINESTATUS);
    }
    return node;
}
Exemplo n.º 5
0
crm_node_t *
crm_get_peer(unsigned int id, const char *uname)
{
    crm_node_t *node = NULL;
    CRM_ASSERT(id > 0 || uname != NULL);

    crm_peer_init();

    if (uname != NULL) {
        node = g_hash_table_lookup(crm_peer_cache, uname);
    }

    if (node == NULL && id > 0) {
        node = g_hash_table_lookup(crm_peer_id_cache, GUINT_TO_POINTER(id));

        if (node && node->uname && uname) {
            crm_crit("Node %s and %s share the same cluster node id '%u'!", node->uname, uname, id);
            
            /* NOTE: Calling crm_new_peer() means the entry in 
             * crm_peer_id_cache will point to the new entity
             */

            /* TODO: Replace the old uname instead? */
            node = crm_new_peer(id, uname);
            CRM_ASSERT(node->uname != NULL);
        }
    }

    if (node == NULL) {
        node = crm_new_peer(id, uname);
        if(uname) {
            const char *uuid = get_uuid(uname);
            crm_update_peer(__FUNCTION__, 0, 0, 0, -1, 0, uuid, uname, NULL, NULL);
        }
    }

    CRM_ASSERT(node);

    if (node && uname && node->uname == NULL) {
        node->uname = strdup(uname);
        crm_info("Node %u is now known as %s", id, uname);
        g_hash_table_insert(crm_peer_cache, node->uname, node);
        if (crm_status_callback) {
            crm_status_callback(crm_status_uname, node, NULL);
        }
    }

    if (node && node->uname && node->uuid == NULL) {
        const char *uuid = get_node_uuid(id, node->uname);

        if (node->uuid) {
            crm_info("Node %u has uuid %s", id, node->uuid);
        } else if (uuid) {
            node->uuid = strdup(uuid);
        }
    }

    if (node && id > 0 && id != node->id) {
        g_hash_table_remove(crm_peer_id_cache, GUINT_TO_POINTER(node->id));
        g_hash_table_insert(crm_peer_id_cache, GUINT_TO_POINTER(id), node);
        node->id = id;
        crm_info("Node %s now has id: %u", crm_str(uname), id);
    }

    return node;
}