Various bug fixes encountered during remote ansible executor development. 60/89760/3
authorSerge Simard <serge@agilitae.com>
Wed, 12 Jun 2019 14:06:24 +0000 (10:06 -0400)
committerSerge Simard <serge@agilitae.com>
Thu, 13 Jun 2019 04:45:32 +0000 (00:45 -0400)
 - 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 <serge@agilitae.com>
Change-Id: If9d4b0339d647e6c99121f5464a1b6da787761a0
Signed-off-by: Serge Simard <serge@agilitae.com>
ms/blueprintsprocessor/functions/ansible-awx-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/ansible/executor/ComponentRemoteAnsibleExecutor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/ResourceAssignmentProcessor.kt
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/service/BluePrintRuntimeService.kt
ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/utils/BluePrintMetadataUtils.kt

index 96a7bb7..f145d96 100644 (file)
@@ -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()
     }
index 1a7c506..7a8d6ec 100644 (file)
@@ -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<String>)
index 1cc44a2..39ffe5e 100644 (file)
@@ -121,7 +121,7 @@ abstract class ResourceAssignmentProcessor : BlueprintFunctionNode<ResourceAssig
         try {
             process(resourceAssignment)
         } catch (runtimeException: RuntimeException) {
-            log.error("failed in ${getName()} : ${runtimeException.message}", runtimeException)
+            log.error("failed in ResourceAssignmentProcessor : ${runtimeException.message}", runtimeException)
             recover(runtimeException, resourceAssignment)
         }
     }
index 1a943d1..8a8bfbf 100644 (file)
@@ -70,7 +70,7 @@ class ResourceAssignmentUtils {
             try {
                 if (resourceProp.type.isNotEmpty()) {
                     logger.info("Setting Resource Value ($value) for Resource Name " +
-                            "(${resourceAssignment.dictionaryName}) of type (${resourceProp.type})")
+                            "(${resourceAssignment.name}) of type (${resourceProp.type})")
                     setResourceValue(resourceAssignment, raRuntimeService, value)
                     resourceAssignment.updatedDate = Date()
                     resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM
index 8f39a5a..0819ed7 100644 (file)
@@ -547,7 +547,8 @@ open class DefaultBluePrintRuntimeService(private var id: String, private var bl
 
         workflowDynamicInputs?.let {
             bluePrintContext.dataTypeByName("dt-$dynamicInputPropertiesName")?.properties?.forEach { propertyName, property ->
-                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)
 
index c51f482..60ed634 100644 (file)
@@ -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