Implementation of config-assign and config-deploy actions
[demo.git] / heat / vFW_CNF_CDS / templates / cba / Scripts / kotlin / ConfigDeploy.kt
index c484960..861cdf6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2020 Aarna Networks, Inc. 
+ * Copyright © 2021 Orange
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
 
-import com.fasterxml.jackson.databind.node.ObjectNode
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
 import org.slf4j.LoggerFactory
-import org.springframework.http.HttpMethod
-import org.springframework.web.client.RestTemplate
 
 open class ConfigDeploy : AbstractScriptComponentFunction() {
 
     private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!!
 
-    override suspend fun processNB(executionRequest: ExecutionServiceInput) {
-
-        /*
-         * Resolution key will come as part of config-deploy request payload.
-         */
+    override fun getName(): String {
+        return "ConfigDeploy"
+    }
 
+    override suspend fun processNB(executionRequest: ExecutionServiceInput) {
         val resolution_key = getDynamicProperties("resolution-key").asText()
-        log.info("Got the resolution_key: $resolution_key from config-deploy going to retrive the data from DB")
+        log.info("Got the resolution_key: $resolution_key from config-deploy going to retrieve the data from DB")
+        val prefix = "config-deploy" // used in the config-assign resolution
 
-        // Read the config-assing data using the resolution key + prefix name for the template
-        // We can select the given configuration using the resolution_key
-        val prefix = "cnf"
         val payload = storedContentFromResolvedArtifactNB(resolution_key, prefix)
         log.info("cnf configuration data from DB : \n$payload\n")
 
         println("Run config-deploy")
         println("$payload")
-
     }
 
     override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
         log.info("Executing Recovery")
+        this.addError("${runtimeException.message}")
     }
 }