summaryrefslogtreecommitdiffstats
path: root/tools/crm_ticket.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/crm_ticket.c74
1 files changed, 39 insertions, 35 deletions
diff --git a/tools/crm_ticket.c b/tools/crm_ticket.c
index c451e8a..d95b581 100644
--- a/tools/crm_ticket.c
+++ b/tools/crm_ticket.c
@@ -31,6 +31,7 @@
#include <crm/cib/internal.h>
#include <crm/pengine/rules.h>
#include <crm/pengine/status.h>
+#include <crm/pengine/internal.h>
#include <pacemaker-internal.h>
@@ -253,10 +254,10 @@ static GOptionEntry deprecated_entries[] = {
{ NULL }
};
-static pe_ticket_t *
-find_ticket(gchar *ticket_id, pe_working_set_t * data_set)
+static pcmk_ticket_t *
+find_ticket(gchar *ticket_id, pcmk_scheduler_t *scheduler)
{
- return g_hash_table_lookup(data_set->tickets, ticket_id);
+ return g_hash_table_lookup(scheduler->tickets, ticket_id);
}
static void
@@ -275,7 +276,7 @@ print_date(time_t time)
}
static void
-print_ticket(pe_ticket_t * ticket, bool raw, bool details)
+print_ticket(pcmk_ticket_t *ticket, bool raw, bool details)
{
if (raw) {
fprintf(stdout, "%s\n", ticket->id);
@@ -325,12 +326,12 @@ print_ticket(pe_ticket_t * ticket, bool raw, bool details)
}
static void
-print_ticket_list(pe_working_set_t * data_set, bool raw, bool details)
+print_ticket_list(pcmk_scheduler_t *scheduler, bool raw, bool details)
{
GHashTableIter iter;
- pe_ticket_t *ticket = NULL;
+ pcmk_ticket_t *ticket = NULL;
- g_hash_table_iter_init(&iter, data_set->tickets);
+ g_hash_table_iter_init(&iter, scheduler->tickets);
while (g_hash_table_iter_next(&iter, NULL, (void **)&ticket)) {
print_ticket(ticket, raw, details);
@@ -369,7 +370,7 @@ find_ticket_state(cib_t * the_cib, gchar *ticket_id, xmlNode ** ticket_state_xml
}
crm_log_xml_debug(xml_search, "Match");
- if (xml_has_children(xml_search)) {
+ if (xml_search->children != NULL) {
if (ticket_id) {
fprintf(stdout, "Multiple ticket_states match ticket_id=%s\n", ticket_id);
}
@@ -439,7 +440,7 @@ dump_ticket_xml(cib_t * the_cib, gchar *ticket_id)
char *state_xml_str = NULL;
state_xml_str = dump_xml_formatted(state_xml);
- fprintf(stdout, "\n%s", pcmk__s(state_xml_str, "<null>\n"));
+ fprintf(stdout, "\n%s", state_xml_str);
free_xml(state_xml);
free(state_xml_str);
}
@@ -461,8 +462,7 @@ dump_constraints(cib_t * the_cib, gchar *ticket_id)
}
cons_xml_str = dump_xml_formatted(cons_xml);
- fprintf(stdout, "Constraints XML:\n\n%s",
- pcmk__s(cons_xml_str, "<null>\n"));
+ fprintf(stdout, "Constraints XML:\n\n%s", cons_xml_str);
free_xml(cons_xml);
free(cons_xml_str);
@@ -471,14 +471,14 @@ dump_constraints(cib_t * the_cib, gchar *ticket_id)
static int
get_ticket_state_attr(gchar *ticket_id, const char *attr_name, const char **attr_value,
- pe_working_set_t * data_set)
+ pcmk_scheduler_t *scheduler)
{
- pe_ticket_t *ticket = NULL;
+ pcmk_ticket_t *ticket = NULL;
CRM_ASSERT(attr_value != NULL);
*attr_value = NULL;
- ticket = g_hash_table_lookup(data_set->tickets, ticket_id);
+ ticket = g_hash_table_lookup(scheduler->tickets, ticket_id);
if (ticket == NULL) {
return ENXIO;
}
@@ -564,7 +564,7 @@ allow_modification(gchar *ticket_id)
}
static int
-modify_ticket_state(gchar * ticket_id, cib_t * cib, pe_working_set_t * data_set)
+modify_ticket_state(gchar *ticket_id, cib_t *cib, pcmk_scheduler_t *scheduler)
{
int rc = pcmk_rc_ok;
xmlNode *xml_top = NULL;
@@ -577,7 +577,7 @@ modify_ticket_state(gchar * ticket_id, cib_t * cib, pe_working_set_t * data_set)
char *key = NULL;
char *value = NULL;
- pe_ticket_t *ticket = NULL;
+ pcmk_ticket_t *ticket = NULL;
rc = find_ticket_state(cib, ticket_id, &ticket_state_xml);
if (rc == pcmk_rc_ok) {
@@ -605,7 +605,7 @@ modify_ticket_state(gchar * ticket_id, cib_t * cib, pe_working_set_t * data_set)
xml_remove_prop(ticket_state_xml, key);
}
- ticket = find_ticket(ticket_id, data_set);
+ ticket = find_ticket(ticket_id, scheduler);
g_hash_table_iter_init(&hash_iter, attr_set);
while (g_hash_table_iter_next(&hash_iter, (gpointer *) & key, (gpointer *) & value)) {
@@ -719,7 +719,7 @@ build_arg_context(pcmk__common_args_t *args) {
int
main(int argc, char **argv)
{
- pe_working_set_t *data_set = NULL;
+ pcmk_scheduler_t *scheduler = NULL;
xmlNode *cib_xml_copy = NULL;
cib_t *cib_conn = NULL;
@@ -751,13 +751,16 @@ main(int argc, char **argv)
pcmk__cli_help('v');
}
- data_set = pe_new_working_set();
- if (data_set == NULL) {
- crm_perror(LOG_CRIT, "Could not allocate working set");
- exit_code = CRM_EX_OSERR;
+ scheduler = pe_new_working_set();
+ if (scheduler == NULL) {
+ rc = errno;
+ exit_code = pcmk_rc2exitc(rc);
+ g_set_error(&error, PCMK__EXITC_ERROR, exit_code,
+ "Could not allocate scheduler data: %s", pcmk_rc_str(rc));
goto done;
}
- pe__set_working_set_flags(data_set, pe_flag_no_counts|pe_flag_no_compat);
+ pe__set_working_set_flags(scheduler,
+ pcmk_sched_no_counts|pcmk_sched_no_compat);
cib_conn = cib_new();
if (cib_conn == NULL) {
@@ -798,14 +801,14 @@ main(int argc, char **argv)
goto done;
}
- data_set->input = cib_xml_copy;
- data_set->now = crm_time_new(NULL);
+ scheduler->input = cib_xml_copy;
+ scheduler->now = crm_time_new(NULL);
- cluster_status(data_set);
+ cluster_status(scheduler);
/* For recording the tickets that are referenced in rsc_ticket constraints
* but have never been granted yet. */
- pcmk__unpack_constraints(data_set);
+ pcmk__unpack_constraints(scheduler);
if (options.ticket_cmd == 'l' || options.ticket_cmd == 'L' || options.ticket_cmd == 'w') {
bool raw = false;
@@ -818,7 +821,7 @@ main(int argc, char **argv)
}
if (options.ticket_id) {
- pe_ticket_t *ticket = find_ticket(options.ticket_id, data_set);
+ pcmk_ticket_t *ticket = find_ticket(options.ticket_id, scheduler);
if (ticket == NULL) {
exit_code = CRM_EX_NOSUCH;
@@ -829,7 +832,7 @@ main(int argc, char **argv)
print_ticket(ticket, raw, details);
} else {
- print_ticket_list(data_set, raw, details);
+ print_ticket_list(scheduler, raw, details);
}
} else if (options.ticket_cmd == 'q') {
@@ -860,7 +863,8 @@ main(int argc, char **argv)
goto done;
}
- rc = get_ticket_state_attr(options.ticket_id, options.get_attr_name, &value, data_set);
+ rc = get_ticket_state_attr(options.ticket_id, options.get_attr_name,
+ &value, scheduler);
if (rc == pcmk_rc_ok) {
fprintf(stdout, "%s\n", value);
} else if (rc == ENXIO && options.attr_default) {
@@ -878,9 +882,9 @@ main(int argc, char **argv)
}
if (options.force == FALSE) {
- pe_ticket_t *ticket = NULL;
+ pcmk_ticket_t *ticket = NULL;
- ticket = find_ticket(options.ticket_id, data_set);
+ ticket = find_ticket(options.ticket_id, scheduler);
if (ticket == NULL) {
exit_code = CRM_EX_NOSUCH;
g_set_error(&error, PCMK__EXITC_ERROR, exit_code,
@@ -934,7 +938,7 @@ main(int argc, char **argv)
goto done;
}
- rc = modify_ticket_state(options.ticket_id, cib_conn, data_set);
+ rc = modify_ticket_state(options.ticket_id, cib_conn, scheduler);
exit_code = pcmk_rc2exitc(rc);
if (rc != pcmk_rc_ok) {
@@ -985,8 +989,8 @@ main(int argc, char **argv)
}
attr_delete = NULL;
- pe_free_working_set(data_set);
- data_set = NULL;
+ pe_free_working_set(scheduler);
+ scheduler = NULL;
cib__clean_up_connection(&cib_conn);