dhodovsk / source-git / pacemaker

Forked from source-git/pacemaker 3 years ago
Clone

Blame tools/crmadmin.c

rpm-build 3ee90c
/*
rpm-build 3ee90c
 * Copyright 2004-2019 the Pacemaker project contributors
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * The version control history for this file may have further details.
rpm-build 3ee90c
 *
rpm-build 3ee90c
 * This source code is licensed under the GNU General Public License version 2
rpm-build 3ee90c
 * or later (GPLv2+) WITHOUT ANY WARRANTY.
rpm-build 3ee90c
 */
rpm-build 3ee90c
rpm-build 3ee90c
#include <crm_internal.h>
rpm-build 3ee90c
rpm-build 3ee90c
#include <sys/param.h>
rpm-build 3ee90c
rpm-build 3ee90c
#include <stdio.h>
rpm-build 3ee90c
#include <sys/types.h>
rpm-build 3ee90c
#include <unistd.h>
rpm-build 3ee90c
rpm-build 3ee90c
#include <stdlib.h>
rpm-build 3ee90c
#include <errno.h>
rpm-build 3ee90c
#include <fcntl.h>
rpm-build 3ee90c
#include <libgen.h>
rpm-build 3ee90c
rpm-build 3ee90c
#include <crm/crm.h>
rpm-build 3ee90c
#include <crm/msg_xml.h>
rpm-build 3ee90c
#include <crm/common/xml.h>
rpm-build 3ee90c
rpm-build 3ee90c
#include <crm/common/mainloop.h>
rpm-build 3ee90c
rpm-build 3ee90c
#include <crm/cib.h>
rpm-build 3ee90c
rpm-build 3ee90c
static int message_timer_id = -1;
rpm-build 3ee90c
static int message_timeout_ms = 30 * 1000;
rpm-build 3ee90c
rpm-build 3ee90c
static GMainLoop *mainloop = NULL;
rpm-build 3ee90c
static crm_ipc_t *crmd_channel = NULL;
rpm-build 3ee90c
static char *admin_uuid = NULL;
rpm-build 3ee90c
rpm-build 3ee90c
gboolean do_init(void);
rpm-build 3ee90c
int do_work(void);
rpm-build 3ee90c
void crmadmin_ipc_connection_destroy(gpointer user_data);
rpm-build 3ee90c
int admin_msg_callback(const char *buffer, ssize_t length, gpointer userdata);
rpm-build 3ee90c
int do_find_node_list(xmlNode * xml_node);
rpm-build 3ee90c
gboolean admin_message_timeout(gpointer data);
rpm-build 3ee90c
rpm-build 3ee90c
static gboolean BE_VERBOSE = FALSE;
rpm-build 3ee90c
static int expected_responses = 1;
rpm-build 3ee90c
static gboolean BASH_EXPORT = FALSE;
rpm-build 3ee90c
static gboolean DO_HEALTH = FALSE;
rpm-build 3ee90c
static gboolean DO_RESET = FALSE;
rpm-build 3ee90c
static gboolean DO_RESOURCE = FALSE;
rpm-build 3ee90c
static gboolean DO_ELECT_DC = FALSE;
rpm-build 3ee90c
static gboolean DO_WHOIS_DC = FALSE;
rpm-build 3ee90c
static gboolean DO_NODE_LIST = FALSE;
rpm-build 3ee90c
static gboolean BE_SILENT = FALSE;
rpm-build 3ee90c
static gboolean DO_RESOURCE_LIST = FALSE;
rpm-build 3ee90c
static const char *crmd_operation = NULL;
rpm-build 3ee90c
static char *dest_node = NULL;
rpm-build 3ee90c
static crm_exit_t exit_code = CRM_EX_OK;
rpm-build 3ee90c
static const char *sys_to = NULL;
rpm-build 3ee90c
rpm-build 3ee90c
/* *INDENT-OFF* */
rpm-build 3ee90c
static struct crm_option long_options[] = {
rpm-build 3ee90c
    /* Top-level Options */
rpm-build 3ee90c
    {"help",    0, 0, '?', "\tThis text"},
rpm-build 3ee90c
    {"version", 0, 0, '$', "\tVersion information"  },
rpm-build 3ee90c
    {"quiet",   0, 0, 'q', "\tDisplay only the essential query information"},
rpm-build 3ee90c
    {"verbose", 0, 0, 'V', "\tIncrease debug output"},
rpm-build 3ee90c
    
rpm-build 3ee90c
    {"-spacer-",	1, 0, '-', "\nCommands:"},
rpm-build 3ee90c
    /* daemon options */
rpm-build 3ee90c
    {"status",    1, 0, 'S', "Display the status of the specified node." },
rpm-build 3ee90c
    {"-spacer-",  1, 0, '-', "\n\tResult is the node's internal FSM state which can be useful for debugging\n"},
rpm-build 3ee90c
    {"dc_lookup", 0, 0, 'D', "Display the uname of the node co-ordinating the cluster."},
rpm-build 3ee90c
    {"-spacer-",  1, 0, '-', "\n\tThis is an internal detail and is rarely useful to administrators except when deciding on which node to examine the logs.\n"},
rpm-build 3ee90c
    {"nodes",     0, 0, 'N', "\tDisplay the uname of all member nodes"},
rpm-build 3ee90c
    {"election",  0, 0, 'E', "(Advanced) Start an election for the cluster co-ordinator"},
rpm-build 3ee90c
    {
rpm-build 3ee90c
        "kill",      1, 0, 'K',
rpm-build 3ee90c
        "(Advanced) Stop the controller (not the rest of the cluster stack) on specified node"
rpm-build 3ee90c
    },
rpm-build 3ee90c
    {"health",    0, 0, 'H', NULL, 1},
rpm-build 3ee90c
    
rpm-build 3ee90c
    {"-spacer-",	1, 0, '-', "\nAdditional Options:"},
rpm-build 3ee90c
    {XML_ATTR_TIMEOUT, 1, 0, 't', "Time (in milliseconds) to wait before declaring the operation failed"},
rpm-build 3ee90c
    {"bash-export", 0, 0, 'B', "Create Bash export entries of the form 'export uname=uuid'\n"},
rpm-build 3ee90c
rpm-build 3ee90c
    {"-spacer-",  1, 0, '-', "Notes:"},
rpm-build 3ee90c
    {"-spacer-",  1, 0, '-', " The -K and -E commands are rarely used and may be removed in future versions."},
rpm-build 3ee90c
rpm-build 3ee90c
    {0, 0, 0, 0}
rpm-build 3ee90c
};
rpm-build 3ee90c
/* *INDENT-ON* */
rpm-build 3ee90c
rpm-build 3ee90c
int
rpm-build 3ee90c
main(int argc, char **argv)
rpm-build 3ee90c
{
rpm-build 3ee90c
    int option_index = 0;
rpm-build 3ee90c
    int argerr = 0;
rpm-build 3ee90c
    int flag;
rpm-build 3ee90c
rpm-build 3ee90c
    crm_log_cli_init("crmadmin");
rpm-build 3ee90c
    crm_set_options(NULL, "command [options]", long_options,
rpm-build 3ee90c
                    "Development tool for performing some controller-specific commands."
rpm-build 3ee90c
                    "\n  Likely to be replaced by crm_node in the future");
rpm-build 3ee90c
    if (argc < 2) {
rpm-build 3ee90c
        crm_help('?', CRM_EX_USAGE);
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    while (1) {
rpm-build 3ee90c
        flag = crm_get_option(argc, argv, &option_index);
rpm-build 3ee90c
        if (flag == -1)
rpm-build 3ee90c
            break;
rpm-build 3ee90c
rpm-build 3ee90c
        switch (flag) {
rpm-build 3ee90c
            case 'V':
rpm-build 3ee90c
                BE_VERBOSE = TRUE;
rpm-build 3ee90c
                crm_bump_log_level(argc, argv);
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 't':
rpm-build 3ee90c
                message_timeout_ms = atoi(optarg);
rpm-build 3ee90c
                if (message_timeout_ms < 1) {
rpm-build 3ee90c
                    message_timeout_ms = 30 * 1000;
rpm-build 3ee90c
                }
rpm-build 3ee90c
                break;
rpm-build 3ee90c
rpm-build 3ee90c
            case '$':
rpm-build 3ee90c
            case '?':
rpm-build 3ee90c
                crm_help(flag, CRM_EX_OK);
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 'D':
rpm-build 3ee90c
                DO_WHOIS_DC = TRUE;
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 'B':
rpm-build 3ee90c
                BASH_EXPORT = TRUE;
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 'K':
rpm-build 3ee90c
                DO_RESET = TRUE;
rpm-build 3ee90c
                crm_trace("Option %c => %s", flag, optarg);
rpm-build 3ee90c
                dest_node = strdup(optarg);
rpm-build 3ee90c
                crmd_operation = CRM_OP_LOCAL_SHUTDOWN;
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 'q':
rpm-build 3ee90c
                BE_SILENT = TRUE;
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 'S':
rpm-build 3ee90c
                DO_HEALTH = TRUE;
rpm-build 3ee90c
                crm_trace("Option %c => %s", flag, optarg);
rpm-build 3ee90c
                dest_node = strdup(optarg);
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 'E':
rpm-build 3ee90c
                DO_ELECT_DC = TRUE;
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 'N':
rpm-build 3ee90c
                DO_NODE_LIST = TRUE;
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            case 'H':
rpm-build 3ee90c
                DO_HEALTH = TRUE;
rpm-build 3ee90c
                break;
rpm-build 3ee90c
            default:
rpm-build 3ee90c
                printf("Argument code 0%o (%c) is not (?yet?) supported\n", flag, flag);
rpm-build 3ee90c
                ++argerr;
rpm-build 3ee90c
                break;
rpm-build 3ee90c
        }
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    if (optind < argc) {
rpm-build 3ee90c
        printf("non-option ARGV-elements: ");
rpm-build 3ee90c
        while (optind < argc)
rpm-build 3ee90c
            printf("%s ", argv[optind++]);
rpm-build 3ee90c
        printf("\n");
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    if (optind > argc) {
rpm-build 3ee90c
        ++argerr;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    if (argerr) {
rpm-build 3ee90c
        crm_help('?', CRM_EX_USAGE);
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    if (do_init()) {
rpm-build 3ee90c
        int res = 0;
rpm-build 3ee90c
rpm-build 3ee90c
        res = do_work();
rpm-build 3ee90c
        if (res > 0) {
rpm-build 3ee90c
            /* wait for the reply by creating a mainloop and running it until
rpm-build 3ee90c
             * the callbacks are invoked...
rpm-build 3ee90c
             */
rpm-build 3ee90c
            mainloop = g_main_loop_new(NULL, FALSE);
rpm-build 3ee90c
            crm_trace("Waiting for %d replies from the local CRM", expected_responses);
rpm-build 3ee90c
rpm-build 3ee90c
            message_timer_id = g_timeout_add(message_timeout_ms, admin_message_timeout, NULL);
rpm-build 3ee90c
rpm-build 3ee90c
            g_main_loop_run(mainloop);
rpm-build 3ee90c
rpm-build 3ee90c
        } else if (res < 0) {
rpm-build 3ee90c
            crm_err("No message to send");
rpm-build 3ee90c
            exit_code = CRM_EX_ERROR;
rpm-build 3ee90c
        }
rpm-build 3ee90c
    } else {
rpm-build 3ee90c
        crm_warn("Init failed, could not perform requested operations");
rpm-build 3ee90c
        exit_code = CRM_EX_UNAVAILABLE;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    crm_trace("%s exiting normally", crm_system_name);
rpm-build 3ee90c
    return exit_code;
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
int
rpm-build 3ee90c
do_work(void)
rpm-build 3ee90c
{
rpm-build 3ee90c
    int ret = 1;
rpm-build 3ee90c
rpm-build 3ee90c
    /* construct the request */
rpm-build 3ee90c
    xmlNode *msg_data = NULL;
rpm-build 3ee90c
    gboolean all_is_good = TRUE;
rpm-build 3ee90c
rpm-build 3ee90c
    if (DO_HEALTH == TRUE) {
rpm-build 3ee90c
        crm_trace("Querying the system");
rpm-build 3ee90c
rpm-build 3ee90c
        sys_to = CRM_SYSTEM_DC;
rpm-build 3ee90c
rpm-build 3ee90c
        if (dest_node != NULL) {
rpm-build 3ee90c
            sys_to = CRM_SYSTEM_CRMD;
rpm-build 3ee90c
            crmd_operation = CRM_OP_PING;
rpm-build 3ee90c
rpm-build 3ee90c
            if (BE_VERBOSE) {
rpm-build 3ee90c
                expected_responses = 1;
rpm-build 3ee90c
            }
rpm-build 3ee90c
rpm-build 3ee90c
        } else {
rpm-build 3ee90c
            crm_info("Cluster-wide health not available yet");
rpm-build 3ee90c
            all_is_good = FALSE;
rpm-build 3ee90c
        }
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (DO_ELECT_DC) {
rpm-build 3ee90c
        /* tell the local node to initiate an election */
rpm-build 3ee90c
rpm-build 3ee90c
        dest_node = NULL;
rpm-build 3ee90c
        sys_to = CRM_SYSTEM_CRMD;
rpm-build 3ee90c
        crmd_operation = CRM_OP_VOTE;
rpm-build 3ee90c
        ret = 0;                /* no return message */
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (DO_WHOIS_DC) {
rpm-build 3ee90c
        dest_node = NULL;
rpm-build 3ee90c
        sys_to = CRM_SYSTEM_DC;
rpm-build 3ee90c
        crmd_operation = CRM_OP_PING;
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (DO_NODE_LIST) {
rpm-build 3ee90c
rpm-build 3ee90c
        cib_t *the_cib = cib_new();
rpm-build 3ee90c
        xmlNode *output = NULL;
rpm-build 3ee90c
rpm-build 3ee90c
        int rc = the_cib->cmds->signon(the_cib, crm_system_name, cib_command);
rpm-build 3ee90c
rpm-build 3ee90c
        if (rc != pcmk_ok) {
rpm-build 3ee90c
            return -1;
rpm-build 3ee90c
        }
rpm-build 3ee90c
rpm-build 3ee90c
        rc = the_cib->cmds->query(the_cib, NULL, &output, cib_scope_local | cib_sync_call);
rpm-build 3ee90c
        if(rc == pcmk_ok) {
rpm-build 3ee90c
            do_find_node_list(output);
rpm-build 3ee90c
rpm-build 3ee90c
            free_xml(output);
rpm-build 3ee90c
        }
rpm-build 3ee90c
        the_cib->cmds->signoff(the_cib);
rpm-build 3ee90c
        crm_exit(crm_errno2exit(rc));
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (DO_RESET) {
rpm-build 3ee90c
        /* tell dest_node to initiate the shutdown procedure
rpm-build 3ee90c
         *
rpm-build 3ee90c
         * if dest_node is NULL, the request will be sent to the
rpm-build 3ee90c
         *   local node
rpm-build 3ee90c
         */
rpm-build 3ee90c
        sys_to = CRM_SYSTEM_CRMD;
rpm-build 3ee90c
        ret = 0;                /* no return message */
rpm-build 3ee90c
rpm-build 3ee90c
    } else {
rpm-build 3ee90c
        crm_err("Unknown options");
rpm-build 3ee90c
        all_is_good = FALSE;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    if (all_is_good == FALSE) {
rpm-build 3ee90c
        crm_err("Creation of request failed.  No message to send");
rpm-build 3ee90c
        return -1;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
/* send it */
rpm-build 3ee90c
    if (crmd_channel == NULL) {
rpm-build 3ee90c
        crm_err("The IPC connection is not valid, cannot send anything");
rpm-build 3ee90c
        return -1;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    if (sys_to == NULL) {
rpm-build 3ee90c
        if (dest_node != NULL) {
rpm-build 3ee90c
            sys_to = CRM_SYSTEM_CRMD;
rpm-build 3ee90c
        } else {
rpm-build 3ee90c
            sys_to = CRM_SYSTEM_DC;
rpm-build 3ee90c
        }
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    {
rpm-build 3ee90c
        xmlNode *cmd = create_request(crmd_operation, msg_data, dest_node, sys_to,
rpm-build 3ee90c
                                      crm_system_name, admin_uuid);
rpm-build 3ee90c
rpm-build 3ee90c
        crm_ipc_send(crmd_channel, cmd, 0, 0, NULL);
rpm-build 3ee90c
        free_xml(cmd);
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    return ret;
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
void
rpm-build 3ee90c
crmadmin_ipc_connection_destroy(gpointer user_data)
rpm-build 3ee90c
{
rpm-build 3ee90c
    crm_err("Connection to controller was terminated");
rpm-build 3ee90c
    if (mainloop) {
rpm-build 3ee90c
        g_main_loop_quit(mainloop);
rpm-build 3ee90c
    } else {
rpm-build 3ee90c
        crm_exit(CRM_EX_DISCONNECT);
rpm-build 3ee90c
    }
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
struct ipc_client_callbacks crm_callbacks = {
rpm-build 3ee90c
    .dispatch = admin_msg_callback,
rpm-build 3ee90c
    .destroy = crmadmin_ipc_connection_destroy
rpm-build 3ee90c
};
rpm-build 3ee90c
rpm-build 3ee90c
gboolean
rpm-build 3ee90c
do_init(void)
rpm-build 3ee90c
{
rpm-build 3ee90c
    mainloop_io_t *source =
rpm-build 3ee90c
        mainloop_add_ipc_client(CRM_SYSTEM_CRMD, G_PRIORITY_DEFAULT, 0, NULL, &crm_callbacks);
rpm-build 3ee90c
rpm-build 3ee90c
    admin_uuid = crm_getpid_s();
rpm-build 3ee90c
rpm-build 3ee90c
    crmd_channel = mainloop_get_ipc_client(source);
rpm-build 3ee90c
rpm-build 3ee90c
    if (DO_RESOURCE || DO_RESOURCE_LIST || DO_NODE_LIST) {
rpm-build 3ee90c
        return TRUE;
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (crmd_channel != NULL) {
rpm-build 3ee90c
        xmlNode *xml = create_hello_message(admin_uuid, crm_system_name, "0", "1");
rpm-build 3ee90c
rpm-build 3ee90c
        crm_ipc_send(crmd_channel, xml, 0, 0, NULL);
rpm-build 3ee90c
        return TRUE;
rpm-build 3ee90c
    }
rpm-build 3ee90c
    return FALSE;
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
static bool
rpm-build 3ee90c
validate_crm_message(xmlNode * msg, const char *sys, const char *uuid, const char *msg_type)
rpm-build 3ee90c
{
rpm-build 3ee90c
    const char *type = NULL;
rpm-build 3ee90c
    const char *crm_msg_reference = NULL;
rpm-build 3ee90c
rpm-build 3ee90c
    if (msg == NULL) {
rpm-build 3ee90c
        return FALSE;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    type = crm_element_value(msg, F_CRM_MSG_TYPE);
rpm-build 3ee90c
    crm_msg_reference = crm_element_value(msg, XML_ATTR_REFERENCE);
rpm-build 3ee90c
rpm-build 3ee90c
    if (type == NULL) {
rpm-build 3ee90c
        crm_info("No message type defined.");
rpm-build 3ee90c
        return FALSE;
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (msg_type != NULL && strcasecmp(msg_type, type) != 0) {
rpm-build 3ee90c
        crm_info("Expecting a (%s) message but received a (%s).", msg_type, type);
rpm-build 3ee90c
        return FALSE;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    if (crm_msg_reference == NULL) {
rpm-build 3ee90c
        crm_info("No message crm_msg_reference defined.");
rpm-build 3ee90c
        return FALSE;
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    return TRUE;
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
int
rpm-build 3ee90c
admin_msg_callback(const char *buffer, ssize_t length, gpointer userdata)
rpm-build 3ee90c
{
rpm-build 3ee90c
    static int received_responses = 0;
rpm-build 3ee90c
    xmlNode *xml = string2xml(buffer);
rpm-build 3ee90c
rpm-build 3ee90c
    received_responses++;
rpm-build 3ee90c
    g_source_remove(message_timer_id);
rpm-build 3ee90c
rpm-build 3ee90c
    crm_log_xml_trace(xml, "ipc");
rpm-build 3ee90c
rpm-build 3ee90c
    if (xml == NULL) {
rpm-build 3ee90c
        crm_info("XML in IPC message was not valid... " "discarding.");
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (validate_crm_message(xml, crm_system_name, admin_uuid, XML_ATTR_RESPONSE) == FALSE) {
rpm-build 3ee90c
        crm_trace("Message was not a CRM response. Discarding.");
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (DO_HEALTH) {
rpm-build 3ee90c
        xmlNode *data = get_message_xml(xml, F_CRM_DATA);
rpm-build 3ee90c
        const char *state = crm_element_value(data, XML_PING_ATTR_CRMDSTATE);
rpm-build 3ee90c
rpm-build 3ee90c
        printf("Status of %s@%s: %s (%s)\n",
rpm-build 3ee90c
               crm_element_value(data, XML_PING_ATTR_SYSFROM),
rpm-build 3ee90c
               crm_element_value(xml, F_CRM_HOST_FROM),
rpm-build 3ee90c
               state, crm_element_value(data, XML_PING_ATTR_STATUS));
rpm-build 3ee90c
rpm-build 3ee90c
        if (BE_SILENT && state != NULL) {
rpm-build 3ee90c
            fprintf(stderr, "%s\n", state);
rpm-build 3ee90c
        }
rpm-build 3ee90c
rpm-build 3ee90c
    } else if (DO_WHOIS_DC) {
rpm-build 3ee90c
        const char *dc = crm_element_value(xml, F_CRM_HOST_FROM);
rpm-build 3ee90c
rpm-build 3ee90c
        printf("Designated Controller is: %s\n", dc);
rpm-build 3ee90c
        if (BE_SILENT && dc != NULL) {
rpm-build 3ee90c
            fprintf(stderr, "%s\n", dc);
rpm-build 3ee90c
        }
rpm-build 3ee90c
        crm_exit(CRM_EX_OK);
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    free_xml(xml);
rpm-build 3ee90c
rpm-build 3ee90c
    if (received_responses >= expected_responses) {
rpm-build 3ee90c
        crm_trace("Received expected number (%d) of replies, exiting normally",
rpm-build 3ee90c
                   expected_responses);
rpm-build 3ee90c
        crm_exit(CRM_EX_OK);
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    message_timer_id = g_timeout_add(message_timeout_ms, admin_message_timeout, NULL);
rpm-build 3ee90c
    return 0;
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
gboolean
rpm-build 3ee90c
admin_message_timeout(gpointer data)
rpm-build 3ee90c
{
rpm-build 3ee90c
    fprintf(stderr, "No messages received in %d seconds.. aborting\n",
rpm-build 3ee90c
            (int)message_timeout_ms / 1000);
rpm-build 3ee90c
    crm_err("No messages received in %d seconds", (int)message_timeout_ms / 1000);
rpm-build 3ee90c
    exit_code = CRM_EX_TIMEOUT;
rpm-build 3ee90c
    g_main_loop_quit(mainloop);
rpm-build 3ee90c
    return FALSE;
rpm-build 3ee90c
}
rpm-build 3ee90c
rpm-build 3ee90c
int
rpm-build 3ee90c
do_find_node_list(xmlNode * xml_node)
rpm-build 3ee90c
{
rpm-build 3ee90c
    int found = 0;
rpm-build 3ee90c
    xmlNode *node = NULL;
rpm-build 3ee90c
    xmlNode *nodes = get_object_root(XML_CIB_TAG_NODES, xml_node);
rpm-build 3ee90c
rpm-build 3ee90c
    for (node = __xml_first_child_element(nodes); node != NULL;
rpm-build 3ee90c
         node = __xml_next_element(node)) {
rpm-build 3ee90c
rpm-build 3ee90c
        if (crm_str_eq((const char *)node->name, XML_CIB_TAG_NODE, TRUE)) {
rpm-build 3ee90c
rpm-build 3ee90c
            if (BASH_EXPORT) {
rpm-build 3ee90c
                printf("export %s=%s\n",
rpm-build 3ee90c
                       crm_element_value(node, XML_ATTR_UNAME),
rpm-build 3ee90c
                       crm_element_value(node, XML_ATTR_ID));
rpm-build 3ee90c
            } else {
rpm-build 3ee90c
                printf("%s node: %s (%s)\n",
rpm-build 3ee90c
                       crm_element_value(node, XML_ATTR_TYPE),
rpm-build 3ee90c
                       crm_element_value(node, XML_ATTR_UNAME),
rpm-build 3ee90c
                       crm_element_value(node, XML_ATTR_ID));
rpm-build 3ee90c
            }
rpm-build 3ee90c
            found++;
rpm-build 3ee90c
        }
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    if (found == 0) {
rpm-build 3ee90c
        printf("NO nodes configured\n");
rpm-build 3ee90c
    }
rpm-build 3ee90c
rpm-build 3ee90c
    return found;
rpm-build 3ee90c
}