MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / test_role_expression

Function test_role_expression

lib/pengine/rules.c:165–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165gboolean
166test_role_expression(xmlNode * expr, enum rsc_role_e role, crm_time_t * now)
167{
168 gboolean accept = FALSE;
169 const char *op = NULL;
170 const char *value = NULL;
171
172 if (role == RSC_ROLE_UNKNOWN) {
173 return accept;
174 }
175
176 value = crm_element_value(expr, XML_EXPR_ATTR_VALUE);
177 op = crm_element_value(expr, XML_EXPR_ATTR_OPERATION);
178
179 if (safe_str_eq(op, "defined")) {
180 if (role > RSC_ROLE_STARTED) {
181 accept = TRUE;
182 }
183
184 } else if (safe_str_eq(op, "not_defined")) {
185 if (role < RSC_ROLE_SLAVE && role > RSC_ROLE_UNKNOWN) {
186 accept = TRUE;
187 }
188
189 } else if (safe_str_eq(op, "eq")) {
190 if (text2role(value) == role) {
191 accept = TRUE;
192 }
193
194 } else if (safe_str_eq(op, "ne")) {
195 /* we will only test "ne" wtih master/slave roles style */
196 if (role < RSC_ROLE_SLAVE && role > RSC_ROLE_UNKNOWN) {
197 accept = FALSE;
198
199 } else if (text2role(value) != role) {
200 accept = TRUE;
201 }
202 }
203 return accept;
204}
205
206gboolean
207test_attr_expression(xmlNode * expr, GHashTable * hash, crm_time_t * now)

Callers 1

test_expressionFunction · 0.85

Calls 2

crm_element_valueFunction · 0.85
text2roleFunction · 0.85

Tested by

no test coverage detected