| 1192 | } |
| 1193 | |
| 1194 | static int |
| 1195 | stonith_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 | |
| 1235 | static int |
| 1236 | stonith_api_call(stonith_t * stonith, |
nothing calls this directly
no test coverage detected