pacemaker  2.0.4-2deceaa3ae
Scalable High-Availability cluster resource manager
rules.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2019 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 PENGINE_RULES__H
11 # define PENGINE_RULES__H
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 # include <glib.h>
18 # include <regex.h>
19 
20 # include <crm/crm.h>
21 # include <crm/common/iso8601.h>
22 # include <crm/pengine/common.h>
23 
32 };
33 
34 typedef struct pe_re_match_data {
35  char *string;
36  int nregs;
37  regmatch_t *pmatch;
39 
40 typedef struct pe_match_data {
42  GHashTable *params;
43  GHashTable *meta;
45 
46 enum expression_type find_expression_type(xmlNode * expr);
47 
48 gboolean pe_evaluate_rules(xmlNode *ruleset, GHashTable *node_hash,
49  crm_time_t *now, crm_time_t *next_change);
50 
51 gboolean pe_test_rule(xmlNode *rule, GHashTable *node_hash,
52  enum rsc_role_e role, crm_time_t *now,
53  crm_time_t *next_change, pe_match_data_t *match_data);
54 
55 gboolean pe_test_expression(xmlNode *expr, GHashTable *node_hash,
56  enum rsc_role_e role, crm_time_t *now,
57  crm_time_t *next_change,
58  pe_match_data_t *match_data);
59 
60 void pe_unpack_nvpairs(xmlNode *top, xmlNode *xml_obj, const char *set_name,
61  GHashTable *node_hash, GHashTable *hash,
62  const char *always_first, gboolean overwrite,
63  crm_time_t *now, crm_time_t *next_change);
64 
65 #if ENABLE_VERSIONED_ATTRS
66 void pe_unpack_versioned_attributes(xmlNode *top, xmlNode *xml_obj,
67  const char *set_name, GHashTable *node_hash,
68  xmlNode *hash, crm_time_t *now,
69  crm_time_t *next_change);
70 GHashTable *pe_unpack_versioned_parameters(xmlNode *versioned_params, const char *ra_version);
71 #endif
72 
73 char *pe_expand_re_matches(const char *string, pe_re_match_data_t * match_data);
74 
75 #ifndef PCMK__NO_COMPAT
76 /* Everything here is deprecated and kept only for public API backward
77  * compatibility. It will be moved to compatibility.h when 2.1.0 is released.
78  */
79 
81 gboolean test_ruleset(xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now);
82 
84 gboolean test_rule(xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role,
85  crm_time_t *now);
86 
88 gboolean pe_test_rule_re(xmlNode *rule, GHashTable *node_hash,
89  enum rsc_role_e role, crm_time_t *now,
90  pe_re_match_data_t *re_match_data);
91 
93 gboolean pe_test_rule_full(xmlNode *rule, GHashTable *node_hash,
94  enum rsc_role_e role, crm_time_t *now,
95  pe_match_data_t *match_data);
96 
98 gboolean test_expression(xmlNode *expr, GHashTable *node_hash,
99  enum rsc_role_e role, crm_time_t *now);
100 
102 gboolean pe_test_expression_re(xmlNode *expr, GHashTable *node_hash,
103  enum rsc_role_e role, crm_time_t *now,
104  pe_re_match_data_t *re_match_data);
105 
107 gboolean pe_test_expression_full(xmlNode *expr, GHashTable *node_hash,
108  enum rsc_role_e role,
109  crm_time_t *now, pe_match_data_t *match_data);
110 
112 void unpack_instance_attributes(xmlNode *top, xmlNode *xml_obj,
113  const char *set_name, GHashTable *node_hash,
114  GHashTable *hash, const char *always_first,
115  gboolean overwrite, crm_time_t *now);
116 #endif
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif
pe_match_data::re
pe_re_match_data_t * re
Definition: rules.h:41
find_expression_type
enum expression_type find_expression_type(xmlNode *expr)
Definition: rules.c:181
pe_re_match_data::nregs
int nregs
Definition: rules.h:36
pe_re_match_data::pmatch
regmatch_t * pmatch
Definition: rules.h:37
nested_rule
@ nested_rule
Definition: rules.h:26
rsc_role_e
rsc_role_e
Definition: common.h:88
pe_match_data_t
struct pe_match_data pe_match_data_t
pe_match_data
Definition: rules.h:40
pe_test_expression
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)
Definition: rules.c:124
test_ruleset
gboolean test_ruleset(xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now)
Definition: rules.c:1132
pe_unpack_nvpairs
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.
Definition: rules.c:1005
pe_test_rule_full
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)
Definition: rules.c:1155
pe_test_rule
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: rules.c:63
loc_expr
@ loc_expr
Definition: rules.h:28
pe_match_data::meta
GHashTable * meta
Definition: rules.h:43
role_expr
@ role_expr
Definition: rules.h:29
attr_expr
@ attr_expr
Definition: rules.h:27
pe_test_expression_full
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)
Definition: rules.c:1179
pe_expand_re_matches
char * pe_expand_re_matches(const char *string, pe_re_match_data_t *match_data)
Definition: rules.c:1027
version_expr
@ version_expr
Definition: rules.h:31
pe_re_match_data
Definition: rules.h:34
not_expr
@ not_expr
Definition: rules.h:25
pe_test_rule_re
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)
Definition: rules.c:1144
iso8601.h
ISO_8601 Date handling.
pe_test_expression_re
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)
Definition: rules.c:1168
pe_match_data::params
GHashTable * params
Definition: rules.h:42
pe_evaluate_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.
Definition: rules.c:38
common.h
pe_re_match_data::string
char * string
Definition: rules.h:35
expression_type
expression_type
Definition: rules.h:24
test_rule
gboolean test_rule(xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now)
Definition: rules.c:1138
time_expr
@ time_expr
Definition: rules.h:30
unpack_instance_attributes
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)
Definition: rules.c:1187
crm.h
A dumping ground.
pe_re_match_data_t
struct pe_re_match_data pe_re_match_data_t
test_expression
gboolean test_expression(xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now)
Definition: rules.c:1162
crm_time_t
struct crm_time_s crm_time_t
Definition: iso8601.h:32