aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor
diff options
context:
space:
mode:
authorKAPIL SINGAL <ks220y@att.com>2020-12-03 17:16:59 +0000
committerGerrit Code Review <gerrit@onap.org>2020-12-03 17:16:59 +0000
commit7871f10b1c93e938f5f26e7c9545fa422cd58351 (patch)
treecfd6766af8c13657ecd599bac01671260932140d /ms/blueprintsprocessor
parentd578a475277774517207c96772e221e81b6c5d25 (diff)
parentfffa390c47e265c84d5bc755f480cb6d7974d4c5 (diff)
Merge "add toggle variable ansible fire failure to awx function"
Diffstat (limited to 'ms/blueprintsprocessor')
-rw-r--r--ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt19
1 files changed, 16 insertions, 3 deletions
diff --git a/ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt b/ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt
index 504757104..dccbe2e3c 100644
--- a/ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt
+++ b/ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt
@@ -75,6 +75,8 @@ open class ComponentRemoteAnsibleExecutor(
// input fields names accepted by this executor
const val INPUT_ENDPOINT_SELECTOR = "endpoint-selector"
const val INPUT_JOB_TEMPLATE_NAME = "job-template-name"
+ const val ANSIBLE_FIRE_FAILURE = "ansible-fire-failure"
+ const val ANSIBLE_FAILED_STATUS = "failed"
const val INPUT_WORKFLOW_JOB_TEMPLATE_NAME = "workflow-job-template-id"
const val INPUT_LIMIT_TO_HOST = "limit"
const val INPUT_INVENTORY = "inventory"
@@ -102,10 +104,14 @@ open class ComponentRemoteAnsibleExecutor(
jobTemplateName = getOperationInput(INPUT_WORKFLOW_JOB_TEMPLATE_NAME).asText()
workflowURIPrefix = "workflow_"
}
+ var isAnsibleFireFailure = false
+ if (getOptionalOperationInput(ANSIBLE_FIRE_FAILURE) != null) {
+ isAnsibleFireFailure = getOperationInput(ANSIBLE_FIRE_FAILURE).asBoolean()
+ }
val jtId = lookupJobTemplateIDByName(restClientService, jobTemplateName, workflowURIPrefix)
if (jtId.isNotEmpty()) {
- runJobTemplateOnAWX(restClientService, jobTemplateName, jtId, workflowURIPrefix)
+ runJobTemplateOnAWX(restClientService, jobTemplateName, jtId, workflowURIPrefix, isAnsibleFireFailure)
} else {
val message = "Workflow/Job template $jobTemplateName does not exists"
log.error(message)
@@ -178,7 +184,8 @@ open class ComponentRemoteAnsibleExecutor(
awxClient: BlueprintWebClientService,
job_template_name: String?,
jtId: String,
- workflowPrefix: String
+ workflowPrefix: String,
+ isAnsibleFireFailure: Boolean
) {
setNodeOutputProperties("preparing".asJsonPrimitive(), "".asJsonPrimitive(), "".asJsonPrimitive())
@@ -217,7 +224,13 @@ open class ComponentRemoteAnsibleExecutor(
log.info("Execution of job template $job_template_name in job #$jobId finished with status ($jobStatus) for requestId $processId")
- populateJobRunResponse(awxClient, jobId, workflowPrefix, jobStatus)
+ if (isAnsibleFireFailure && jobStatus == ANSIBLE_FAILED_STATUS) {
+ val message = "Execution of job template $job_template_name failed for requestId $processId." + " (Response: ${response.body}) "
+ log.error(message)
+ setNodeOutputErrors(ATTRIBUTE_EXEC_CMD_STATUS_ERROR, message)
+ } else {
+ populateJobRunResponse(awxClient, jobId, workflowPrefix, jobStatus)
+ }
} else {
// The job template requirements were not fulfilled with the values passed in. The message below will
// provide more information via the response, like the ignored_fields, or variables_needed_to_start,