| 487 | } |
| 488 | |
| 489 | int |
| 490 | admin_msg_callback(const char *buffer, ssize_t length, gpointer userdata) |
| 491 | { |
| 492 | static int received_responses = 0; |
| 493 | const char *result = NULL; |
| 494 | xmlNode *xml = string2xml(buffer); |
| 495 | |
| 496 | received_responses++; |
| 497 | g_source_remove(message_timer_id); |
| 498 | |
| 499 | crm_log_xml_trace(xml, "ipc"); |
| 500 | |
| 501 | if (xml == NULL) { |
| 502 | crm_info("XML in IPC message was not valid... " "discarding."); |
| 503 | |
| 504 | } else if (validate_crm_message(xml, crm_system_name, admin_uuid, XML_ATTR_RESPONSE) == FALSE) { |
| 505 | crm_trace("Message was not a CRM response. Discarding."); |
| 506 | |
| 507 | } else { |
| 508 | result = crm_element_value(xml, XML_ATTR_RESULT); |
| 509 | if (result == NULL || strcasecmp(result, "ok") == 0) { |
| 510 | result = "pass"; |
| 511 | |
| 512 | } else { |
| 513 | result = "fail"; |
| 514 | } |
| 515 | |
| 516 | if (DO_HEALTH) { |
| 517 | xmlNode *data = get_message_xml(xml, F_CRM_DATA); |
| 518 | const char *state = crm_element_value(data, "crmd_state"); |
| 519 | |
| 520 | printf("Status of %s@%s: %s (%s)\n", |
| 521 | crm_element_value(data, XML_PING_ATTR_SYSFROM), |
| 522 | crm_element_value(xml, F_CRM_HOST_FROM), |
| 523 | state, crm_element_value(data, XML_PING_ATTR_STATUS)); |
| 524 | |
| 525 | if (BE_SILENT && state != NULL) { |
| 526 | fprintf(stderr, "%s\n", state); |
| 527 | } |
| 528 | |
| 529 | } else if (DO_WHOIS_DC) { |
| 530 | const char *dc = crm_element_value(xml, F_CRM_HOST_FROM); |
| 531 | |
| 532 | printf("Designated Controller is: %s\n", dc); |
| 533 | if (BE_SILENT && dc != NULL) { |
| 534 | fprintf(stderr, "%s\n", dc); |
| 535 | } |
| 536 | crm_exit(0); |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | free_xml(xml); |
| 541 | |
| 542 | if (received_responses >= expected_responses) { |
| 543 | crm_trace("Received expected number (%d) of messages from Heartbeat." |
| 544 | " Exiting normally.", expected_responses); |
| 545 | crm_exit(0); |
| 546 | } |
nothing calls this directly
no test coverage detected