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

Function stonith_api_query

lib/fencing/st_client.c:1194–1233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1192}
1193
1194static int
1195stonith_api_query(stonith_t * stonith, int call_options, const char *target,
1196 stonith_key_value_t ** devices, int timeout)
1197{
1198 int rc = 0, lpc = 0, max = 0;
1199
1200 xmlNode *data = NULL;
1201 xmlNode *output = NULL;
1202 xmlXPathObjectPtr xpathObj = NULL;
1203
1204 CRM_CHECK(devices != NULL, return -EINVAL);
1205
1206 data = create_xml_node(NULL, F_STONITH_DEVICE);
1207 crm_xml_add(data, "origin", __FUNCTION__);
1208 crm_xml_add(data, F_STONITH_TARGET, target);
1209 crm_xml_add(data, F_STONITH_ACTION, "off");
1210 rc = stonith_send_command(stonith, STONITH_OP_QUERY, data, &output, call_options, timeout);
1211
1212 if (rc < 0) {
1213 return rc;
1214 }
1215
1216 xpathObj = xpath_search(output, "//@agent");
1217 if (xpathObj) {
1218 max = xpathObj->nodesetval->nodeNr;
1219
1220 for (lpc = 0; lpc < max; lpc++) {
1221 xmlNode *match = getXpathResult(xpathObj, lpc);
1222
1223 CRM_CHECK(match != NULL, continue);
1224
1225 crm_info("%s[%d] = %s", "//@agent", lpc, xmlGetNodePath(match));
1226 *devices = stonith_key_value_add(*devices, NULL, crm_element_value(match, XML_ATTR_ID));
1227 }
1228 }
1229
1230 free_xml(output);
1231 free_xml(data);
1232 return max;
1233}
1234
1235static int
1236stonith_api_call(stonith_t * stonith,

Callers

nothing calls this directly

Calls 8

create_xml_nodeFunction · 0.85
crm_xml_addFunction · 0.85
stonith_send_commandFunction · 0.85
xpath_searchFunction · 0.85
getXpathResultFunction · 0.85
stonith_key_value_addFunction · 0.85
crm_element_valueFunction · 0.85
free_xmlFunction · 0.85

Tested by

no test coverage detected