summaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfConfigDeploy.kt
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2020-09-22 12:16:46 -0400
committerSingal, Kapil (ks220y) <ks220y@att.com>2020-09-22 13:49:05 -0400
commit1072867dfac0df993cbd3e44bcc11a5cac7465fd (patch)
tree4a821659cf3b50cf946cbb535d528be8508e9fff /components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfConfigDeploy.kt
parentd97021cd756d63402545fdc2e14ac7611c3da118 (diff)
Enabling Code Formatter
Code Formatter was turned off due to java 11 migation Issue-ID: CCSDK-2852 Signed-off-by: Singal, Kapil (ks220y) <ks220y@att.com> Change-Id: I3d02ed3cc7a93d7551fe25356512cfe8db1517d8
Diffstat (limited to 'components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfConfigDeploy.kt')
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfConfigDeploy.kt21
1 files changed, 10 insertions, 11 deletions
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfConfigDeploy.kt b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfConfigDeploy.kt
index 730565959..154792873 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfConfigDeploy.kt
+++ b/components/model-catalog/blueprint-model/uat-blueprints/PNF_CDS_RESTCONF/Scripts/kotlin/RestconfConfigDeploy.kt
@@ -16,10 +16,8 @@
* ============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
@@ -35,6 +33,7 @@ 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"
@@ -57,13 +56,15 @@ class RestconfConfigDeploy : AbstractScriptComponentFunction() {
log.debug("Mounting Device : $deviceID")
restconfMountDevice(webclientService, deviceID, mountPayload, mutableMapOf("Content-Type" to "application/json"))
- //Log the current configuration for the subtree
+ // 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<*>
+ // 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())
@@ -72,11 +73,10 @@ class RestconfConfigDeploy : AbstractScriptComponentFunction() {
} else {
log.info("Device has been configured succesfully")
}
-
} catch (err: Exception) {
log.error("an error occurred while configuring device {}", err)
} finally {
- //Un mount device
+ // Un mount device
restconfUnMountDevice(webclientService, deviceID, "")
}
} catch (bpe: BluePrintProcessorException) {
@@ -84,10 +84,9 @@ class RestconfConfigDeploy : AbstractScriptComponentFunction() {
}
}
-
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
+}