pacemaker/pacemaker-crm_mon-tickets.diff
Tim Serong 1589a3e7c3 - Add provides to identify support level for tickets (bnc#752241)
- Resolve coverity RESOURCE_LEAK, REVERSE_INULL and UNREACHABLE defects 

- Tools: crm_simulate - Support to grant/revoke/standby/activate
  tickets from the new ticket state section (bnc#752241)

- Tools: Add crm_ticket to be profiled by valgrind
- Tools: crm_ticket - Display the tickets that are referenced in
  rsc_ticket constraints but have never been granted yet (bnc#752241)
- Tools: crm_mon - Support to display tickets (bnc#752242)

- PE: Move the ticket state section to
  "/cib/status/tickets/ticket_state" (bnc#752241)
- PE: Support to make tickets standby for relinquishing tickets
  gracefully (bnc#752241)
- Tools: Implement a new crm_ticket (bnc#752241)
- Tools: Update CLI regression tests for the new crm_ticket
- Tools: Add CLI regression tests for ticket standby state
- PE: Update regression tests for the new ticket state section
- PE: Support to make tickets standby for relinquishing tickets
  gracefully (regression tests)

- Tools: crm_ticket - Granting/revoking tickets need user to confirm
  unless "--force" option is used (bnc#752269)

- Tools: Implement the support of granting/revoking tickets for
  crm_simulate (bnc#752241)

OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/pacemaker?expand=0&rev=34
2012-04-23 11:15:16 +00:00

110 lines
3.5 KiB
Diff

commit 147890c8f9200960b3212a4a5acca4240f20451d
Author: Gao,Yan <ygao@suse.com>
Date: Sun Mar 25 16:27:38 2012 +0800
High: Tools: crm_mon - Support to display tickets (based on Yuusuke Iida's work)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 2c2192c..9922bfe 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -95,6 +95,7 @@ crm_diff_LDADD = $(COMMONLIBS)
crm_mon_SOURCES = crm_mon.c
crm_mon_LDADD = $(top_builddir)/lib/pengine/libpe_status.la \
+ $(top_builddir)/pengine/libpengine.la \
$(COMMONLIBS) $(SNMPLIBS) $(ESMTPLIBS) -llrm
# Arguments could be made that this should live in crm/pengine
diff --git a/tools/crm_mon.c b/tools/crm_mon.c
index b71e574..3f6ad37 100644
--- a/tools/crm_mon.c
+++ b/tools/crm_mon.c
@@ -43,6 +43,7 @@
#include <crm/cib.h>
#include <crm/pengine/status.h>
#include <../lib/pengine/unpack.h>
+#include <../pengine/pengine.h>
/* GMainLoop *mainloop = NULL; */
@@ -88,6 +89,7 @@ gboolean print_timing = FALSE;
gboolean print_nodes_attr = FALSE;
gboolean print_last_updated = TRUE;
gboolean print_last_change = TRUE;
+gboolean print_tickets = FALSE;
#define FILTER_STR {"shutdown", "terminate", "standby", "fail-count", \
"last-failure", "probe_complete", "#id", "#uname", \
@@ -300,7 +302,8 @@ static struct crm_option long_options[] = {
{"failcounts", 0, 0, 'f', "\tDisplay resource fail counts"},
{"operations", 0, 0, 'o', "\tDisplay resource operation history" },
{"timing-details", 0, 0, 't', "\tDisplay resource operation history with timing details" },
- {"show-node-attributes", 0, 0, 'A', "Display node attributes\n" },
+ {"show-node-attributes", 0, 0, 'A', "Display node attributes" },
+ {"tickets", 0, 0, 'c', "\t\tDisplay cluster tickets"},
{"-spacer-", 1, 0, '-', "\nAdditional Options:"},
{"interval", 1, 0, 'i', "\tUpdate frequency in seconds" },
@@ -400,6 +403,9 @@ main(int argc, char **argv)
case 'A':
print_nodes_attr = TRUE;
break;
+ case 'c':
+ print_tickets = TRUE;
+ break;
case 'p':
crm_free(pid_file);
pid_file = crm_strdup(optarg);
@@ -948,6 +954,38 @@ print_node_summary(pe_working_set_t * data_set, gboolean operations)
}
}
+static void
+print_ticket(gpointer name, gpointer value, gpointer data)
+{
+ ticket_t *ticket = (ticket_t *) value;
+
+ print_as(" %s\t%s%10s", ticket->id,
+ ticket->granted ? "granted":"revoked",
+ ticket->standby ? " [standby]":"");
+ if (ticket->last_granted > -1) {
+ print_as(" last-granted=");
+ print_date(ticket->last_granted);
+ }
+ print_as("\n");
+
+ return;
+}
+
+static void
+print_cluster_tickets(pe_working_set_t * data_set)
+{
+ xmlNode *cib_constraints = get_object_root(XML_CIB_TAG_CONSTRAINTS, data_set->input);
+
+ /* For recording the tickets that are referenced in rsc_ticket constraints
+ * but have never been granted yet. */
+ unpack_constraints(cib_constraints, data_set);
+
+ print_as("\nTickets:\n");
+ g_hash_table_foreach(data_set->tickets, print_ticket, NULL);
+
+ return;
+}
+
static char *
add_list_element(char *list, const char *value)
{
@@ -1209,6 +1247,11 @@ print_status(pe_working_set_t * data_set)
print_as("): %s\n", execra_code2string(val));
}
}
+
+ if (print_tickets) {
+ print_cluster_tickets(data_set);
+ }
+
#if CURSES_ENABLED
if (as_console) {
refresh();