From 39167cccae3271603819aa39c6476e434c759533 Mon Sep 17 00:00:00 2001 From: Serge Simard Date: Wed, 12 Jun 2019 10:06:24 -0400 Subject: [PATCH] Various bug fixes encountered during remote ansible executor development. - Upload CBA sometimes failed because Property files were left opened. - Default value were ignored on datatype elements. - Various erroneous error messages - Fixed job template lookup by name encoding when name contains blanks. Issue-ID: CCSDK-1357 Signed-off-by: Serge Simard Change-Id: If9d4b0339d647e6c99121f5464a1b6da787761a0 Signed-off-by: Serge Simard --- .../functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt | 7 ++++++- .../resolution/processor/CapabilityResourceResolutionProcessor.kt | 2 +- .../resource/resolution/processor/ResourceAssignmentProcessor.kt | 2 +- .../functions/resource/resolution/utils/ResourceAssignmentUtils.kt | 2 +- .../controllerblueprints/core/service/BluePrintRuntimeService.kt | 3 ++- .../cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt | 4 +++- 6 files changed, 14 insertions(+), 6 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 96a7bb712..f145d9677 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 @@ -19,6 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.ansible.executor import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.node.ObjectNode +import java.net.URI import java.net.URLEncoder import java.util.NoSuchElementException import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.* @@ -132,8 +133,12 @@ open class ComponentRemoteAnsibleExecutor(private val blueprintRestLibPropertySe private fun lookupJobTemplateIDByName(awxClient : BlueprintWebClientService, job_template_name: String?): String { val mapper = ObjectMapper() + val encodedJTName = URI(null,null, + "/api/v2/job_templates/${job_template_name}/", + null,null).rawPath + // Get Job Template details by name - var response = awxClient.exchangeResource(GET, "/api/v2/job_templates/${job_template_name}/", "") + var response = awxClient.exchangeResource(GET, encodedJTName,"") val jtDetails: JsonNode = mapper.readTree(response.body) return jtDetails.at("/id").asText() } diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt index 1a7c50676..7a8d6ec5c 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt @@ -81,7 +81,7 @@ open class CapabilityResourceResolutionProcessor(private val applicationContext: override suspend fun recoverNB(runtimeException: RuntimeException, resourceAssignment: ResourceAssignment) { raRuntimeService.getBluePrintError() - .addError("Failed in ComponentNetconfExecutor : ${runtimeException.message}") + .addError("Failed in CapabilityResourceResolutionProcessor : ${runtimeException.message}") } suspend fun scriptInstance(scriptType: String, scriptClassReference: String, instanceDependencies: List) diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt index 1cc44a2cb..39ffe5ea9 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt @@ -121,7 +121,7 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode - val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName) + val valueNode: JsonNode = workflowDynamicInputs.at(BluePrintConstants.PATH_DIVIDER + propertyName).returnNullIfMissing() + ?: property.defaultValue ?: NullNode.getInstance() setInputValue(propertyName, property, valueNode) diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt index c51f48290..60ed6343a 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt @@ -65,7 +65,9 @@ class BluePrintMetadataUtils { envDir.listFiles() .filter { it.name.endsWith(".properties") } .forEach { - properties.load(it.inputStream()) + val istream = it.inputStream() + properties.load(istream) + istream.close() } } return properties -- 2.16.6