aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKAPIL SINGAL <ks220y@att.com>2020-09-09 13:10:26 +0000
committerGerrit Code Review <gerrit@onap.org>2020-09-09 13:10:26 +0000
commitda970292a1ac53a93c9fcb4c28df43946fa8b293 (patch)
tree9a629e0571056da8c9a95e3a6fbfc8e8eacf9b00
parentdbf58e985a064a8a499ce2db4643b3b5c602d625 (diff)
parent15f1d7121c4735c1dd33a80930d9cd61e58ac050 (diff)
Merge "Changed method of k8s-upload-profile template prefix acquisition"
-rw-r--r--components/model-catalog/definition-type/starter-type/node_type/component-k8s-profile-upload.json8
-rw-r--r--ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt23
2 files changed, 25 insertions, 6 deletions
diff --git a/components/model-catalog/definition-type/starter-type/node_type/component-k8s-profile-upload.json b/components/model-catalog/definition-type/starter-type/node_type/component-k8s-profile-upload.json
index ac7c95cd8..d7b4bb990 100644
--- a/components/model-catalog/definition-type/starter-type/node_type/component-k8s-profile-upload.json
+++ b/components/model-catalog/definition-type/starter-type/node_type/component-k8s-profile-upload.json
@@ -42,6 +42,14 @@
"required": false,
"type": "string"
},
+ "artifact-prefix-names": {
+ "description": "Resource Assignment Artifact Prefix names",
+ "required": false,
+ "type": "list",
+ "entry_schema": {
+ "type": "string"
+ }
+ },
"resource-assignment-map": {
"description": "Holds resolved values for each artifact prefix eg. { vdns: { vnf-id: 123 } }",
"required": false,
diff --git a/ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt b/ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt
index 0ae76ea7e..337104551 100644
--- a/ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt
+++ b/ms/blueprintsprocessor/functions/k8s-profile-upload/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/k8s/profile/upload/K8sProfileUploadComponent.kt
@@ -20,6 +20,7 @@
package org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.profile.upload
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.ObjectNode
import org.apache.commons.io.FileUtils
import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintPropertiesService
@@ -63,6 +64,7 @@ open class K8sProfileUploadComponent(
const val INPUT_K8S_PROFILE_NAMESPACE = "k8s-rb-profile-namespace"
const val INPUT_K8S_PROFILE_SOURCE = "k8s-rb-profile-source"
const val INPUT_RESOURCE_ASSIGNMENT_MAP = "resource-assignment-map"
+ const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_STATUSES = "statuses"
const val OUTPUT_SKIPPED = "skipped"
@@ -80,7 +82,8 @@ open class K8sProfileUploadComponent(
INPUT_K8S_DEFINITION_NAME,
INPUT_K8S_DEFINITION_VERSION,
INPUT_K8S_PROFILE_NAMESPACE,
- INPUT_K8S_PROFILE_SOURCE
+ INPUT_K8S_PROFILE_SOURCE,
+ INPUT_ARTIFACT_PREFIX_NAMES
)
var outputPrefixStatuses = mutableMapOf<String, String>()
var inputParamsMap = mutableMapOf<String, JsonNode?>()
@@ -90,7 +93,7 @@ open class K8sProfileUploadComponent(
}
log.info("Getting the template prefixes")
- val prefixList: ArrayList<String> = getTemplatePrefixList(executionRequest)
+ val prefixList: ArrayList<String> = getTemplatePrefixList(inputParamsMap[INPUT_ARTIFACT_PREFIX_NAMES])
log.info("Iterating over prefixes in resource assignment map.")
for (prefix in prefixList) {
@@ -175,10 +178,18 @@ open class K8sProfileUploadComponent(
bluePrintRuntimeService.getBluePrintError().addError(runtimeException.message!!)
}
- fun getTemplatePrefixList(executionRequest: ExecutionServiceInput): ArrayList<String> {
- val result = ArrayList<String>()
- for (prefix in executionRequest.payload.get("resource-assignment-request").get("template-prefix").elements())
- result.add(prefix.asText())
+ private fun getTemplatePrefixList(node: JsonNode?): ArrayList<String> {
+ var result = ArrayList<String>()
+ when (node) {
+ is ArrayNode -> {
+ val arrayNode = node.toList()
+ for (prefixNode in arrayNode)
+ result.add(prefixNode.asText())
+ }
+ is ObjectNode -> {
+ result.add(node.asText())
+ }
+ }
return result
}