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