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;
59 g_hash_table_iter_init(&hash_iter, attr_set);
60 while (g_hash_table_iter_next(&hash_iter, (gpointer *) & key, (gpointer *) & value)) {
64 && (ticket == NULL || ticket->
granted == FALSE)
67 char *now = pcmk__ttoa(time(NULL));
79 xmlNode *xml_search = NULL;
85 if (ticket_id != NULL) {
93 rc = cib->
cmds->
query(cib, xpath, &xml_search,
100 if (xml_search->children != NULL && ticket_id != NULL) {
116 const char *xpath_base = NULL;
124 if (ticket_id != NULL) {
126 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) {
195 if (ticket == NULL) {
210 }
else if (rc == ENXIO) {
222 rc = delete_single_ticket(state, cib);
226 out->
info(out,
"Cleaned up %s", ticket_id);
260 const char *ticket_id,
const char *attr_name,
261 const char *attr_default)
264 const char *attr_value = NULL;
269 if (ticket_id == NULL || attr_name == NULL) {
275 if (ticket != NULL) {
276 attr_value = g_hash_table_lookup(ticket->
state, attr_name);
279 if (attr_value != NULL) {
280 out->
message(out,
"ticket-attribute", ticket_id, attr_name, attr_value);
281 }
else if (attr_default != NULL) {
282 out->
message(out,
"ticket-attribute", ticket_id, attr_name, attr_default);
292 const char *attr_name,
const char *attr_default)
313 const char *ticket_id,
bool details,
bool raw)
319 if (ticket_id != NULL) {
320 GHashTable *tickets = NULL;
323 if (ticket == NULL) {
331 g_hash_table_insert(tickets, strdup(ticket->
id), ticket);
332 out->
message(out,
"ticket-list", tickets,
false, raw, details);
333 g_hash_table_destroy(tickets);
370 const char *ticket_id, GList *attr_delete,
bool force)
372 xmlNode *ticket_state_xml = NULL;
373 xmlNode *xml_top = NULL;
378 if (ticket_id == NULL) {
383 if (attr_delete == NULL) {
387 rc = build_ticket_modify_xml(cib, ticket_id, &ticket_state_xml, &xml_top);
396 for (GList *list_iter = attr_delete; list_iter != NULL; list_iter = list_iter->next) {
397 const char *key = list_iter->data;
442 const char *ticket_id, GHashTable *attr_set,
bool force)
444 xmlNode *ticket_state_xml = NULL;
445 xmlNode *xml_top = NULL;
450 if (ticket_id == NULL) {
455 if (attr_set == NULL || g_hash_table_size(attr_set) == 0) {
459 rc = build_ticket_modify_xml(cib, ticket_id, &ticket_state_xml, &xml_top);
473 add_attribute_xml(
scheduler, ticket_id, attr_set, &ticket_state_xml);
512 xmlNode *state_xml = NULL;
524 if (state_xml != NULL) {
525 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.
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_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
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.
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
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.
void pcmk__xe_remove_attr(xmlNode *element, const char *name)
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)
void free_xml(xmlNode *child)
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
int pcmk__xe_foreach_child(xmlNode *xml, const char *child_element_name, int(*handler)(xmlNode *xml, void *userdata), void *userdata)
#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.
#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)
gboolean crm_is_true(const char *s)
int(* remove)(cib_t *cib, const char *section, xmlNode *data, int call_options)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)