aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEltanany Shaaban <shaaban.eltanany.ext@orange.com>2020-12-03 16:44:44 +0200
committerShaaban Ebrahim <shaaban.eltanany.ext@orange.com>2020-12-14 13:26:24 +0000
commit58004522ca8cbcf0adaceb5c69bc6ee12737d809 (patch)
treead0a4aa4391864ba6845b7f3a782a131e53de57e
parent10be5cfcdf61fd206746a713e7cb0aab22dd610b (diff)
add toggle variable ansible fire failure to awx function
Issue-ID: CCSDK-2366 Signed-off-by: Eltanany Shaaban <shaaban.eltanany.ext@orange.com> Change-Id: I42b757c206c6d420ffa289cbe9e6c2b4dbf22b20 (cherry picked from commit fffa390c47e265c84d5bc755f480cb6d7974d4c5)
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-remote-ansible-executor.json7
-rw-r--r--ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt19
2 files changed, 22 insertions, 4 deletions
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-remote-ansible-executor.json b/components/model-catalog/definition-type/starter-type/node_type/component-remote-ansible-executor.json
index b14d5b28d..125d1ea2f 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-remote-ansible-executor.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-remote-ansible-executor.json
@@ -30,6 +30,11 @@
"required": false,
"type": "string"
},
+ "ansible-fire-failure": {
+ "description": "ansible fire failue status ",
+ "required": false,
+ "type": "boolean"
+ },
"workflow-job-template-id": {
"description": "Primary key (name not supported) of the workflow job template to launch new job.",
"required": false,
@@ -71,4 +76,4 @@
}
},
"derived_from": "tosca.nodes.Component"
-} \ No newline at end of file
+}
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 6f994edab..37d3e566d 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
@@ -73,6 +73,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"
@@ -100,10 +102,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)
@@ -176,7 +182,8 @@ open class ComponentRemoteAnsibleExecutor(
awxClient: BlueprintWebClientService,
job_template_name: String?,
jtId: String,
- workflowPrefix: String
+ workflowPrefix: String,
+ isAnsibleFireFailure: Boolean
) {
setNodeOutputProperties("preparing".asJsonPrimitive(), "".asJsonPrimitive(), "".asJsonPrimitive())
@@ -215,7 +222,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,