pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
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
19extern "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)
52#endif
53};
55
57typedef 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
105int 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
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:1304
expression_type
Definition rules.h:33
@ pcmk__condition_rule
Definition rules.h:35
@ pcmk__condition_location
Definition rules.h:37
@ not_expr
Definition rules.h:43
@ rsc_expr
Definition rules.h:50
@ op_expr
Definition rules.h:51
@ role_expr
Definition rules.h:47
@ attr_expr
Definition rules.h:45
@ version_expr
Definition rules.h:49
@ pcmk__condition_unknown
Definition rules.h:34
@ pcmk__condition_attribute
Definition rules.h:36
@ nested_rule
Definition rules.h:44
@ pcmk__condition_datetime
Definition rules.h:38
@ time_expr
Definition rules.h:48
@ loc_expr
Definition rules.h:46
@ pcmk__condition_resource
Definition rules.h:39
@ pcmk__condition_operation
Definition rules.h:40
struct pcmk_rule_input pcmk_rule_input_t
Data used to evaluate a rule (any NULL items are ignored)
ISO_8601 Date handling.
struct crm_time_s crm_time_t
Definition iso8601.h:32
Data used to evaluate a rule (any NULL items are ignored)
Definition rules.h:57
const char * rsc_standard
Resource standard that rule applies to.
Definition rules.h:62
const char * op_name
Operation name that rule applies to.
Definition rules.h:67
const char * rsc_provider
Resource provider that rule applies to.
Definition rules.h:63
const regmatch_t * rsc_id_submatches
Resource pattern submatches (as set by regexec()) for rsc_id.
Definition rules.h:99
int rsc_id_nmatches
Number of entries in rsc_id_submatches.
Definition rules.h:102
GHashTable * node_attrs
Definition rules.h:77
GHashTable * rsc_meta
Definition rules.h:93
const crm_time_t * now
Current time for rule evaluation purposes.
Definition rules.h:59
const char * rsc_agent
Resource agent that rule applies to.
Definition rules.h:64
const char * rsc_id
Resource ID to compare against a location constraint's resource pattern.
Definition rules.h:96
guint op_interval_ms
Operation interval that rule applies to.
Definition rules.h:68
GHashTable * rsc_params
Definition rules.h:86