- ansibleResult.setStatusCode(codeStatus);
- ansibleResult.setStatusMessage(messageStatus);
- LOGGER.info("Received response with code = {}, Message = {}", codeStatus, messageStatus);
-
- if (!postResponse.isNull("Results")) {
-
- // Results are available. process them
- // Results is a dictionary of the form
- // {host :{status:s, group:g, message:m, hostname:h}, ...}
- LOGGER.info("Processing results in response");
- JSONObject results = postResponse.getJSONObject("Results");
- LOGGER.info("Get JSON dictionary from Results ..");
- Iterator<String> hosts = results.keys();
- LOGGER.info("Iterating through hosts");
-
- while (hosts.hasNext()) {
- String host = hosts.next();
- LOGGER.info("Processing host = {}", host);
-
- try {
- JSONObject hostResponse = results.getJSONObject(host);
- int subCode = hostResponse.getInt(STATUS_CODE_KEY);
- String message = hostResponse.getString(STATUS_MESSAGE_KEY);
-
- LOGGER.info("Code = {}, Message = {}", subCode, message);
-
- if (subCode != 200 || !message.equals("SUCCESS")) {
- finalCode = AnsibleResultCodes.REQ_FAILURE.getValue();
- }
- } catch (JSONException e) {
- ansibleResult.setStatusCode(AnsibleResultCodes.INVALID_RESPONSE.getValue());
- ansibleResult.setStatusMessage(String.format(
- "Error processing response message = %s from host %s", results.getString(host), host));
- break;
- }
- }