30 eval_date_expression(
const xmlNode *expr,
crm_time_t *now)
68 if (new_scheduler == NULL) {
80 if (new_scheduler->
input == NULL) {
81 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(
scheduler, *rule_id, &error);
267 out->
message(out,
"rule-check", *rule_id, last_rc, error);
281 const char **rule_ids)
int pe__eval_date_expr(const xmlNode *expr, const pe_rule_eval_data_t *rule_data, crm_time_t *next_change)
int cib__signon_query(pcmk__output_t *out, cib_t **cib, xmlNode **cib_object)
int(* message)(pcmk__output_t *out, const char *message_id,...)
struct crm_time_s crm_time_t
#define XML_CIB_TAG_CONSTRAINTS
crm_time_t * pcmk_copy_time(const crm_time_t *source)
#define pe__set_working_set_flags(scheduler, flags_to_set)
Implementation of pcmk_scheduler_t.
gboolean cluster_status(pcmk_scheduler_t *scheduler)
enum expression_type find_expression_type(xmlNode *expr)
xmlNode * copy_xml(xmlNode *src_node)
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(*) int(*) void(* err)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
void pcmk__register_lib_messages(pcmk__output_t *out)
#define XML_EXPR_ATTR_OPERATION
pcmk_scheduler_t * pe_new_working_set(void)
Create a new object to hold scheduler data.
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
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
This structure contains everything that makes up a single output formatter.
Skip counting of total, disabled, and blocked resource instances.
void pcmk__xml_output_finish(pcmk__output_t *out, xmlNodePtr *xml)
Resource role is unknown.
void freeXpathObject(xmlXPathObjectPtr xpathObj)
crm_time_t * now
Current time for evaluation purposes.