aboutsummaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt
diff options
context:
space:
mode:
authorgummar <raj.gumma@est.tech>2020-02-18 18:54:44 +0000
committerKAPIL SINGAL <ks220y@att.com>2020-02-26 15:23:42 +0000
commit94ad509756f17e79c278e3cc2f87440009125cd1 (patch)
treeccd6a842eb0fdca66689b2569cd71cb78ec81cd2 /components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt
parentac31d2159014a84de91b6c7baeb29adf90284c10 (diff)
Merge SW Upgrade Blueprint into PNF_AAI and create one UAT BP for PNF
UAT: Add support to multiple responses for a single request Set property IN_UAT=1 during UAT execution so blueprints can tune their settings to values more suitable for testing (like timeouts) Add 'times' field to specify expected number of invocations Add UAT blueprint script for PNF SW Upgrade UC Add current thread check for Hazelcast distributed lock Resolve URI before returning Issue-ID: CCSDK-2091 Change-Id: Id256bad043488f88f1b60015ebf9ade4be607fa2 Signed-off-by: gummar <raj.gumma@est.tech>
Diffstat (limited to 'components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt')
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt93
1 files changed, 0 insertions, 93 deletions
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt
deleted file mode 100644
index f0190e8ec..000000000
--- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* Copyright (C) 2019 Nordix Foundation.
-* ================================================================================
-* 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.
-* ============LICENSE_END=========================================================
- */
-
-
-package cba.pnf.config.aai
-
-
-import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.contentFromResolvedArtifactNB
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifactNB
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfMountDevice
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfApplyDeviceConfig
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfUnMountDevice
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfDeviceConfig
-import org.onap.ccsdk.cds.blueprintsprocessor.functions.restconf.executor.restconfClientService
-import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
-import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.cds.controllerblueprints.core.logger
-import com.fasterxml.jackson.databind.ObjectMapper
-import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService.WebClientResponse
-
-class RestconfConfigDeploy : AbstractScriptComponentFunction() {
- private val CONFIGLET_TEMPLATE_NAME = "config-assign"
- private val CONFIGLET_RESOURCE_PATH = "yang-ext:mount/mynetconf:netconflist"
- private val RESTCONF_SERVER_IDENTIFIER = "sdnc"
- private val mapper = ObjectMapper()
- private val log = logger(AbstractScriptComponentFunction::class.java)
-
- override suspend fun processNB(executionRequest: ExecutionServiceInput) {
- log.info("Started execution of process method")
- try {
- // Extract Resolution key & Device ID
- val resolutionKey = getDynamicProperties("resolution-key").asText()
- log.info("resolution_key: $resolutionKey")
- val deviceID: String = requestPayloadActionProperty("config-deploy-properties")?.get(0)?.get("pnf-id")?.textValue()!!
- log.info("device_id: $deviceID")
- val webclientService = restconfClientService(RESTCONF_SERVER_IDENTIFIER)
-
- try {
- // Mount the device
- val mountPayload = contentFromResolvedArtifactNB("config-deploy")
- log.debug("Mounting Device : $deviceID")
- restconfMountDevice(webclientService, deviceID, mountPayload, mutableMapOf("Content-Type" to "application/json"))
-
- //Log the current configuration for the subtree
- val currentConfig: Any = restconfDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH)
- log.info("Current configuration subtree : $currentConfig")
- //Apply configlet
- val result = restconfApplyDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH,
- storedContentFromResolvedArtifactNB(resolutionKey, CONFIGLET_TEMPLATE_NAME),
- mutableMapOf("Content-Type" to "application/yang.patch+json")) as WebClientResponse<*>
-
- val jsonResult = mapper.readTree((result.body).toString())
-
- if(jsonResult.get("ietf-yang-patch:yang-patch-status").get("errors") != null) {
- log.error("There was an error configuring device")
- } else {
- log.info("Device has been configured succesfully")
- }
-
- } catch (err: Exception) {
- log.error("an error occurred while configuring device {}", err)
- } finally {
- //Un mount device
- restconfUnMountDevice(webclientService, deviceID, "")
- }
- } catch (bpe: BluePrintProcessorException) {
- log.error("Error looking up server identifier ", bpe)
- }
- }
-
-
- override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
- log.info("Recover function called!")
- log.info("Execution request : $executionRequest")
- log.error("Exception", runtimeException)
- }
-} \ No newline at end of file