From 4193053d0fc30b688f991e2356e2c0cd6c446a57 Mon Sep 17 00:00:00 2001 From: Lukasz Rajewski Date: Mon, 14 Nov 2022 14:48:24 +0100 Subject: [APACHECNF] CDS workflows for upgrade scenario Issue-ID: INT-2164 Signed-off-by: Lukasz Rajewski Change-Id: Icfa9dd7d90abb3da2b0cf388cfb1e3a27e8edd6d --- .../cba/Scripts/kotlin/ConfigDeploySetup.kt | 17 +++++++-- .../cba/Scripts/kotlin/SimpleErrorCheck.kt | 41 ---------------------- .../templates/cba/Scripts/kotlin/SimpleScript.kt | 41 ++++++++++++++++++++++ .../cba/Scripts/kotlin/SimpleStatusCheck.kt | 4 +-- 4 files changed, 58 insertions(+), 45 deletions(-) delete mode 100644 tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleErrorCheck.kt create mode 100644 tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleScript.kt (limited to 'tutorials/ApacheCNF/templates/cba/Scripts/kotlin') diff --git a/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/ConfigDeploySetup.kt b/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/ConfigDeploySetup.kt index f925be06..c57ca758 100644 --- a/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/ConfigDeploySetup.kt +++ b/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/ConfigDeploySetup.kt @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition.template.K8sConfigTemplateComponent import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition.template.K8sConfigValueComponent +import org.onap.ccsdk.cds.blueprintsprocessor.functions.k8s.definition.profile.K8sProfileUploadComponent import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException @@ -100,13 +101,23 @@ open class ConfigDeploySetup() : ResourceAssignmentProcessor() { val modelInfo = modelTopology["onap-model-information"] val moduleData: ObjectNode = objectMapper.createObjectNode() result.put(label, moduleData) - moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_DEFINITION_NAME, modelInfo["model-invariant-uuid"].asText()) - moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_DEFINITION_VERSION, modelInfo["model-customization-uuid"].asText()) + val profileName: String? = getParamValueByName(moduleParameters, K8sProfileUploadComponent.INPUT_K8S_PROFILE_NAME) + val profileSource: String? = getParamValueByName(moduleParameters, K8sProfileUploadComponent.INPUT_K8S_PROFILE_SOURCE) + val profileNamespace: String? = getParamValueByName(moduleParameters, K8sProfileUploadComponent.INPUT_K8S_PROFILE_NAMESPACE) + val profileK8sVersion: String? = getParamValueByName(moduleParameters, K8sProfileUploadComponent.INPUT_K8S_PROFILE_K8S_VERSION) val templateName: String? = getParamValueByName(moduleParameters, K8sConfigTemplateComponent.INPUT_K8S_TEMPLATE_NAME) val templateSource: String? = getParamValueByName(moduleParameters, K8sConfigTemplateComponent.INPUT_K8S_TEMPLATE_SOURCE) val configValueSource: String? = getParamValueByName(moduleParameters, K8sConfigValueComponent.INPUT_K8S_CONFIG_VALUE_SOURCE) val configName: String? = getParamValueByName(moduleParameters, K8sConfigValueComponent.INPUT_K8S_RB_CONFIG_NAME) + if (profileName != null) + moduleData.put(K8sProfileUploadComponent.INPUT_K8S_PROFILE_NAME, profileName) + if (profileSource != null) + moduleData.put(K8sProfileUploadComponent.INPUT_K8S_PROFILE_SOURCE, profileSource) + if (profileNamespace != null) + moduleData.put(K8sProfileUploadComponent.INPUT_K8S_PROFILE_NAMESPACE, profileNamespace) + if (profileK8sVersion != null) + moduleData.put(K8sProfileUploadComponent.INPUT_K8S_PROFILE_K8S_VERSION, profileK8sVersion) if (templateName != null) moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_TEMPLATE_NAME, templateName) if (templateSource != null) @@ -119,6 +130,8 @@ open class ConfigDeploySetup() : ResourceAssignmentProcessor() { for (aaiModule in modulesAai) { if (aaiModule["vf-module-id"].asText() == module["vf-module-id"].asText() && aaiModule["heat-stack-id"] != null) { moduleData.put(K8sConfigValueComponent.INPUT_K8S_INSTANCE_ID, aaiModule["heat-stack-id"].asText()) + moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_DEFINITION_NAME, aaiModule["model-invariant-id"].asText()) + moduleData.put(K8sConfigTemplateComponent.INPUT_K8S_DEFINITION_VERSION, aaiModule["model-customization-id"].asText()) break } } diff --git a/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleErrorCheck.kt b/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleErrorCheck.kt deleted file mode 100644 index 8e4a58ab..00000000 --- a/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleErrorCheck.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - * 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.services.execution.scripts - -import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput -import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction -import org.slf4j.LoggerFactory - -open class SimpleErrorCheck : AbstractScriptComponentFunction() { - - private val log = LoggerFactory.getLogger(SimpleErrorCheck::class.java)!! - - override fun getName(): String { - return "SimpleErrorCheck" - } - - override suspend fun processNB(executionRequest: ExecutionServiceInput) { - log.info("SIMPLE ERROR CHECK - START") - - log.info("SIMPLE ERROR CHECK - END") - } - - override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { - log.info("Executing Recovery") - this.addError("${runtimeException.message}") - } -} diff --git a/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleScript.kt b/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleScript.kt new file mode 100644 index 00000000..6849654d --- /dev/null +++ b/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleScript.kt @@ -0,0 +1,41 @@ +/* + * 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. + * 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.services.execution.scripts + +import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction +import org.slf4j.LoggerFactory + +open class SimpleScript : AbstractScriptComponentFunction() { + + private val log = LoggerFactory.getLogger(SimpleScript::class.java)!! + + override fun getName(): String { + return "SimpleScript" + } + + override suspend fun processNB(executionRequest: ExecutionServiceInput) { + log.info("STEP ${executionRequest.stepData?.name} - START") + + log.info("STEP ${executionRequest.stepData?.name} - STOP") + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Executing Recovery") + this.addError("${runtimeException.message}") + } +} diff --git a/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt b/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt index c1f59d98..4cef7f66 100644 --- a/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt +++ b/tutorials/ApacheCNF/templates/cba/Scripts/kotlin/SimpleStatusCheck.kt @@ -35,7 +35,7 @@ open class SimpleStatusCheck : AbstractScriptComponentFunction() { } override suspend fun processNB(executionRequest: ExecutionServiceInput) { - log.info("SIMPLE STATUS CHECK - START") + log.info("STEP ${executionRequest.stepData?.name} - START") val configValueSetup: ObjectNode = getDynamicProperties("config-deploy-setup") as ObjectNode var checkCount: Int = getDynamicProperties("status-check-max-count").asInt() @@ -71,7 +71,7 @@ open class SimpleStatusCheck : AbstractScriptComponentFunction() { checkCount = 0 } - log.info("SIMPLE STATUS CHECK - END") + log.info("STEP ${executionRequest.stepData?.name} - STOP") } override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { -- cgit