29 eval_date_expression(xmlNodePtr expr,
crm_time_t *now)
67 if (new_data_set == NULL) {
79 if (new_data_set->
input == NULL) {
80 out->
err(out,
"Failed to copy input XML");
109 #define XPATH_NODE_RULE "//" XML_TAG_RULE "[@" XML_ATTR_ID "='%s']" 124 xmlNodePtr cib_constraints = NULL;
125 xmlNodePtr match = NULL;
126 xmlXPathObjectPtr xpath_obj = NULL;
149 num_results = numXpathResults(xpath_obj);
154 if (num_results == 0) {
155 *error =
"Rule not found";
159 if (num_results > 1) {
161 *error =
"Found more than one rule with matching ID";
168 num_results = numXpathResults(xpath_obj);
173 if (num_results != 1) {
174 if (num_results == 0) {
175 *error =
"Rule does not have a date expression";
177 *error =
"Rule has more than one date expression";
187 num_results = numXpathResults(xpath_obj);
191 if (num_results == 0) {
196 "and date_spec/@years " 197 "and not(date_spec/@moon)]", rule_id);
199 num_results = numXpathResults(xpath_obj);
203 if (num_results == 0) {
205 *error =
"Rule must either not use date_spec, or use date_spec " 206 "with years= but not moon=";
224 *error =
"Error parsing rule";
246 const char **rule_ids)
253 if (rule_ids == NULL) {
263 for (
const char **rule_id = rule_ids; *rule_id != NULL; rule_id++) {
264 const char *error = NULL;
265 int last_rc = eval_rule(
data_set, *rule_id, &error);
267 out->
message(out,
"rule-check", *rule_id, last_rc, error);
281 const char **rule_ids)
int(* message)(pcmk__output_t *out, const char *message_id,...)
void pe_free_working_set(pe_working_set_t *data_set)
Free a working set.
struct crm_time_s crm_time_t
#define XML_CIB_TAG_CONSTRAINTS
pe_working_set_t * pe_new_working_set(void)
Create a new working set.
#define pe_flag_no_compat
crm_time_t * pcmk_copy_time(const crm_time_t *source)
#define pe_flag_no_counts
Don't count total, disabled and blocked resource instances.
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
enum expression_type find_expression_type(xmlNode *expr)
xmlNode * copy_xml(xmlNode *src_node)
int cib__signon_query(cib_t **cib, xmlNode **cib_object)
int pe__eval_date_expr(xmlNode *expr, pe_rule_eval_data_t *rule_data, crm_time_t *next_change)
int pcmk__check_rules(pcmk__output_t *out, xmlNodePtr input, const crm_time_t *date, const char **rule_ids)
xmlNode * pcmk_find_cib_element(xmlNode *cib, const char *element_name)
Find an element in the CIB.
int pcmk__xml_output_new(pcmk__output_t **out, xmlNodePtr *xml)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
int(*) void(* err)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
void pcmk__register_lib_messages(pcmk__output_t *out)
pe_working_set_t * data_set
#define XML_EXPR_ATTR_OPERATION
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.
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
gboolean cluster_status(pe_working_set_t *data_set)
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
This structure contains everything that makes up a single output formatter.
#define pe__set_working_set_flags(working_set, flags_to_set)
void pcmk__xml_output_finish(pcmk__output_t *out, xmlNodePtr *xml)
void freeXpathObject(xmlXPathObjectPtr xpathObj)