pacemaker  2.1.8-3980678f03
Scalable High-Availability cluster resource manager
rules.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2024 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 PCMK__CRM_COMMON_RULES__H
11 #define PCMK__CRM_COMMON_RULES__H
12 
13 #include <glib.h> // guint, GHashTable
14 #include <regex.h> // regmatch_t
15 #include <libxml/tree.h> // xmlNode
16 #include <crm/common/iso8601.h> // crm_time_t
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
28 /* Allowed subexpressions of a rule
29  * @COMPAT This should be made internal at an API compatibility break
30  */
34  pcmk__condition_unknown = 0, // Unknown or invalid condition
35  pcmk__condition_rule = 1, // Nested rule
36  pcmk__condition_attribute = 2, // Node attribute expression
37  pcmk__condition_location = 3, // Node location expression
38  pcmk__condition_datetime = 5, // Date/time expression
39  pcmk__condition_resource = 7, // Resource agent expression
40  pcmk__condition_operation = 8, // Operation expression
41 
42 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
47  role_expr = 4,
52 #endif
53 };
55 
57 typedef struct pcmk_rule_input {
58  // Used to evaluate date expressions
59  const crm_time_t *now;
60 
61  // Used to evaluate resource type expressions
62  const char *rsc_standard;
63  const char *rsc_provider;
64  const char *rsc_agent;
65 
66  // Used to evaluate operation type expressions
67  const char *op_name;
69 
70  // Remaining members are used to evaluate node attribute expressions
71 
77  GHashTable *node_attrs;
78 
79  // Remaining members are used only within location constraint rules
80 
86  GHashTable *rsc_params;
87 
93  GHashTable *rsc_meta;
94 
96  const char *rsc_id;
97 
99  const regmatch_t *rsc_id_submatches;
100 
104 
105 int pcmk_evaluate_rule(xmlNode *rule, const pcmk_rule_input_t *rule_input,
106  crm_time_t *next_change);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif // PCMK__CRM_COMMON_RULES__H
GHashTable * rsc_meta
Definition: rules.h:93
const crm_time_t * now
Current time for rule evaluation purposes.
Definition: rules.h:59
Data used to evaluate a rule (any NULL items are ignored)
Definition: rules.h:57
Definition: rules.h:46
GHashTable * rsc_params
Definition: rules.h:86
const char * rsc_provider
Resource provider that rule applies to.
Definition: rules.h:63
struct crm_time_s crm_time_t
Definition: iso8601.h:32
const char * op_name
Definition: rules.h:67
int rsc_id_nmatches
Number of entries in rsc_id_submatches.
Definition: rules.h:102
expression_type
Definition: rules.h:33
Definition: rules.h:50
const char * rsc_agent
Resource agent that rule applies to.
Definition: rules.h:64
Definition: rules.h:43
int pcmk_evaluate_rule(xmlNode *rule, const pcmk_rule_input_t *rule_input, crm_time_t *next_change)
Evaluate a single rule, including all its conditions.
Definition: rules.c:1385
guint op_interval_ms
Operation name that rule applies to.
Definition: rules.h:68
ISO_8601 Date handling.
const char * rsc_standard
Resource standard that rule applies to.
Definition: rules.h:62
Definition: rules.h:51
struct pcmk_rule_input pcmk_rule_input_t
Data used to evaluate a rule (any NULL items are ignored)
const regmatch_t * rsc_id_submatches
Resource pattern submatches (as set by regexec()) for rsc_id.
Definition: rules.h:99
GHashTable * node_attrs
Operation interval that rule applies to.
Definition: rules.h:77
const char * rsc_id
Resource ID to compare against a location constraint&#39;s resource pattern.
Definition: rules.h:96