aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/restconf-executor
diff options
context:
space:
mode:
authorgummar <raj.gumma@est.tech>2019-11-06 11:48:57 +0000
committergummar <raj.gumma@est.tech>2019-11-22 18:14:04 +0000
commit73a34e905c6abdad567b7063c6e9c3aaa1e42f07 (patch)
tree782455409170a0d09514f31b2ccaa7de4725ce7c /ms/blueprintsprocessor/functions/restconf-executor
parent4dfd7d6f90445fb0a52ccff0a683c8240e4ee9b1 (diff)
CCSDK-1864 : PNF Use Case Move from Jython to Kotlin using CDS Framework
Change-Id: I58eb134a07345d25be6d64dc614f25fc73ecf554 Signed-off-by: gummar <raj.gumma@est.tech> Issue-ID: CCSDK-1864
Diffstat (limited to 'ms/blueprintsprocessor/functions/restconf-executor')
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt19
1 files changed, 10 insertions, 9 deletions
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
index 49fd025d9..11a35eede 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt
@@ -39,19 +39,20 @@ fun AbstractScriptComponentFunction.restconfClientService(selector: String): Blu
*/
suspend fun AbstractScriptComponentFunction.restconfMountDevice(webClientService: BlueprintWebClientService,
- deviceId: String, payload: Any) {
- val headers: MutableMap<String, String> = hashMapOf()
- headers["Content-Type"] = "application/xml"
+ deviceId: String,
+ payload: Any,
+ headers: Map<String, String> = mutableMapOf("Content-Type" to "application/xml")) {
+
val mountUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
log.info("sending mount request, url: $mountUrl")
- webClientService.exchangeNB("PUT", mountUrl, payload, headers)
+ webClientService.exchangeResource("PUT", mountUrl, payload as String, headers)
/** Check device has mounted */
val mountCheckUrl = "restconf/operational/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
val expectedResult = """"netconf-node-topology:connection-status":"connected""""
val mountCheckExecutionBlock: suspend (Int) -> String = { tryCount: Int ->
- val result = webClientService.exchangeNB("GET", mountCheckUrl, "")
+ val result = webClientService.exchangeResource("GET", mountCheckUrl, "")
if (result.body.contains(expectedResult)) {
log.info("NF was mounted successfully on ODL")
result.body
@@ -70,13 +71,13 @@ suspend fun AbstractScriptComponentFunction.restconfMountDevice(webClientService
suspend fun AbstractScriptComponentFunction.restconfApplyDeviceConfig(webClientService: BlueprintWebClientService,
deviceId: String, configletResourcePath: String,
configletToApply: Any,
- additionalHeaders: Map<String, String>?) {
+ additionalHeaders: Map<String, String > = mutableMapOf("Content-Type" to "application/yang.patch+xml")) {
log.debug("headers: $additionalHeaders")
log.info("configuring device: $deviceId, Configlet: $configletToApply")
val applyConfigUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
"$deviceId/$configletResourcePath"
- val result = webClientService.exchangeNB("PATCH", applyConfigUrl, configletToApply, additionalHeaders)
+ val result:Any = webClientService.exchangeResource("PATCH", applyConfigUrl, configletToApply as String, additionalHeaders)
log.info("Configuration application result: $result")
}
@@ -88,7 +89,7 @@ suspend fun AbstractScriptComponentFunction.restconfDeviceConfig(webClientServic
val configPathUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/" +
"$deviceId/$configletResourcePath"
log.debug("sending GET request, url: $configPathUrl")
- return webClientService.exchangeNB("GET", configPathUrl, "")
+ return webClientService.exchangeResource("GET", configPathUrl, "")
}
/**
@@ -98,5 +99,5 @@ suspend fun AbstractScriptComponentFunction.restconfUnMountDevice(webClientServi
deviceId: String, payload: String) {
val unMountUrl = "restconf/config/network-topology:network-topology/topology/topology-netconf/node/$deviceId"
log.info("sending unMount request, url: $unMountUrl")
- webClientService.exchangeNB("DELETE", unMountUrl, "")
+ webClientService.exchangeResource("DELETE", unMountUrl, "")
} \ No newline at end of file