summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src')
-rw-r--r--appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java10
-rw-r--r--appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java2
2 files changed, 9 insertions, 3 deletions
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
index b9cdbc6bb..ae0b8594f 100644
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/main/java/org/onap/appc/adapter/ansible/impl/AnsibleAdapterImpl.java
@@ -77,6 +77,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
private static final String RESULT_CODE_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.result.code";
private static final String MESSAGE_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.message";
private static final String RESULTS_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.results";
+ private static final String OUTPUT_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.output";
private static final String ID_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.Id";
private static final String LOG_ATTRIBUTE_NAME = "org.onap.appc.adapter.ansible.log";
@@ -317,6 +318,7 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
int code = -1;
String message = StringUtils.EMPTY;
String results = StringUtils.EMPTY;
+ String output = StringUtils.EMPTY;
try {
// Try to retrieve the test results (modify the URL for that)
@@ -324,13 +326,14 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
code = testResult.getStatusCode();
message = testResult.getStatusMessage();
- if (code == 200) {
+ if (code == 200 || code == 400 || "FINISHED".equalsIgnoreCase(message)) {
logger.info("Parsing response from Server = " + message);
// Valid HTTP. process the Ansible message
testResult = messageProcessor.parseGetResponse(message);
code = testResult.getStatusCode();
message = testResult.getStatusMessage();
results = testResult.getResults();
+ output = testResult.getOutput();
}
logger.info("Request response = " + message);
@@ -350,13 +353,16 @@ public class AnsibleAdapterImpl implements AnsibleAdapter {
logger.info(String.format("Ansible Request %s finished with Result %s, Message = %s", params.get("Id"),
OUTCOME_FAILURE, message));
ctx.setAttribute(RESULTS_ATTRIBUTE_NAME, results);
+ ctx.setAttribute(OUTPUT_ATTRIBUTE_NAME, output);
doFailure(ctx, code, message);
return;
}
- ctx.setAttribute(RESULT_CODE_ATTRIBUTE_NAME, Integer.toString(code));
+ // In case of 200,400,FINISHED return 400
+ ctx.setAttribute(RESULT_CODE_ATTRIBUTE_NAME, "400");
ctx.setAttribute(MESSAGE_ATTRIBUTE_NAME, message);
ctx.setAttribute(RESULTS_ATTRIBUTE_NAME, results);
+ ctx.setAttribute(OUTPUT_ATTRIBUTE_NAME, output);
ctx.setStatus(OUTCOME_SUCCESS);
}
diff --git a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
index 7898260d1..7ba34e942 100644
--- a/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
+++ b/appc-adapters/appc-ansible-adapter/appc-ansible-adapter-bundle/src/test/java/org/onap/appc/adapter/ansible/impl/TestAnsibleAdapterImpl.java
@@ -150,7 +150,7 @@ public class TestAnsibleAdapterImpl {
when(messageProcessor.reqUriResult(params)).thenReturn(agentUrl);
when(messageProcessor.parseGetResponse(anyString())).thenReturn(result);
spyAdapter.reqExecResult(params, svcContext);
- assertEquals(SUCCESS, svcContext.getAttribute(RESULT_CODE_ATTRIBUTE_NAME));
+ assertEquals("400", svcContext.getAttribute(RESULT_CODE_ATTRIBUTE_NAME));
}
/**