22 #define XPATH_NODE_RULE "//" PCMK_XE_RULE "[@" PCMK_XA_ID "='%s']" 37 xmlNodePtr cib_constraints = NULL;
38 xmlNodePtr match = NULL;
39 xmlXPathObjectPtr xpath_obj = NULL;
62 num_results = numXpathResults(xpath_obj);
67 if (num_results == 0) {
68 *error =
"Rule not found";
72 if (num_results > 1) {
74 *error =
"Found more than one rule with matching ID";
81 num_results = numXpathResults(xpath_obj);
86 if (num_results != 1) {
87 if (num_results == 0) {
88 *error =
"Rule does not have a date expression";
90 *error =
"Rule has more than one date expression";
102 num_results = numXpathResults(xpath_obj);
106 if (num_results == 0) {
119 num_results = numXpathResults(xpath_obj);
123 if (num_results == 0) {
142 *error =
"Error parsing rule";
164 const char **rule_ids)
171 if (rule_ids == NULL) {
181 for (
const char **rule_id = rule_ids; *rule_id != NULL; rule_id++) {
182 const char *error = NULL;
183 int last_rc = eval_rule(
scheduler, *rule_id, &error);
185 out->
message(out,
"rule-check", *rule_id, last_rc, error);
199 const char **rule_ids)
int(* message)(pcmk__output_t *out, const char *message_id,...)
struct crm_time_s crm_time_t
#define PCMK_VALUE_DATE_SPEC
#define PCMK_XE_CONSTRAINTS
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
void pcmk__xml_output_finish(pcmk__output_t *out, crm_exit_t exit_status, xmlNodePtr *xml)
#define PCMK_XA_OPERATION
int pcmk__check_rules(pcmk__output_t *out, xmlNodePtr input, const crm_time_t *date, const char **rule_ids)
#define PCMK_XE_DATE_EXPRESSION
xmlNode * pcmk_find_cib_element(xmlNode *cib, const char *element_name)
Find an element in the CIB.
#define PCMK_XE_DATE_SPEC
int pcmk__xml_output_new(pcmk__output_t **out, xmlNodePtr *xml)
G_GNUC_INTERNAL int pcmk__init_scheduler(pcmk__output_t *out, xmlNodePtr input, const crm_time_t *date, pcmk_scheduler_t **scheduler)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
void pcmk__register_lib_messages(pcmk__output_t *out)
Wrappers for and extensions to libxml2.
#define pcmk__assert(expr)
void pe_free_working_set(pcmk_scheduler_t *scheduler)
Free scheduler data.
xmlXPathObjectPtr xpath_search(const xmlNode *xml_top, const char *path)
int pcmk_check_rules(xmlNodePtr *xml, xmlNodePtr input, const crm_time_t *date, const char **rule_ids)
Check whether each rule in a list is in effect.
pcmk_scheduler_t * scheduler
enum expression_type pcmk__condition_type(const xmlNode *condition)
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
This structure contains everything that makes up a single output formatter.
int pcmk__evaluate_date_expression(const xmlNode *date_expression, const crm_time_t *now, crm_time_t *next_change)
void freeXpathObject(xmlXPathObjectPtr xpathObj)