1 /* 2 * Copyright 2024 the Pacemaker project contributors 3 * 4 * The version control history for this file may have further details. 5 * 6 * This source code is licensed under the GNU Lesser General Public License 7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. 8 */ 9 10 #ifndef PCMK__PCMKI_PCMKI_TICKET__H 11 # define PCMK__PCMKI_PCMKI_TICKET__H 12 13 #include <crm/common/output_internal.h> 14 15 #include <crm/cib/cib_types.h> 16 17 /*! 18 * \internal 19 * \brief Return the state XML for a given ticket 20 * 21 * \param[in] cib Open CIB connection 22 * \param[in] ticket_id Ticket to get state for, or \c NULL for all tickets 23 * \param[out] state Where to store the result XML 24 * 25 * \return Standard Pacemaker return code 26 * 27 * \note If \p ticket_id is not \c NULL and more than one ticket exists with 28 * that ID, this function returns \c pcmk_rc_duplicate_id. 29 */ 30 int pcmk__get_ticket_state(cib_t *cib, const char *ticket_id, xmlNode **state); 31 32 /*! 33 * \internal 34 * \brief Display the constraints that apply to a given ticket 35 * 36 * \param[in,out] out Output object 37 * \param[in] cib Open CIB connection 38 * \param[in] ticket_id Ticket to find constraints for, 39 * or \c NULL for all ticket constraints 40 * 41 * \return Standard Pacemaker return code 42 */ 43 int pcmk__ticket_constraints(pcmk__output_t *out, cib_t *cib, const char *ticket_id); 44 45 /*! 46 * \internal 47 * \brief Delete a ticket's state from the local cluster site 48 * 49 * \param[in,out] out Output object 50 * \param[in] cib Open CIB connection 51 * \param[in] scheduler Scheduler data 52 * \param[in] ticket_id Ticket to delete 53 * \param[in] force If \c true, delete the ticket even if it has 54 * been granted 55 * 56 * \return Standard Pacemaker return code 57 */ 58 int pcmk__ticket_delete(pcmk__output_t *out, cib_t *cib, pcmk_scheduler_t *scheduler, 59 const char *ticket_id, bool force); 60 61 /*! 62 * \internal 63 * \brief Return the value of a ticket's attribute 64 * 65 * \param[in,out] out Output object 66 * \param[in,out] scheduler Scheduler data 67 * \param[in] ticket_id Ticket to find attribute value for 68 * \param[in] attr_name Attribute's name to find value for 69 * \param[in] attr_default If either the ticket or the attribute do not 70 * exist, use this as the value in the output 71 * 72 * \return Standard Pacemaker return code 73 */ 74 int pcmk__ticket_get_attr(pcmk__output_t *out, pcmk_scheduler_t *scheduler, 75 const char *ticket_id, const char *attr_name, 76 const char *attr_default); 77 78 /*! 79 * \brief Return information about the given ticket 80 * 81 * \param[in,out] out Output object 82 * \param[in,out] scheduler Scheduler data 83 * \param[in] ticket_id Ticket to display info for, or \c NULL for 84 * all tickets 85 * \param[in] details If true (and \p out is not an XML format 86 * object), output any additional attributes 87 * set on a ticket beyond the basics 88 * \param[in] raw If true (and \p out is not an XML format 89 * object), simply list the IDs of all tickets. 90 * This does not make a lot of sense if 91 * \p ticket_id is not NULL, but that will not 92 * raise an error. 93 * 94 * \return Standard Pacemaker return code 95 */ 96 int pcmk__ticket_info(pcmk__output_t *out, pcmk_scheduler_t *scheduler, 97 const char *ticket_id, bool details, bool raw); 98 99 /*! 100 * \brief Remove the given attribute(s) from a ticket 101 * 102 * \param[in,out] out Output object 103 * \param[in] cib Open CIB connection 104 * \param[in,out] scheduler Scheduler data 105 * \param[in] ticket_id Ticket to remove attributes from 106 * \param[in] attr_delete A list of attribute names 107 * \param[in] force Attempting to remove the granted attribute of 108 * \p ticket_id will cause this function to return 109 * \c EACCES unless \p force is set to \c true 110 * 111 * \return Standard Pacemaker return code 112 */ 113 int pcmk__ticket_remove_attr(pcmk__output_t *out, cib_t *cib, pcmk_scheduler_t *scheduler, 114 const char *ticket_id, GList *attr_delete, bool force); 115 116 /*! 117 * \brief Set the given attribute(s) on a ticket 118 * 119 * \param[in,out] out Output object 120 * \param[in] cib Open CIB connection 121 * \param[in,out] scheduler Scheduler data 122 * \param[in] ticket_id Ticket to set attributes on 123 * \param[in] attr_set A hash table of attributes, where keys are the 124 * attribute names and the values are the attribute 125 * values 126 * \param[in] force Attempting to change the granted status of 127 * \p ticket_id will cause this function to return 128 * \c EACCES unless \p force is set to \c true 129 * 130 * \return Standard Pacemaker return code 131 * 132 * \note If no \p ticket_id attribute exists but \p attr_set is non-NULL, the 133 * ticket will be created with the given attributes. 134 */ 135 int pcmk__ticket_set_attr(pcmk__output_t *out, cib_t *cib, pcmk_scheduler_t *scheduler, 136 const char *ticket_id, GHashTable *attr_set, bool force); 137 138 /*! 139 * \internal 140 * \brief Return a ticket's state XML 141 * 142 * \param[in,out] out Output object 143 * \param[in] cib Open CIB connection 144 * \param[in] ticket_id Ticket to find constraints for, 145 * or \c NULL for all ticket constraints 146 * 147 * \return Standard Pacemaker return code 148 * 149 * \note If \p ticket_id is not \c NULL and more than one ticket exists with 150 * that ID, this function returns \c pcmk_rc_duplicate_id. 151 */ 152 int pcmk__ticket_state(pcmk__output_t *out, cib_t *cib, const char *ticket_id); 153 154 #endif