Add cofig-assign and config-deploy to cds workflow
[demo.git] / heat / vFW_CNF_CDS / templates / cba / Scripts / kotlin / ConfigDeploy.kt
1 /*
2  * Copyright © 2020 Aarna Networks, Inc. 
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.ccsdk.cds.blueprintsprocessor.services.execution.scripts
18
19 import com.fasterxml.jackson.databind.node.ObjectNode
20 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
21 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
22 import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties
23 import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties
24 import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService
25 import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
26 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
27 import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
28 import org.slf4j.LoggerFactory
29 import org.springframework.http.HttpMethod
30 import org.springframework.web.client.RestTemplate
31
32 open class ConfigDeploy : AbstractScriptComponentFunction() {
33
34     private val log = LoggerFactory.getLogger(ConfigDeploy::class.java)!!
35
36     override suspend fun processNB(executionRequest: ExecutionServiceInput) {
37
38         /*
39          * Resolution key will come as part of config-deploy request payload.
40          */
41
42         val resolution_key = getDynamicProperties("resolution-key").asText()
43         log.info("Got the resolution_key: $resolution_key from config-deploy going to retrive the data from DB")
44
45         // Read the config-assing data using the resolution key + prefix name for the template
46         // We can select the given configuration using the resolution_key
47         val prefix = "cnf"
48         val payload = storedContentFromResolvedArtifactNB(resolution_key, prefix)
49         log.info("cnf configuration data from DB : \n$payload\n")
50
51         println("Run config-deploy")
52         println("$payload")
53
54     }
55
56     override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
57         log.info("Executing Recovery")
58     }
59 }