summaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/message-prioritizaion/pom.xml1
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt3
-rwxr-xr-xms/blueprintsprocessor/functions/pom.xml2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt4
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt11
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt30
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt23
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt9
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessor.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt7
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt77
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt1
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt98
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt12
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt8
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt70
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt17
-rw-r--r--ms/blueprintsprocessor/functions/restful-executor/pom.xml (renamed from ms/blueprintsprocessor/functions/nrm-restful/pom.xml)12
-rw-r--r--ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/internal/scripts/TestRestfulConfigure.kt42
-rw-r--r--ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/ComponentRestfulExecutor.kt69
-rw-r--r--ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/RestfulCMComponentFunction.kt126
-rw-r--r--ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/nrmfunction/RestfulNRMServiceClient.kt (renamed from ms/blueprintsprocessor/functions/nrm-restful/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/nrm/restful/RestfulNRMServiceClient.kt)2
-rw-r--r--ms/blueprintsprocessor/functions/restful-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/restful/executor/ComponentRestfulExecutorTest.kt105
-rw-r--r--ms/blueprintsprocessor/functions/restful-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/restful/executor/nrmfunction/RestfulNRMServiceClientTest.kt (renamed from ms/blueprintsprocessor/functions/nrm-restful/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nrm/restful/RestfulNRMServiceClientTest.kt)2
26 files changed, 700 insertions, 40 deletions
diff --git a/ms/blueprintsprocessor/functions/message-prioritizaion/pom.xml b/ms/blueprintsprocessor/functions/message-prioritizaion/pom.xml
index ac46b3635..c7dbaf174 100644
--- a/ms/blueprintsprocessor/functions/message-prioritizaion/pom.xml
+++ b/ms/blueprintsprocessor/functions/message-prioritizaion/pom.xml
@@ -14,7 +14,6 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
index 1262e8500..307e73e6b 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
@@ -65,6 +65,9 @@ open class ComponentNetconfExecutor(private var componentFunctionScriptingServic
// Handles both script processing and error handling
scriptComponent.executeScript(executionServiceInput)
+
+ componentFunctionScriptingService.cleanupInstance(bluePrintRuntimeService.bluePrintContext(),
+ scriptType)
}
override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml
index abd186bcf..3097c1b98 100755
--- a/ms/blueprintsprocessor/functions/pom.xml
+++ b/ms/blueprintsprocessor/functions/pom.xml
@@ -33,7 +33,7 @@
<modules>
<module>resource-resolution</module>
- <module>nrm-restful</module>
+ <module>restful-executor</module>
<module>ansible-awx-executor</module>
<module>python-executor</module>
<module>netconf-executor</module>
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
index db0a6f0ed..3c95ea7bb 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponent.kt
@@ -43,6 +43,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
const val INPUT_RESOURCE_TYPE = "resource-type"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val INPUT_RESOLUTION_KEY = "resolution-key"
+ const val INPUT_RESOLUTION_SUMMARY = "resolution-summary"
const val INPUT_STORE_RESULT = "store-result"
const val INPUT_OCCURRENCE = "occurrence"
@@ -64,6 +65,8 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
val resourceType =
getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE)?.returnNullIfMissing()?.textValue() ?: ""
+ val resolutionSummary =
+ getOptionalOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY)?.asBoolean() ?: false
val properties: MutableMap<String, Any> = mutableMapOf()
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = storeResult
@@ -71,6 +74,7 @@ open class ResourceResolutionComponent(private val resourceResolutionService: Re
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] = resourceId
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] = resourceType
properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY] = resolutionSummary
val jsonResponse = JsonNodeFactory.instance.objectNode()
// Initialize Output Attribute to empty JSON
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
index 6573d0e9a..fd104d3ad 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSL.kt
@@ -82,6 +82,11 @@ fun BluePrintTypes.nodeTypeComponentResourceResolution(): NodeType {
)
property(
+ ResourceResolutionComponent.INPUT_RESOLUTION_SUMMARY, BluePrintConstants.DATA_TYPE_BOOLEAN,
+ false, "Enables ResolutionSummary output"
+ )
+
+ property(
ResourceResolutionComponent.INPUT_OCCURRENCE, BluePrintConstants.DATA_TYPE_INTEGER,
false, "Number of time to perform the resolution."
) {
@@ -176,6 +181,12 @@ class ComponentResourceResolutionNodeTemplateBuilder(id: String, description: St
property(ResourceResolutionComponent.INPUT_RESOLUTION_KEY, resolutionKey)
}
+ fun resolutionSummary(resolutionSummary: Boolean) = resolutionSummary(resolutionSummary.asJsonPrimitive())
+
+ fun resolutionSummary(resolutionSummary: JsonNode) {
+ property(ResourceResolutionComponent.INPUT_RESOLUTION_SUMMARY, resolutionSummary)
+ }
+
fun dynamicProperties(dynamicProperties: String) = dynamicProperties(dynamicProperties.asJsonType())
fun dynamicProperties(dynamicProperties: JsonNode) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index c39933dc8..8f6069160 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -29,4 +29,5 @@ object ResourceResolutionConstants {
const val RESOURCE_RESOLUTION_INPUT_OCCURRENCE = "occurrence"
const val RESOURCE_RESOLUTION_INPUT_RESOURCE_ID = "resource-id"
const val RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE = "resource-type"
+ const val RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY = "resolution-summary"
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 7272a3d63..dff00c7eb 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -147,7 +147,7 @@ open class ResourceResolutionServiceImpl(
properties: Map<String, Any>
): String {
- // Velocity Artifact Definition Name
+ // Template Artifact Definition Name
val artifactTemplate = "$artifactPrefix-template"
// Resource Assignment Artifact Definition Name
val artifactMapping = "$artifactPrefix-mapping"
@@ -185,22 +185,28 @@ open class ResourceResolutionServiceImpl(
properties
)
+ val resolutionSummary = properties.getOrDefault(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY, false) as Boolean
val resolvedParamJsonContent =
ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
-
val artifactTemplateDefinition = bluePrintRuntimeService.bluePrintContext().checkNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
- val resolvedContent = if (artifactTemplateDefinition != null) {
- blueprintTemplateService.generateContent(
- bluePrintRuntimeService, nodeTemplateName,
- artifactTemplate, resolvedParamJsonContent, false,
- mutableMapOf(
- ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to
- properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
+ val resolvedContent = when {
+ artifactTemplateDefinition != null -> {
+ blueprintTemplateService.generateContent(
+ bluePrintRuntimeService, nodeTemplateName,
+ artifactTemplate, resolvedParamJsonContent, false,
+ mutableMapOf(
+ ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE to
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE].asJsonPrimitive()
+ )
)
- )
- } else {
- resolvedParamJsonContent
+ }
+ resolutionSummary -> {
+ ResourceAssignmentUtils.generateResolutionSummaryData(resourceAssignments, resourceDefinitions)
+ }
+ else -> {
+ resolvedParamJsonContent
+ }
}
if (isToStore(properties)) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
index f8bf7bd09..dc1553747 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBService.kt
@@ -198,4 +198,27 @@ class ResourceResolutionDBService(private val resourceResolutionRepository: Reso
throw BluePrintException("Failed to store resource resolution result.", ex)
}
}
+
+ /**
+ * This is a deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey method to delete resources
+ * associated to a specific resolution-key
+ *
+ * @param blueprintName name of the CBA
+ * @param blueprintVersion version of the CBA
+ * @param artifactName name of the artifact
+ * @param resolutionKey value of the resolution-key
+ */
+ suspend fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
+ blueprintName: String,
+ blueprintVersion: String,
+ artifactName: String,
+ resolutionKey: String
+ ) {
+ resourceResolutionRepository.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
+ blueprintName,
+ blueprintVersion,
+ artifactName,
+ resolutionKey
+ )
+ }
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
index a2a3a753b..c2d630e5e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionRepository.kt
@@ -17,6 +17,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.db
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository
+import javax.transaction.Transactional
@Repository
interface ResourceResolutionRepository : JpaRepository<ResourceResolution, String> {
@@ -59,4 +60,12 @@ interface ResourceResolutionRepository : JpaRepository<ResourceResolution, Strin
resourceType: String,
occurrence: Int
): List<ResourceResolution>
+
+ @Transactional
+ fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
+ blueprintName: String?,
+ blueprintVersion: String?,
+ artifactName: String,
+ resolutionKey: String
+ )
}
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 feef4c2fe..868f919c1 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,6 +81,8 @@ open class CapabilityResourceResolutionProcessor(private var componentFunctionSc
// Invoke componentResourceAssignmentProcessor
componentResourceAssignmentProcessor!!.executeScript(resourceAssignment)
+
+ componentFunctionScriptingService.cleanupInstance(raRuntimeService.bluePrintContext(), scriptType)
}
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
index e43b45e7d..0bfd7e4e2 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/DatabaseResourceAssignmentProcessor.kt
@@ -28,6 +28,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.KeyIdentifier
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDictionaryConstants
import org.slf4j.LoggerFactory
@@ -91,6 +92,11 @@ open class DatabaseResourceAssignmentProcessor(
"failed to get input-key-mappings for $dName under $dSource properties"
}
+ sourceProperties.inputKeyMapping
+ ?.mapValues { raRuntimeService.getDictionaryStore(it.value) }
+ ?.map { KeyIdentifier(it.key, it.value) }
+ ?.let { resourceAssignment.keyIdentifiers.addAll(it) }
+
logger.info(
"DatabaseResource ($dSource) dictionary information: " +
"Query:($sql), input-key-mapping:($inputKeyMapping), output-key-mapping:(${sourceProperties.outputKeyMapping})"
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
index 2ff5c441e..5d9226876 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt
@@ -27,6 +27,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.checkNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.isNotEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.nullToEmpty
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.KeyIdentifier
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
@@ -75,8 +76,14 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS
checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping).toMutableMap()
+ sourceProperties.inputKeyMapping
+ ?.mapValues { raRuntimeService.getDictionaryStore(it.value) }
+ ?.map { KeyIdentifier(it.key, it.value) }
+ ?.let { resourceAssignment.keyIdentifiers.addAll(it) }
+
// Resolving content Variables
val payload = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.payload), resolvedInputKeyMapping)
+ resourceSourceProperties["resolved-payload"] = JacksonUtils.jsonNode(payload)
val urlPath =
resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping)
val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping)
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
index 7ffc6db39..7bb757b8e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtils.kt
@@ -42,6 +42,9 @@ import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintRuntimeServ
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonReactorUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.PropertyDefinitionUtils.Companion.hasLogProtect
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.DictionaryMetadataEntry
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.KeyIdentifier
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResolutionSummary
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import org.slf4j.LoggerFactory
@@ -196,6 +199,29 @@ class ResourceAssignmentUtils {
return data
}
+ fun generateResolutionSummaryData(
+ resourceAssignments: List<ResourceAssignment>,
+ resourceDefinitions: Map<String, ResourceDefinition>
+ ): String {
+ val resolutionSummaryList = resourceAssignments.map {
+ val definition = resourceDefinitions[it.name]
+ val payload = definition?.sources?.get(it.dictionarySource)
+ ?.properties?.get("resolved-payload")
+ val metadata = definition?.property?.metadata
+ ?.map { e -> DictionaryMetadataEntry(e.key, e.value) }
+ ?.toMutableList() ?: mutableListOf()
+ val description = definition?.property?.description
+ ResolutionSummary(
+ it.name, it.property?.value, it.property?.required, it.property?.type,
+ it.keyIdentifiers, description, metadata, it.dictionaryName,
+ it.dictionarySource, payload, it.status, it.message
+ )
+ }
+ // Wrapper needed for integration with SDNC
+ val data = mapOf("resolution-summary" to resolutionSummaryList)
+ return JacksonUtils.getJson(data, includeNull = true)
+ }
+
private fun useDefaultValueIfNull(
resourceAssignment: ResourceAssignment,
resourceAssignmentName: String
@@ -263,7 +289,7 @@ class ResourceAssignmentUtils {
return when (type) {
in BluePrintTypes.validPrimitiveTypes() -> {
// Primitive Types
- parseResponseNodeForPrimitiveTypes(responseNode, outputKeyMapping)
+ parseResponseNodeForPrimitiveTypes(responseNode, resourceAssignment, outputKeyMapping)
}
in BluePrintTypes.validCollectionTypes() -> {
// Array Types
@@ -282,6 +308,7 @@ class ResourceAssignmentUtils {
private fun parseResponseNodeForPrimitiveTypes(
responseNode: JsonNode,
+ resourceAssignment: ResourceAssignment,
outputKeyMapping: MutableMap<String, String>
): JsonNode {
// Return responseNode if is not a Complex Type
@@ -306,11 +333,16 @@ class ResourceAssignmentUtils {
if (returnNode.isNullOrMissing() || returnNode!!.isComplexType() && !returnNode.has(outputKeyMapping[outputKey])) {
throw BluePrintProcessorException("Fail to find output key mapping ($outputKey) in the responseNode.")
}
- return if (returnNode.isComplexType()) {
+
+ val returnValue = if (returnNode.isComplexType()) {
returnNode[outputKeyMapping[outputKey]]
} else {
returnNode
}
+
+ outputKey?.let { KeyIdentifier(it, returnValue) }
+ ?.let { resourceAssignment.keyIdentifiers.add(it) }
+ return returnValue
}
private fun parseResponseNodeForCollection(
@@ -337,7 +369,7 @@ class ResourceAssignmentUtils {
val responseArrayNode = responseNode.toList()
for (responseSingleJsonNode in responseArrayNode) {
val arrayChildNode = parseSingleElementOfArrayResponseNode(
- entrySchemaType,
+ entrySchemaType, resourceAssignment,
outputKeyMapping, raRuntimeService, responseSingleJsonNode, metadata
)
arrayNode.add(arrayChildNode)
@@ -347,7 +379,10 @@ class ResourceAssignmentUtils {
is ObjectNode -> {
val responseArrayNode = responseNode.rootFieldsToMap()
resultNode =
- parseObjectResponseNode(entrySchemaType, outputKeyMapping, responseArrayNode, metadata)
+ parseObjectResponseNode(
+ resourceAssignment, entrySchemaType, outputKeyMapping,
+ responseArrayNode, metadata
+ )
}
else -> {
throw BluePrintProcessorException("Key-value response expected to match the responseNode.")
@@ -387,6 +422,7 @@ class ResourceAssignmentUtils {
private fun parseSingleElementOfArrayResponseNode(
entrySchemaType: String,
+ resourceAssignment: ResourceAssignment,
outputKeyMapping: MutableMap<String, String>,
raRuntimeService: ResourceAssignmentRuntimeService,
responseNode: JsonNode,
@@ -397,7 +433,13 @@ class ResourceAssignmentUtils {
in BluePrintTypes.validPrimitiveTypes() -> {
if (outputKeyMappingHasOnlyOneElement) {
val outputKeyMap = outputKeyMapping.entries.first()
+ if (resourceAssignment.keyIdentifiers.none { it.name == outputKeyMap.key }) {
+ resourceAssignment.keyIdentifiers.add(
+ KeyIdentifier(outputKeyMap.key, JacksonUtils.objectMapper.createArrayNode())
+ )
+ }
return parseSingleElementNodeWithOneOutputKeyMapping(
+ resourceAssignment,
responseNode,
outputKeyMap.key,
outputKeyMap.value,
@@ -416,6 +458,7 @@ class ResourceAssignmentUtils {
raRuntimeService
) -> {
parseSingleElementNodeWithAllOutputKeyMapping(
+ resourceAssignment,
responseNode,
outputKeyMapping,
entrySchemaType,
@@ -425,6 +468,7 @@ class ResourceAssignmentUtils {
outputKeyMappingHasOnlyOneElement -> {
val outputKeyMap = outputKeyMapping.entries.first()
parseSingleElementNodeWithOneOutputKeyMapping(
+ resourceAssignment,
responseNode,
outputKeyMap.key,
outputKeyMap.value,
@@ -441,6 +485,7 @@ class ResourceAssignmentUtils {
}
private fun parseObjectResponseNode(
+ resourceAssignment: ResourceAssignment,
entrySchemaType: String,
outputKeyMapping: MutableMap<String, String>,
responseArrayNode: MutableMap<String, JsonNode>,
@@ -449,19 +494,21 @@ class ResourceAssignmentUtils {
val outputKeyMappingHasOnlyOneElement = checkIfOutputKeyMappingProvideOneElement(outputKeyMapping)
if (outputKeyMappingHasOnlyOneElement) {
val outputKeyMap = outputKeyMapping.entries.first()
- return parseObjectResponseNodeWithOneOutputKeyMapping(
+ val returnValue = parseObjectResponseNodeWithOneOutputKeyMapping(
responseArrayNode, outputKeyMap.key, outputKeyMap.value,
entrySchemaType, metadata
)
+ resourceAssignment.keyIdentifiers.add(KeyIdentifier(outputKeyMap.key, returnValue))
+ return returnValue
} else {
throw BluePrintProcessorException("Output-key-mapping do not map the Data Type $entrySchemaType")
}
}
private fun parseSingleElementNodeWithOneOutputKeyMapping(
+ resourceAssignment: ResourceAssignment,
responseSingleJsonNode: JsonNode,
- outputKeyMappingKey:
- String,
+ outputKeyMappingKey: String,
outputKeyMappingValue: String,
type: String,
metadata: MutableMap<String, String>?
@@ -476,11 +523,19 @@ class ResourceAssignmentUtils {
logKeyValueResolvedResource(metadata, outputKeyMappingKey, responseKeyValue, type)
JacksonUtils.populateJsonNodeValues(outputKeyMappingKey, responseKeyValue, type, arrayChildNode)
-
+ resourceAssignment.keyIdentifiers.find { it.name == outputKeyMappingKey && it.value.isArray }
+ .let {
+ if (it != null)
+ (it.value as ArrayNode).add(responseKeyValue)
+ else
+ resourceAssignment.keyIdentifiers.add(
+ KeyIdentifier(outputKeyMappingKey, responseKeyValue))
+ }
return arrayChildNode
}
private fun parseSingleElementNodeWithAllOutputKeyMapping(
+ resourceAssignment: ResourceAssignment,
responseSingleJsonNode: JsonNode,
outputKeyMapping: MutableMap<String, String>,
type: String,
@@ -496,6 +551,7 @@ class ResourceAssignmentUtils {
logKeyValueResolvedResource(metadata, it.key, responseKeyValue, type)
JacksonUtils.populateJsonNodeValues(it.key, responseKeyValue, type, arrayChildNode)
+ resourceAssignment.keyIdentifiers.add(KeyIdentifier(it.key, responseKeyValue))
}
return arrayChildNode
}
@@ -541,6 +597,7 @@ class ResourceAssignmentUtils {
raRuntimeService
) -> {
parseSingleElementNodeWithAllOutputKeyMapping(
+ resourceAssignment,
responseNode,
outputKeyMapping,
entrySchemaType,
@@ -550,8 +607,8 @@ class ResourceAssignmentUtils {
outputKeyMappingHasOnlyOneElement -> {
val outputKeyMap = outputKeyMapping.entries.first()
parseSingleElementNodeWithOneOutputKeyMapping(
- responseNode, outputKeyMap.key, outputKeyMap.value,
- entrySchemaType, metadata
+ resourceAssignment, responseNode, outputKeyMap.key,
+ outputKeyMap.value, entrySchemaType, metadata
)
}
else -> {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
index ae9b4208f..d1347113a 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionComponentDSLTest.kt
@@ -41,6 +41,7 @@ class ResourceResolutionComponentDSLTest {
occurrence(2)
resourceType("vnf")
storeResult(false)
+ resolutionSummary(true)
artifactPrefixNames(arrayListOf("template1", "template2"))
dynamicProperties(
"""{
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
index 2f338a3a1..d5c43184e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt
@@ -36,6 +36,7 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResolutionSummary
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
@@ -44,6 +45,7 @@ import org.springframework.context.annotation.ComponentScan
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
+import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertTrue
@@ -79,6 +81,7 @@ class ResourceResolutionServiceTest {
props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_ID] = resourceId
props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOURCE_TYPE] = resourceType
props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_OCCURRENCE] = occurrence
+ props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY] = false
}
@Test
@@ -214,6 +217,101 @@ class ResourceResolutionServiceTest {
}
@Test
+ @Throws(Exception::class)
+ fun testResolveResourcesResolutionSummary() {
+ runBlocking {
+ props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_SUMMARY] = true
+ Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
+
+ val executionServiceInput =
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
+
+ val resourceAssignmentRuntimeService =
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourcesWithMappingAndTemplate"
+ )
+
+ val artifactPrefix = "notemplate"
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ )
+ }.let {
+ val summaries = JacksonUtils.jsonNode(it)["resolution-summary"]
+ val list = JacksonUtils.getListFromJsonNode(summaries, ResolutionSummary::class.java)
+ assertEquals(list.size, 3)
+ }
+ }
+
+ @Test
+ @Throws(Exception::class)
+ fun testResolveResourcesWithoutTemplate() {
+ runBlocking {
+ Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService)
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(
+ "1234",
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration"
+ )
+
+ val executionServiceInput =
+ JacksonUtils.readValueFromClassPathFile(
+ "payload/requests/sample-resourceresolution-request.json",
+ ExecutionServiceInput::class.java
+ )!!
+
+ val resourceAssignmentRuntimeService =
+ ResourceAssignmentUtils.transformToRARuntimeService(
+ bluePrintRuntimeService,
+ "testResolveResourcesWithMappingAndTemplate"
+ )
+
+ val artifactPrefix = "notemplate"
+
+ // Prepare Inputs
+ PayloadUtils.prepareInputsFromWorkflowPayload(
+ bluePrintRuntimeService,
+ executionServiceInput.payload,
+ "resource-assignment"
+ )
+
+ resourceResolutionService.resolveResources(
+ resourceAssignmentRuntimeService,
+ "resource-assignment",
+ artifactPrefix,
+ props
+ )
+ }.let {
+ assertEquals("""
+ {
+ "service-instance-id" : "siid_1234",
+ "vnf-id" : "vnf_1234",
+ "vnf_name" : "temp_vnf"
+ }
+ """.trimIndent(), it)
+ }
+ }
+
+ @Test
fun testResolveResourcesWithResourceIdAndResourceType() {
props[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_RESOLUTION_KEY] = ""
runBlocking {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
index 4f864a49c..e667cd16f 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/ResourceResolutionDBServiceTest.kt
@@ -223,4 +223,16 @@ open class ResourceResolutionDBServiceTest {
assertEquals(resourceResolution, res)
}
}
+
+ @Test
+ fun deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKeyTest() {
+ every {
+ resourceResolutionRepository.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(any(), any(), any(), any())
+ } returns Unit
+ runBlocking {
+ val res = resourceResolutionDBService.deleteByBlueprintNameAndBlueprintVersionAndArtifactNameAndResolutionKey(
+ blueprintName, blueprintVersion, artifactPrefix, resolutionKey)
+ assertEquals(Unit, res)
+ }
+ }
}
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
index d84488d76..5fbe32e07 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt
@@ -52,6 +52,10 @@ class CapabilityResourceResolutionProcessorTest {
.scriptInstance<ResourceAssignmentProcessor>(any(), any(), any())
} returns MockCapabilityScriptRA()
+ coEvery {
+ componentFunctionScriptingService.cleanupInstance(any(), any())
+ } returns mockk()
+
val raRuntimeService = mockk<ResourceAssignmentRuntimeService>()
every { raRuntimeService.bluePrintContext() } returns mockk<BluePrintContext>()
every { raRuntimeService.getInputValue("test-property") } returns NullNode.getInstance()
@@ -96,6 +100,10 @@ class CapabilityResourceResolutionProcessorTest {
.scriptInstance<ResourceAssignmentProcessor>(any(), BluePrintConstants.SCRIPT_JYTHON, any())
} returns MockCapabilityScriptRA()
+ coEvery {
+ componentFunctionScriptingService.cleanupInstance(any(), any())
+ } returns mockk()
+
val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext)
val capabilityResourceResolutionProcessor =
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
index 3251dcacb..9df8fb7d7 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/utils/ResourceAssignmentUtilsTest.kt
@@ -33,10 +33,12 @@ import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.data.DataType
import org.onap.ccsdk.cds.controllerblueprints.core.data.EntrySchema
+import org.onap.ccsdk.cds.controllerblueprints.core.data.NodeTemplate
import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceDefinition
import kotlin.test.assertEquals
data class IpAddress(val port: String, val ip: String)
@@ -46,6 +48,7 @@ data class ExpectedResponseIpAddress(val ipAddress: IpAddress)
class ResourceAssignmentUtilsTest {
private lateinit var resourceAssignmentRuntimeService: ResourceAssignmentRuntimeService
+ private lateinit var resourceAssignment: ResourceAssignment
private lateinit var inputMapToTestPrimitiveTypeWithValue: JsonNode
private lateinit var inputMapToTestPrimitiveTypeWithKeyValue: JsonNode
@@ -156,6 +159,46 @@ class ResourceAssignmentUtilsTest {
assertEquals(expected, outcome.replace("\r\n", "\n"), "unexpected outcome generated")
}
+ @Test
+ fun generate() {
+ val resourceAssignment = createResourceAssignmentForTest(null)
+ val resourceDefinition = ResourceDefinition()
+ val nodeTemplate = NodeTemplate().apply {
+ properties = mutableMapOf("resolved-payload" to JacksonUtils.jsonNode("{\"mock\": true}"))
+ }
+ resourceDefinition.sources = mutableMapOf("input" to nodeTemplate)
+ resourceDefinition.property = PropertyDefinition().apply {
+ this.description = "pnf-id"
+ this.metadata = mutableMapOf("aai-path" to "//path/in/aai")
+ }
+
+ val result = ResourceAssignmentUtils.generateResolutionSummaryData(
+ listOf(resourceAssignment), mapOf("pnf-id" to resourceDefinition))
+
+ assertEquals("""
+ {
+ "resolution-summary":[
+ {
+ "name":"pnf-id",
+ "value":null,
+ "required":null,
+ "type":"string",
+ "key-identifiers":[],
+ "dictionary-description":"pnf-id",
+ "dictionary-metadata":[
+ {"name":"aai-path","value":"//path/in/aai"}
+ ],
+ "dictionary-name":"pnf-id",
+ "dictionary-source":"input",
+ "request-payload":{"mock":true},
+ "status":null,
+ "message":null
+ }
+ ]
+ }
+ """.replace("\n|\\s".toRegex(), ""), result)
+ }
+
private fun createResourceAssignmentForTest(resourceValue: String?): ResourceAssignment {
val valueForTest = if (resourceValue == null) null else TextNode(resourceValue)
val resourceAssignmentForTest = ResourceAssignment().apply {
@@ -181,6 +224,7 @@ class ResourceAssignmentUtilsTest {
outcome,
"Unexpected outcome returned for primitive type of simple String"
)
+ assertEquals(0, resourceAssignment.keyIdentifiers.size)
outcome = prepareResponseNodeForTest(
"sample-key-value", "string", "",
@@ -191,6 +235,10 @@ class ResourceAssignmentUtilsTest {
outcome,
"Unexpected outcome returned for primitive type of key-value String"
)
+ assertEquals(
+ expectedValueToTestPrimitiveType,
+ resourceAssignment.keyIdentifiers[0].value
+ )
}
@Test
@@ -204,6 +252,13 @@ class ResourceAssignmentUtilsTest {
outcome,
"unexpected outcome returned for list of String"
)
+
+ val expectedKeyIdentifierValue = JacksonUtils.getJsonNode(outcome.map { it["ip"] })
+ assertEquals(
+ expectedKeyIdentifierValue,
+ resourceAssignment.keyIdentifiers[0].value
+ )
+
// FIXME("Map is not collection type, It is known complex type")
// outcome = prepareResponseNodeForTest(
// "mapOfString", "map", "string",
@@ -250,6 +305,9 @@ class ResourceAssignmentUtilsTest {
outcome,
"Unexpected outcome returned for complex type"
)
+ assertEquals(
+ expectedValueToTestComplexTypeWithOneOutputKeyMapping["host"],
+ resourceAssignment.keyIdentifiers[0].value)
}
@Test
@@ -263,6 +321,16 @@ class ResourceAssignmentUtilsTest {
outcome,
"Unexpected outcome returned for complex type"
)
+ assertEquals(2, resourceAssignment.keyIdentifiers.size)
+ assertEquals(
+ expectedValueToTestComplexTypeWithAllOutputKeyMapping["name"],
+ resourceAssignment.keyIdentifiers[0].value
+ )
+
+ assertEquals(
+ expectedValueToTestComplexTypeWithAllOutputKeyMapping["ipAddress"],
+ resourceAssignment.keyIdentifiers[1].value
+ )
}
private fun initInputMapAndExpectedValuesForPrimitiveType() {
@@ -359,7 +427,7 @@ class ResourceAssignmentUtilsTest {
response: Any
): JsonNode {
- val resourceAssignment = when (sourceType) {
+ resourceAssignment = when (sourceType) {
"list" -> {
prepareRADataDictionaryCollection(dictionary_source, sourceType, entrySchema)
}
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
index 906bef9a4..408eaf45b 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
@@ -45,12 +45,12 @@ suspend fun AbstractScriptComponentFunction.restconfMountDevice(
headers: Map<String, String> = mutableMapOf("Content-Type" to "application/xml")
) {
- val mountUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
+ val mountUrl = "/restconf/config/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
log.info("sending mount request, url: $mountUrl")
webClientService.exchangeResource("PUT", mountUrl, payload as String, headers)
/** Check device has mounted */
- val mountCheckUrl = "restconf/operational/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
+ val mountCheckUrl = "/restconf/operational/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
val expectedResult = """"netconf-node-topology:connection-status":"connected""""
val mountCheckExecutionBlock: suspend (Int) -> String = { tryCount: Int ->
@@ -69,6 +69,7 @@ suspend fun AbstractScriptComponentFunction.restconfMountDevice(
/**
* Generic Configure function
+ * @return The WebClientResponse from the request
*/
suspend fun AbstractScriptComponentFunction.restconfApplyDeviceConfig(
webClientService: BlueprintWebClientService,
@@ -76,14 +77,12 @@ suspend fun AbstractScriptComponentFunction.restconfApplyDeviceConfig(
configletResourcePath: String,
configletToApply: Any,
additionalHeaders: Map<String, String> = mutableMapOf("Content-Type" to "application/yang.patch+xml")
-) {
-
+): BlueprintWebClientService.WebClientResponse<String> {
log.debug("headers: $additionalHeaders")
log.info("configuring device: $deviceId, Configlet: $configletToApply")
- val applyConfigUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
+ val applyConfigUrl = "/restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
"$deviceId/$configletResourcePath"
- val result: Any = webClientService.exchangeResource("PATCH", applyConfigUrl, configletToApply as String, additionalHeaders)
- log.info("Configuration application result: $result")
+ return webClientService.exchangeResource("PATCH", applyConfigUrl, configletToApply as String, additionalHeaders)
}
suspend fun AbstractScriptComponentFunction.restconfDeviceConfig(
@@ -93,7 +92,7 @@ suspend fun AbstractScriptComponentFunction.restconfDeviceConfig(
):
BlueprintWebClientService.WebClientResponse<String> {
- val configPathUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
+ val configPathUrl = "/restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
"$deviceId/$configletResourcePath"
log.debug("sending GET request, url: $configPathUrl")
return webClientService.exchangeResource("GET", configPathUrl, "")
@@ -107,7 +106,7 @@ suspend fun AbstractScriptComponentFunction.restconfUnMountDevice(
deviceId: String,
payload: String
) {
- val unMountUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
+ val unMountUrl = "/restconf/config/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
log.info("sending unMount request, url: $unMountUrl")
webClientService.exchangeResource("DELETE", unMountUrl, "")
}
diff --git a/ms/blueprintsprocessor/functions/nrm-restful/pom.xml b/ms/blueprintsprocessor/functions/restful-executor/pom.xml
index 337e71e15..4ac52c4b8 100644
--- a/ms/blueprintsprocessor/functions/nrm-restful/pom.xml
+++ b/ms/blueprintsprocessor/functions/restful-executor/pom.xml
@@ -24,11 +24,10 @@
</parent>
<groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId>
- <artifactId>nrm-restful</artifactId>
- <packaging>jar</packaging>
+ <artifactId>restful-executor</artifactId>
- <name>Blueprints Processor Function - NRM Restful</name>
- <description>Blueprints Processor Function - NRM Restful</description>
+ <name>Blueprints Processor Function - NRM Restful executor</name>
+ <description>Blueprints Processor Function - NRM Restful executor</description>
<dependencies>
<dependency>
@@ -48,5 +47,10 @@
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/internal/scripts/TestRestfulConfigure.kt b/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/internal/scripts/TestRestfulConfigure.kt
new file mode 100644
index 000000000..5f867b93f
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/internal/scripts/TestRestfulConfigure.kt
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2020 Huawei.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+@file:Suppress("unused")
+
+package internal.scripts
+
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.restful.executor.RestfulCMComponentFunction
+import org.slf4j.LoggerFactory
+
+/**
+ * This is for used for Testing only
+ */
+open class TestRestfulConfigure : RestfulCMComponentFunction() {
+
+ val log = LoggerFactory.getLogger(TestRestfulConfigure::class.java)!!
+
+ override fun getName(): String {
+ return "TestRestfulConfigure"
+ }
+
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+ log.info("processing request..")
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ log.info("recovering..")
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/ComponentRestfulExecutor.kt b/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/ComponentRestfulExecutor.kt
new file mode 100644
index 000000000..e1643b576
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/ComponentRestfulExecutor.kt
@@ -0,0 +1,69 @@
+/*
+ * Copyright © 2020 Huawei Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.restful.executor
+
+import com.fasterxml.jackson.databind.node.ArrayNode
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestLibConstants
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
+import org.onap.ccsdk.cds.controllerblueprints.core.getAsString
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Component("component-restful-executor")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ComponentRestfulExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService) : AbstractComponentFunction() {
+
+ lateinit var scriptComponent: RestfulCMComponentFunction
+
+ companion object {
+ const val SCRIPT_TYPE = "script-type"
+ const val SCRIPT_CLASS_REFERENCE = "script-class-reference"
+ const val INSTANCE_DEPENDENCIES = "instance-dependencies"
+ }
+
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+
+ val scriptType = operationInputs.getAsString(SCRIPT_TYPE)
+ val scriptClassReference = operationInputs.getAsString(SCRIPT_CLASS_REFERENCE)
+ val instanceDependenciesNode = operationInputs.get(INSTANCE_DEPENDENCIES) as? ArrayNode
+
+ val scriptDependencies: MutableList<String> = arrayListOf()
+ scriptDependencies.add(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
+
+ instanceDependenciesNode?.forEach { instanceName ->
+ scriptDependencies.add(instanceName.textValue())
+ }
+ /**
+ * Populate the Script Instance based on the Type
+ */
+ scriptComponent = componentFunctionScriptingService
+ .scriptInstance<RestfulCMComponentFunction>(this, scriptType,
+ scriptClassReference, scriptDependencies)
+
+ checkNotNull(scriptComponent) { "failed to get restfulCM script component" }
+
+ // Handles both script processing and error handling
+ scriptComponent.executeScript(executionServiceInput)
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ bluePrintRuntimeService.getBluePrintError()
+ .addError("Failed in ComponentRestfulExecutor : ${runtimeException.message}")
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/RestfulCMComponentFunction.kt b/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/RestfulCMComponentFunction.kt
new file mode 100644
index 000000000..46fec3126
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/RestfulCMComponentFunction.kt
@@ -0,0 +1,126 @@
+/*
+ * Copyright © 2020 Huawei.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.restful.executor
+
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.ObjectMapper
+import com.fasterxml.jackson.databind.node.ObjectNode
+import com.fasterxml.jackson.databind.node.ArrayNode
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestLibConstants
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
+import org.onap.ccsdk.cds.blueprintsprocessor.functions.restful.executor.nrmfunction.RestfulNRMServiceClient
+import org.slf4j.LoggerFactory
+
+abstract class RestfulCMComponentFunction : AbstractScriptComponentFunction() {
+
+ private val log = LoggerFactory.getLogger(RestfulCMComponentFunction::class.java)
+ override suspend fun processNB(executionRequest: ExecutionServiceInput) {
+ throw BluePrintException("Not Implemented required")
+ }
+
+ override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ throw BluePrintException("Not Implemented required")
+ }
+
+ open fun bluePrintRestLibPropertyService(): BluePrintRestLibPropertyService =
+ functionDependencyInstanceAsType(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
+
+ fun restClientService(clientInfo: JsonNode): BlueprintWebClientService {
+ return bluePrintRestLibPropertyService().blueprintWebClientService(clientInfo)
+ }
+
+ fun processNRM(executionRequest: ExecutionServiceInput, input_params: ArrayNode): String {
+ // process the managed object instances
+ log.info("Processing NRM Object")
+ operationInputs = executionServiceInput.stepData!!.properties
+ val dynamic_properties = operationInputs.get("dynamic-properties")
+ // instantiate one restClientService instance
+ val hostname = dynamic_properties?.get("hostname").toString().replace("\"", "")
+ val port = dynamic_properties?.get("port").toString().replace("\"", "")
+ val username = dynamic_properties?.get("username").toString().replace("\"", "")
+ val password = dynamic_properties?.get("password").toString().replace("\"", "")
+ val url = "http://" + hostname + ":" + port
+ val RestInfo: String = "{\n" +
+ " \"type\" : \"basic-auth\",\n" +
+ " \"url\" : \"" + url + "\",\n" +
+ " \"username\" : \"" + username + "\",\n" +
+ " \"password\" : \"" + password + "\"\n" +
+ "}"
+ val mapper = ObjectMapper()
+ val jsonRestInfo: JsonNode = mapper.readTree(RestInfo)
+ val web_client_service = restClientService(jsonRestInfo)
+ val managed_object_instances = input_params
+ var response = JacksonUtils.jsonNode("{}") as ObjectNode
+ // Invoke the corresponding function according to the workflowname
+ when (this.workflowName) {
+ "config-deploy" -> {
+ for (managed_object_instance in managed_object_instances) {
+ // invoke createMOI for each managed-object-instance
+ log.info("invoke createMOI for each managed-object-instance")
+ var NRM_Restful_client = RestfulNRMServiceClient()
+ val MOI_id = NRM_Restful_client.generateMOIid()
+ var httpresponse = NRM_Restful_client.createMOI(web_client_service, MOI_id, managed_object_instance)
+ var MOIname = managed_object_instance.get("className").toString().replace("\"", "")
+ response.put("/$MOIname/$MOI_id", httpresponse)
+ }
+ }
+ "config-get" -> {
+ for (managed_object_instance in managed_object_instances) {
+ // invoke getMOIAttributes for each managed-object-instance
+ log.info("invoke getMOIAttributes for each managed-object-instance")
+ var NRM_Restful_client = RestfulNRMServiceClient()
+ val MOI_id = managed_object_instance.get("id").toString().replace("\"", "")
+ var httpresponse = NRM_Restful_client.getMOIAttributes(web_client_service, MOI_id, managed_object_instance)
+ var MOIname = managed_object_instance.get("className").toString().replace("\"", "")
+ response.put("/$MOIname/$MOI_id", httpresponse)
+ }
+ }
+ "config-modify" -> {
+ for (managed_object_instance in managed_object_instances) {
+ // invoke modifyMOIAttributes for each managed-object-instance
+ log.info("invoke modifyMOIAttributes for each managed-object-instance")
+ var NRM_Restful_client = RestfulNRMServiceClient()
+ val MOI_id = managed_object_instance.get("id").toString().replace("\"", "")
+ var httpresponse = NRM_Restful_client.modifyMOIAttributes(web_client_service, MOI_id, managed_object_instance)
+ var MOIname = managed_object_instance.get("className").toString().replace("\"", "")
+ response.put("/$MOIname/$MOI_id", httpresponse)
+ }
+ }
+ "config-delete" -> {
+ for (managed_object_instance in managed_object_instances) {
+ // invoke deleteMOI for each managed-object-instance
+ log.info("invoke deleteMOI for each managed-object-instance")
+ var NRM_Restful_client = RestfulNRMServiceClient()
+ val MOI_id = managed_object_instance.get("id").toString().replace("\"", "")
+ var httpresponse = NRM_Restful_client.deleteMOI(web_client_service, MOI_id, managed_object_instance)
+ var MOIname = managed_object_instance.get("className").toString().replace("\"", "")
+ response.put("/$MOIname/$MOI_id", httpresponse)
+ }
+ }
+ else -> {
+ print("not Implemented")
+ response.put(this.workflowName, "Not Implemented")
+ }
+ }
+ val strresponse = "$response"
+ return strresponse
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/nrm-restful/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/nrm/restful/RestfulNRMServiceClient.kt b/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/nrmfunction/RestfulNRMServiceClient.kt
index eb14d255b..31ad377c9 100644
--- a/ms/blueprintsprocessor/functions/nrm-restful/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/nrm/restful/RestfulNRMServiceClient.kt
+++ b/ms/blueprintsprocessor/functions/restful-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restful/executor/nrmfunction/RestfulNRMServiceClient.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onap.ccsdk.cds.blueprintsprocessor.functions.nrm.restful
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.restful.executor.nrmfunction
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.ObjectMapper
diff --git a/ms/blueprintsprocessor/functions/restful-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/restful/executor/ComponentRestfulExecutorTest.kt b/ms/blueprintsprocessor/functions/restful-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/restful/executor/ComponentRestfulExecutorTest.kt
new file mode 100644
index 000000000..ad70ac021
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/restful-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/restful/executor/ComponentRestfulExecutorTest.kt
@@ -0,0 +1,105 @@
+/*
+ * Copyright © 2020 Huawei Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.restful.executor
+
+import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ObjectNode
+import io.mockk.every
+import io.mockk.mockk
+import kotlinx.coroutines.runBlocking
+import org.junit.Test
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ActionIdentifiers
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.CommonHeader
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.StepData
+import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.data.Implementation
+import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.cds.controllerblueprints.core.service.DefaultBluePrintRuntimeService
+import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.context.ApplicationContext
+
+class ComponentRestfulExecutorTest {
+
+ @Test
+ fun testComponentRestfulExecutor() {
+ runBlocking {
+
+ val applicationContext = mockk<ApplicationContext>()
+ every { applicationContext.getBean(any()) } returns mockk()
+
+ val componentFunctionScriptingService = ComponentFunctionScriptingService(applicationContext, mockk())
+
+ val componentRestfulExecutor = ComponentRestfulExecutor(componentFunctionScriptingService)
+
+ val executionServiceInput = ExecutionServiceInput().apply {
+ commonHeader = CommonHeader().apply {
+ requestId = "1234"
+ }
+ actionIdentifiers = ActionIdentifiers().apply {
+ actionName = "config-deploy"
+ }
+ payload = JacksonUtils.jsonNode("{}") as ObjectNode
+ }
+
+ val blueprintContext = mockk<BluePrintContext>()
+ every {
+ blueprintContext.nodeTemplateOperationImplementation(
+ any(), any(), any()
+ )
+ } returns Implementation()
+
+ val bluePrintRuntime = mockk<DefaultBluePrintRuntimeService>("1234")
+ every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
+
+ componentRestfulExecutor.bluePrintRuntimeService = bluePrintRuntime
+ componentRestfulExecutor.stepName = "sample-step"
+
+ val operationInputs = hashMapOf<String, JsonNode>()
+ operationInputs[BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE] = "config-deploy-process".asJsonPrimitive()
+ operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = "interfaceName".asJsonPrimitive()
+ operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive()
+ operationInputs["script-type"] = BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive()
+ operationInputs["script-class-reference"] = "internal.scripts.TestRestfulConfigure".asJsonPrimitive()
+
+ val stepInputData = StepData().apply {
+ name = "call-config-deploy-process"
+ properties = operationInputs
+ }
+ executionServiceInput.stepData = stepInputData
+
+ every {
+ bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs(
+ "config-deploy-process",
+ "interfaceName", "operationName"
+ )
+ } returns operationInputs
+
+ val operationOutputs = hashMapOf<String, JsonNode>()
+ every {
+ bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs(
+ "config-deploy-process",
+ "interfaceName", "operationName"
+ )
+ } returns operationOutputs
+
+ componentRestfulExecutor.applyNB(executionServiceInput)
+ }
+ }
+}
diff --git a/ms/blueprintsprocessor/functions/nrm-restful/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nrm/restful/RestfulNRMServiceClientTest.kt b/ms/blueprintsprocessor/functions/restful-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/restful/executor/nrmfunction/RestfulNRMServiceClientTest.kt
index 8dcb7975d..e7f04a5d4 100644
--- a/ms/blueprintsprocessor/functions/nrm-restful/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/nrm/restful/RestfulNRMServiceClientTest.kt
+++ b/ms/blueprintsprocessor/functions/restful-executor/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/restful/executor/nrmfunction/RestfulNRMServiceClientTest.kt
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.onap.ccsdk.cds.blueprintsprocessor.functions.nrm.restful
+package org.onap.ccsdk.cds.blueprintsprocessor.functions.restful.executor.nrmfunction
import com.fasterxml.jackson.databind.node.ObjectNode
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils