21 build_ticket_modify_xml(
cib_t *cib,
const char *ticket_id, xmlNode **ticket_state_xml,
28 *xml_top = *ticket_state_xml;
30 }
else if (rc == ENXIO) {
32 xmlNode *xml_obj = NULL;
51 GHashTable *attr_set, xmlNode **ticket_state_xml)
53 GHashTableIter hash_iter;
60 g_hash_table_iter_init(&hash_iter, attr_set);
61 while (g_hash_table_iter_next(&hash_iter, (gpointer *) & key, (gpointer *) & value)) {
69 char *now = pcmk__ttoa(time(NULL));
81 xmlNode *xml_search = NULL;
87 if (ticket_id != NULL) {
101 if (xml_search->children != NULL && ticket_id != NULL) {
117 const char *xpath_base = NULL;
125 if (ticket_id != NULL) {
127 xpath_base, ticket_id);
168 delete_single_ticket(xmlNode *child,
void *userdata)
181 const char *ticket_id,
bool force)
184 xmlNode *state = NULL;
188 if (ticket_id == NULL) {
197 if (ticket == NULL) {
212 }
else if (rc == ENXIO) {
224 rc = delete_single_ticket(state, cib);
228 out->
info(out,
"Cleaned up %s", ticket_id);
262 const char *ticket_id,
const char *attr_name,
263 const char *attr_default)
266 const char *attr_value = NULL;
271 if (ticket_id == NULL || attr_name == NULL) {
278 if (ticket != NULL) {
279 attr_value = g_hash_table_lookup(ticket->
state, attr_name);
282 if (attr_value != NULL) {
283 out->
message(out,
"ticket-attribute", ticket_id, attr_name, attr_value);
284 }
else if (attr_default != NULL) {
285 out->
message(out,
"ticket-attribute", ticket_id, attr_name, attr_default);
295 const char *attr_name,
const char *attr_default)
316 const char *ticket_id,
bool details,
bool raw)
322 if (ticket_id != NULL) {
323 GHashTable *tickets = NULL;
328 if (ticket == NULL) {
336 g_hash_table_insert(tickets, strdup(ticket->
id), ticket);
337 out->
message(out,
"ticket-list", tickets,
false, raw, details);
338 g_hash_table_destroy(tickets);
342 false, raw, details);
376 const char *ticket_id, GList *attr_delete,
bool force)
378 xmlNode *ticket_state_xml = NULL;
379 xmlNode *xml_top = NULL;
384 if (ticket_id == NULL) {
389 if (attr_delete == NULL) {
393 rc = build_ticket_modify_xml(cib, ticket_id, &ticket_state_xml, &xml_top);
402 for (GList *list_iter = attr_delete; list_iter != NULL; list_iter = list_iter->next) {
403 const char *key = list_iter->data;
448 const char *ticket_id, GHashTable *attr_set,
bool force)
450 xmlNode *ticket_state_xml = NULL;
451 xmlNode *xml_top = NULL;
456 if (ticket_id == NULL) {
461 if (attr_set == NULL || g_hash_table_size(attr_set) == 0) {
465 rc = build_ticket_modify_xml(cib, ticket_id, &ticket_state_xml, &xml_top);
479 add_attribute_xml(
scheduler, ticket_id, attr_set, &ticket_state_xml);
518 xmlNode *state_xml = NULL;
530 if (state_xml != NULL) {
531 out->
message(out,
"ticket-state", state_xml);
#define PCMK__XE_TICKET_STATE
int(* message)(pcmk__output_t *out, const char *message_id,...)
int pcmk__get_ticket_state(cib_t *cib, const char *ticket_id, xmlNode **state)
#define PCMK_XE_CONSTRAINTS
G_GNUC_INTERNAL int pcmk__setup_output_cib_sched(pcmk__output_t **out, cib_t **cib, pcmk_scheduler_t **scheduler, xmlNode **xml)
int pcmk_ticket_set_attr(xmlNodePtr *xml, const char *ticket_id, GHashTable *attr_set, bool force)
Set the given attribute(s) on a ticket.
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
int pcmk__ticket_info(pcmk__output_t *out, pcmk_scheduler_t *scheduler, const char *ticket_id, bool details, bool raw)
Return information about the given ticket.
pcmk__scheduler_private_t * priv
int pcmk__xe_foreach_child(xmlNode *xml, const char *child_element_name, int(*handler)(xmlNode *xml, void *userdata), void *userdata)
GHashTable * ticket_constraints
int pcmk__ticket_delete(pcmk__output_t *out, cib_t *cib, pcmk_scheduler_t *scheduler, const char *ticket_id, bool force)
int pcmk_ticket_state(xmlNodePtr *xml, const char *ticket_id)
Return a ticket's state XML.
int pcmk_ticket_delete(xmlNodePtr *xml, const char *ticket_id, bool force)
Delete a ticket's state from the local cluster site.
void pcmk__xml_output_finish(pcmk__output_t *out, crm_exit_t exit_status, xmlNodePtr *xml)
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
void pcmk__xe_remove_attr(xmlNode *element, const char *name)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
void pcmk__xml_free(xmlNode *xml)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
int pcmk_ticket_remove_attr(xmlNodePtr *xml, const char *ticket_id, GList *attr_delete, bool force)
Remove the given attribute(s) from a ticket.
cib_api_operations_t * cmds
int pcmk_ticket_info(xmlNodePtr *xml, const char *ticket_id)
Return information about the given ticket.
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
int pcmk_ticket_constraints(xmlNodePtr *xml, const char *ticket_id)
Return constraints that apply to the given ticket.
int pcmk_ticket_get_attr(xmlNodePtr *xml, const char *ticket_id, const char *attr_name, const char *attr_default)
Return the value of a ticket's attribute.
int(* modify)(cib_t *cib, const char *section, xmlNode *data, int call_options)
#define crm_log_xml_debug(xml, text)
int pcmk__ticket_set_attr(pcmk__output_t *out, cib_t *cib, pcmk_scheduler_t *scheduler, const char *ticket_id, GHashTable *attr_set, bool force)
Set the given attribute(s) on a ticket.
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
int pcmk_legacy2rc(int legacy_rc)
int pcmk__ticket_state(pcmk__output_t *out, cib_t *cib, const char *ticket_id)
int(* replace)(cib_t *cib, const char *section, xmlNode *data, int call_options)
void pe__register_messages(pcmk__output_t *out)
int cib__clean_up_connection(cib_t **cib)
const char * pcmk_cib_xpath_for(const char *element_name)
Get the relative XPath needed to find a specified CIB element name.
#define pcmk__assert(expr)
void pe_free_working_set(pcmk_scheduler_t *scheduler)
Free scheduler data.
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
pcmk__action_result_t result
#define PCMK_XE_RSC_TICKET
pcmk_scheduler_t * scheduler
int pcmk__ticket_remove_attr(pcmk__output_t *out, cib_t *cib, pcmk_scheduler_t *scheduler, const char *ticket_id, GList *attr_delete, bool force)
Remove the given attribute(s) from a ticket.
This structure contains everything that makes up a single output formatter.
gboolean crm_is_true(const char *s)
#define PCMK_XA_LAST_GRANTED
int pcmk__ticket_get_attr(pcmk__output_t *out, pcmk_scheduler_t *scheduler, const char *ticket_id, const char *attr_name, const char *attr_default)
int pcmk__ticket_constraints(pcmk__output_t *out, cib_t *cib, const char *ticket_id)
int(* remove)(cib_t *cib, const char *section, xmlNode *data, int call_options)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1