pacemaker  2.0.4-2deceaa
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions
rules.c File Reference
#include <crm_internal.h>
#include <crm/crm.h>
#include <crm/msg_xml.h>
#include <crm/common/xml.h>
#include <glib.h>
#include <crm/pengine/rules.h>
#include <crm/pengine/rules_internal.h>
#include <crm/pengine/internal.h>
#include <sys/types.h>
#include <regex.h>
#include <ctype.h>
Include dependency graph for rules.c:

Go to the source code of this file.

Macros

#define CHECK_ONE(spec, name, var)
 
#define update_field(xml_field, time_fn)
 

Typedefs

typedef struct sorted_set_s sorted_set_t
 
typedef struct unpack_data_s unpack_data_t
 

Functions

 CRM_TRACE_INIT_DATA (pe_rules)
 
gboolean pe_evaluate_rules (xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now, crm_time_t *next_change)
 Evaluate any rules contained by given XML element. More...
 
gboolean pe_test_rule (xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, crm_time_t *next_change, pe_match_data_t *match_data)
 
gboolean pe_test_expression (xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, crm_time_t *next_change, pe_match_data_t *match_data)
 Evaluate one rule subelement (pass/fail) More...
 
enum expression_type find_expression_type (xmlNode *expr)
 
gboolean pe_test_role_expression (xmlNode *expr, enum rsc_role_e role, crm_time_t *now)
 
gboolean pe_test_attr_expression (xmlNode *expr, GHashTable *hash, crm_time_t *now, pe_match_data_t *match_data)
 
int pe_cron_range_satisfied (crm_time_t *now, xmlNode *cron_spec)
 
crm_time_tpe_parse_xml_duration (crm_time_t *start, xmlNode *duration_spec)
 
gboolean pe_test_date_expression (xmlNode *time_expr, crm_time_t *now, crm_time_t *next_change)
 
int pe_eval_date_expression (xmlNode *time_expr, crm_time_t *now, crm_time_t *next_change)
 
void pe_unpack_nvpairs (xmlNode *top, xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now, crm_time_t *next_change)
 Extract nvpair blocks contained by an XML element into a hash table. More...
 
char * pe_expand_re_matches (const char *string, pe_re_match_data_t *match_data)
 
gboolean test_ruleset (xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now)
 
gboolean test_rule (xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now)
 
gboolean pe_test_rule_re (xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, pe_re_match_data_t *re_match_data)
 
gboolean pe_test_rule_full (xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, pe_match_data_t *match_data)
 
gboolean test_expression (xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now)
 
gboolean pe_test_expression_re (xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, pe_re_match_data_t *re_match_data)
 
gboolean pe_test_expression_full (xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now, pe_match_data_t *match_data)
 
void unpack_instance_attributes (xmlNode *top, xmlNode *xml_obj, const char *set_name, GHashTable *node_hash, GHashTable *hash, const char *always_first, gboolean overwrite, crm_time_t *now)
 

Macro Definition Documentation

#define CHECK_ONE (   spec,
  name,
  var 
)
Value:
do { \
int subpart_rc = check_one(spec, name, var); \
if (check_passes(subpart_rc) == FALSE) { \
return subpart_rc; \
} \
} while (0)
char * name
Definition: pcmk_fence.c:30

Definition at line 505 of file rules.c.

#define update_field (   xml_field,
  time_fn 
)
Value:
value = crm_element_value(duration_spec, xml_field); \
if(value != NULL) { \
int value_i = crm_parse_int(value, "0"); \
time_fn(end, value_i); \
}
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
Definition: strings.c:126
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:522

Definition at line 546 of file rules.c.

Typedef Documentation

typedef struct sorted_set_s sorted_set_t
typedef struct unpack_data_s unpack_data_t

Function Documentation

CRM_TRACE_INIT_DATA ( pe_rules  )
enum expression_type find_expression_type ( xmlNode *  expr)

Definition at line 181 of file rules.c.

int pe_cron_range_satisfied ( crm_time_t now,
xmlNode *  cron_spec 
)

Definition at line 513 of file rules.c.

int pe_eval_date_expression ( xmlNode *  time_expr,
crm_time_t now,
crm_time_t next_change 
)

Definition at line 620 of file rules.c.

gboolean pe_evaluate_rules ( xmlNode *  ruleset,
GHashTable *  node_hash,
crm_time_t now,
crm_time_t next_change 
)

Evaluate any rules contained by given XML element.

Parameters
[in]xmlXML element to check for rules
[in]node_hashNode attributes to use when evaluating expressions
[in]nowTime to use when evaluating expressions
[out]next_changeIf not NULL, set to when evaluation will change
Returns
TRUE if no rules, or any of rules present is in effect, else FALSE

Definition at line 38 of file rules.c.

char* pe_expand_re_matches ( const char *  string,
pe_re_match_data_t match_data 
)

Definition at line 1027 of file rules.c.

crm_time_t* pe_parse_xml_duration ( crm_time_t start,
xmlNode *  duration_spec 
)

Definition at line 554 of file rules.c.

gboolean pe_test_attr_expression ( xmlNode *  expr,
GHashTable *  hash,
crm_time_t now,
pe_match_data_t match_data 
)

Definition at line 257 of file rules.c.

gboolean pe_test_date_expression ( xmlNode *  time_expr,
crm_time_t now,
crm_time_t next_change 
)

Definition at line 584 of file rules.c.

gboolean pe_test_expression ( xmlNode *  expr,
GHashTable *  node_hash,
enum rsc_role_e  role,
crm_time_t now,
crm_time_t next_change,
pe_match_data_t match_data 
)

Evaluate one rule subelement (pass/fail)

A rule element may contain another rule, a node attribute expression, or a date expression. Given any one of those, evaluate it and return whether it passed.

Parameters
[in]exprRule subelement XML
[in]node_hashNode attributes to use when evaluating expression
[in]roleResource role to use when evaluating expression
[in]nowTime to use when evaluating expression
[out]next_changeIf not NULL, set to when evaluation will change
[in]match_dataIf not NULL, resource back-references and params
Returns
TRUE if expression is in effect under given conditions, else FALSE

Definition at line 124 of file rules.c.

gboolean pe_test_expression_full ( xmlNode *  expr,
GHashTable *  node_hash,
enum rsc_role_e  role,
crm_time_t now,
pe_match_data_t match_data 
)
Deprecated:
Use pe_test_expression() instead

Definition at line 1179 of file rules.c.

gboolean pe_test_expression_re ( xmlNode *  expr,
GHashTable *  node_hash,
enum rsc_role_e  role,
crm_time_t now,
pe_re_match_data_t re_match_data 
)
Deprecated:
Use pe_test_expression() instead

Definition at line 1168 of file rules.c.

gboolean pe_test_role_expression ( xmlNode *  expr,
enum rsc_role_e  role,
crm_time_t now 
)

Definition at line 216 of file rules.c.

gboolean pe_test_rule ( xmlNode *  rule,
GHashTable *  node_hash,
enum rsc_role_e  role,
crm_time_t now,
crm_time_t next_change,
pe_match_data_t match_data 
)

Definition at line 63 of file rules.c.

gboolean pe_test_rule_full ( xmlNode *  rule,
GHashTable *  node_hash,
enum rsc_role_e  role,
crm_time_t now,
pe_match_data_t match_data 
)
Deprecated:
Use pe_test_rule() instead

Definition at line 1155 of file rules.c.

gboolean pe_test_rule_re ( xmlNode *  rule,
GHashTable *  node_hash,
enum rsc_role_e  role,
crm_time_t now,
pe_re_match_data_t re_match_data 
)
Deprecated:
Use pe_test_rule() instead

Definition at line 1144 of file rules.c.

void pe_unpack_nvpairs ( xmlNode *  top,
xmlNode *  xml_obj,
const char *  set_name,
GHashTable *  node_hash,
GHashTable *  hash,
const char *  always_first,
gboolean  overwrite,
crm_time_t now,
crm_time_t next_change 
)

Extract nvpair blocks contained by an XML element into a hash table.

Parameters
[in]topXML document root (used to expand id-ref's)
[in]xml_objXML element containing blocks of nvpair elements
[in]set_nameElement name to identify nvpair blocks
[in]node_hashNode attributes to use when evaluating rules
[out]hashWhere to store extracted name/value pairs
[in]always_firstIf not NULL, process block with this ID first
[in]overwriteWhether to replace existing values with same name
[in]nowTime to use when evaluating rules
[out]next_changeIf not NULL, set to when rule evaluation will change

Definition at line 1005 of file rules.c.

gboolean test_expression ( xmlNode *  expr,
GHashTable *  node_hash,
enum rsc_role_e  role,
crm_time_t now 
)
Deprecated:
Use pe_test_expression() instead

Definition at line 1162 of file rules.c.

gboolean test_rule ( xmlNode *  rule,
GHashTable *  node_hash,
enum rsc_role_e  role,
crm_time_t now 
)
Deprecated:
Use pe_test_rule() instead

Definition at line 1138 of file rules.c.

gboolean test_ruleset ( xmlNode *  ruleset,
GHashTable *  node_hash,
crm_time_t now 
)
Deprecated:
Use pe_evaluate_rules() instead

Definition at line 1132 of file rules.c.

void unpack_instance_attributes ( xmlNode *  top,
xmlNode *  xml_obj,
const char *  set_name,
GHashTable *  node_hash,
GHashTable *  hash,
const char *  always_first,
gboolean  overwrite,
crm_time_t now 
)
Deprecated:
Use pe_unpack_nvpairs() instead

Definition at line 1187 of file rules.c.