pacemaker  2.0.4-2deceaa
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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
A dumping ground.
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
struct pe_re_match_data pe_re_match_data_t
struct crm_time_s crm_time_t
Definition: iso8601.h:32
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
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_re_match_data_t * re
Definition: rules.h:41
struct pe_match_data pe_match_data_t
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
enum expression_type find_expression_type(xmlNode *expr)
Definition: rules.c:181
Definition: rules.h:25
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
ISO_8601 Date handling.
GHashTable * meta
Definition: rules.h:43
char * pe_expand_re_matches(const char *string, pe_re_match_data_t *match_data)
Definition: rules.c:1027
GHashTable * params
Definition: rules.h:42
gboolean test_ruleset(xmlNode *ruleset, GHashTable *node_hash, crm_time_t *now)
Definition: rules.c:1132
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
regmatch_t * pmatch
Definition: rules.h:37
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
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
rsc_role_e
Definition: common.h:76
Definition: rules.h:28
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
gboolean test_rule(xmlNode *rule, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now)
Definition: rules.c:1138
expression_type
Definition: rules.h:24
char * string
Definition: rules.h:35
gboolean test_expression(xmlNode *expr, GHashTable *node_hash, enum rsc_role_e role, crm_time_t *now)
Definition: rules.c:1162