pacemaker  2.0.3-4b1f869f0f
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 
76 gboolean test_ruleset(xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now);
77 
79 gboolean test_rule(xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role,
80  crm_time_t *now);
81 
83 gboolean pe_test_rule_re(xmlNode *rule, GHashTable *node_hash,
84  enum rsc_role_e role, crm_time_t *now,
85  pe_re_match_data_t *re_match_data);
86 
88 gboolean pe_test_rule_full(xmlNode *rule, GHashTable *node_hash,
89  enum rsc_role_e role, crm_time_t *now,
90  pe_match_data_t *match_data);
91 
93 gboolean test_expression(xmlNode *expr, GHashTable *node_hash,
94  enum rsc_role_e role, crm_time_t *now);
95 
97 gboolean pe_test_expression_re(xmlNode *expr, GHashTable *node_hash,
98  enum rsc_role_e role, crm_time_t *now,
99  pe_re_match_data_t *re_match_data);
100 
102 gboolean pe_test_expression_full(xmlNode *expr, GHashTable *node_hash,
103  enum rsc_role_e role,
104  crm_time_t *now, pe_match_data_t *match_data);
105 
107 void unpack_instance_attributes(xmlNode *top, xmlNode *xml_obj,
108  const char *set_name, GHashTable *node_hash,
109  GHashTable *hash, const char *always_first,
110  gboolean overwrite, crm_time_t *now);
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #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:236
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:86
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:171
test_ruleset
gboolean test_ruleset(xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now)
Definition: rules.c:63
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:1053
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:131
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:86
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:228
pe_expand_re_matches
char * pe_expand_re_matches(const char *string, pe_re_match_data_t *match_data)
Definition: rules.c:1085
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:75
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:144
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:69
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:1063
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:138
crm_time_t
struct crm_time_s crm_time_t
Definition: iso8601.h:32