aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json6
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/pnf_config.json8
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/kotlin/RestconfConfigDeploy.kt81
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/python/RestconfConfigDeploy.py78
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json6
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/pnf_config_aai.json8
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt82
-rw-r--r--components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/python/RestconfConfigDeploy.py78
-rw-r--r--ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt4
-rw-r--r--ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt11
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt19
11 files changed, 188 insertions, 193 deletions
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json
index aa5295e44..6ec3b4105 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json
+++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/artifact_types.json
@@ -12,12 +12,6 @@
"derived_from" : "tosca.artifacts.Implementation",
"file_ext" : [ "json" ]
},
- "artifact-script-jython" : {
- "description" : "Jython Script File",
- "version" : "1.0.0",
- "derived_from" : "tosca.artifacts.Implementation",
- "file_ext" : [ "py" ]
- },
"artifact-template-velocity" : {
"description" : " Velocity Template used for Configuration",
"version" : "1.0.0",
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/pnf_config.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/pnf_config.json
index c22764056..62702b7e2 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/pnf_config.json
+++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Definitions/pnf_config.json
@@ -124,8 +124,8 @@
"operation_host" : "SELF"
},
"inputs" : {
- "script-type" : "jython",
- "script-class-reference" : "Scripts/python/RestconfConfigDeploy.py",
+ "script-type" : "kotlin",
+ "script-class-reference" : "cba.pnf.config.RestconfConfigDeploy",
"dynamic-properties" : "*config-deploy-properties"
},
"outputs" : {
@@ -144,10 +144,6 @@
"config-deploy-mapping" : {
"type" : "artifact-mapping-resource",
"file" : "Definitions/config-deploy-pnf-mapping.json"
- },
- "component-script" : {
- "type" : "artifact-script-jython",
- "file" : "Scripts/python/RestconfConfigDeploy.py"
}
}
}
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/kotlin/RestconfConfigDeploy.kt b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/kotlin/RestconfConfigDeploy.kt
new file mode 100644
index 000000000..a2372c9db
--- /dev/null
+++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/kotlin/RestconfConfigDeploy.kt
@@ -0,0 +1,81 @@
+/*
+* ============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
+
+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
+
+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 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
+ restconfApplyDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH,
+ storedContentFromResolvedArtifactNB(resolutionKey, CONFIGLET_TEMPLATE_NAME),
+ mutableMapOf("Content-Type" to "application/yang.patch+json"))
+
+ } 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
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/python/RestconfConfigDeploy.py b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/python/RestconfConfigDeploy.py
deleted file mode 100644
index af0b7e129..000000000
--- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config/Scripts/python/RestconfConfigDeploy.py
+++ /dev/null
@@ -1,78 +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=========================================================
-
-from java.lang import Exception as JavaException
-
-from restconf_client import RestconfClient
-from org.onap.ccsdk.cds.blueprintsprocessor.services.execution import AbstractScriptComponentFunction
-
-
-class RestconfConfigDeploy(AbstractScriptComponentFunction):
- log = globals()["log"]
- configlet_template_name = "config-assign"
- configlet_resource_path = "/yang-ext:mount/mynetconf:netconflist"
- restconf_server_identifier = "sdnc"
-
- def process(self, execution_request):
-
- self.log.info("Started execution of process method")
- try:
- restconf_client = RestconfClient(self.log, self)
- pnf_id, resolution_key = self.retrieve_parameters(execution_request)
- web_client_service = restconf_client.web_client_service(self.restconf_server_identifier)
-
- try:
- # mount the device
- mount_payload = restconf_client.resolve_and_generate_message_from_template_prefix("config-deploy")
- restconf_client.mount_device(web_client_service, pnf_id, mount_payload, "application/json")
-
- # log the current configuration subtree
- current_configuration = restconf_client.retrieve_device_configuration_subtree(
- web_client_service, pnf_id, self.configlet_resource_path)
- self.log.info("Current configuration subtree: {}", current_configuration)
-
- # apply configuration
- configlet = restconf_client.retrieve_resolved_template_from_database(resolution_key, self.configlet_template_name)
- restconf_client.configure_device_json_patch(
- web_client_service, pnf_id, self.configlet_resource_path, configlet)
- except Exception, err:
- self.log.error("an error occurred while configuring device {}", err)
- raise err
- finally:
- restconf_client.unmount_device(web_client_service, pnf_id)
-
- except JavaException, err:
- self.log.error("Java Exception in the script", err)
- raise err
- except Exception, err:
- self.log.error("Python Exception in the script:" + str(err), err)
- raise err
- self.log.info("Ended execution of process method")
-
- def retrieve_parameters(self, execution_request):
- resolution_key = self.getDynamicProperties("resolution-key").asText()
- self.log.info("resolution_key: {}", resolution_key)
- pnf_id = execution_request.payload.get("config-deploy-request").get("config-deploy-properties").get("pnf-id")
- pnf_id = str(pnf_id).strip('\"')
- self.log.info("pnf-id: {}", pnf_id)
- return pnf_id, resolution_key
-
- def recover(self, runtime_exception, execution_request):
- self.log.info("Recover function called!")
- self.log.info("Execution request", execution_request)
- self.log.error("Exception", runtime_exception)
- print self.bluePrintRuntimeService.getBluePrintError().addError(runtime_exception.getMessage())
- return None
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json
index aa5295e44..6ec3b4105 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json
+++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/artifact_types.json
@@ -12,12 +12,6 @@
"derived_from" : "tosca.artifacts.Implementation",
"file_ext" : [ "json" ]
},
- "artifact-script-jython" : {
- "description" : "Jython Script File",
- "version" : "1.0.0",
- "derived_from" : "tosca.artifacts.Implementation",
- "file_ext" : [ "py" ]
- },
"artifact-template-velocity" : {
"description" : " Velocity Template used for Configuration",
"version" : "1.0.0",
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/pnf_config_aai.json b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/pnf_config_aai.json
index e8a95d87f..3ef585cb4 100644
--- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/pnf_config_aai.json
+++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Definitions/pnf_config_aai.json
@@ -124,8 +124,8 @@
"operation_host" : "SELF"
},
"inputs" : {
- "script-type" : "jython",
- "script-class-reference" : "Scripts/python/RestconfConfigDeploy.py",
+ "script-type" : "kotlin",
+ "script-class-reference" : "cba.pnf.config.aai.RestconfConfigDeploy",
"dynamic-properties" : "*config-deploy-properties"
},
"outputs" : {
@@ -144,10 +144,6 @@
"config-deploy-mapping" : {
"type" : "artifact-mapping-resource",
"file" : "Definitions/config-deploy-pnf-mapping.json"
- },
- "component-script" : {
- "type" : "artifact-script-jython",
- "file" : "Scripts/python/RestconfConfigDeploy.py"
}
}
}
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
new file mode 100644
index 000000000..6a034ab94
--- /dev/null
+++ b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/kotlin/RestconfConfigDeploy.kt
@@ -0,0 +1,82 @@
+/*
+* ============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
+
+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 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
+ restconfApplyDeviceConfig(webclientService, deviceID, CONFIGLET_RESOURCE_PATH,
+ storedContentFromResolvedArtifactNB(resolutionKey, CONFIGLET_TEMPLATE_NAME),
+ mutableMapOf("Content-Type" to "application/yang.patch+json"))
+
+ } 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
diff --git a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/python/RestconfConfigDeploy.py b/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/python/RestconfConfigDeploy.py
deleted file mode 100644
index af0b7e129..000000000
--- a/components/model-catalog/blueprint-model/uat-blueprints/pnf_config_aai/Scripts/python/RestconfConfigDeploy.py
+++ /dev/null
@@ -1,78 +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=========================================================
-
-from java.lang import Exception as JavaException
-
-from restconf_client import RestconfClient
-from org.onap.ccsdk.cds.blueprintsprocessor.services.execution import AbstractScriptComponentFunction
-
-
-class RestconfConfigDeploy(AbstractScriptComponentFunction):
- log = globals()["log"]
- configlet_template_name = "config-assign"
- configlet_resource_path = "/yang-ext:mount/mynetconf:netconflist"
- restconf_server_identifier = "sdnc"
-
- def process(self, execution_request):
-
- self.log.info("Started execution of process method")
- try:
- restconf_client = RestconfClient(self.log, self)
- pnf_id, resolution_key = self.retrieve_parameters(execution_request)
- web_client_service = restconf_client.web_client_service(self.restconf_server_identifier)
-
- try:
- # mount the device
- mount_payload = restconf_client.resolve_and_generate_message_from_template_prefix("config-deploy")
- restconf_client.mount_device(web_client_service, pnf_id, mount_payload, "application/json")
-
- # log the current configuration subtree
- current_configuration = restconf_client.retrieve_device_configuration_subtree(
- web_client_service, pnf_id, self.configlet_resource_path)
- self.log.info("Current configuration subtree: {}", current_configuration)
-
- # apply configuration
- configlet = restconf_client.retrieve_resolved_template_from_database(resolution_key, self.configlet_template_name)
- restconf_client.configure_device_json_patch(
- web_client_service, pnf_id, self.configlet_resource_path, configlet)
- except Exception, err:
- self.log.error("an error occurred while configuring device {}", err)
- raise err
- finally:
- restconf_client.unmount_device(web_client_service, pnf_id)
-
- except JavaException, err:
- self.log.error("Java Exception in the script", err)
- raise err
- except Exception, err:
- self.log.error("Python Exception in the script:" + str(err), err)
- raise err
- self.log.info("Ended execution of process method")
-
- def retrieve_parameters(self, execution_request):
- resolution_key = self.getDynamicProperties("resolution-key").asText()
- self.log.info("resolution_key: {}", resolution_key)
- pnf_id = execution_request.payload.get("config-deploy-request").get("config-deploy-properties").get("pnf-id")
- pnf_id = str(pnf_id).strip('\"')
- self.log.info("pnf-id: {}", pnf_id)
- return pnf_id, resolution_key
-
- def recover(self, runtime_exception, execution_request):
- self.log.info("Recover function called!")
- self.log.info("Execution request", execution_request)
- self.log.error("Exception", runtime_exception)
- print self.bluePrintRuntimeService.getBluePrintError().addError(runtime_exception.getMessage())
- return None
diff --git a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt
index 6678075bd..4e97460d3 100644
--- a/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt
+++ b/ms/blueprintsprocessor/application/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/UatExecutor.kt
@@ -304,6 +304,10 @@ class UatExecutor(
return realAnswer
}
+ override suspend fun <T> retry(times: Int, initialDelay: Long, delay: Long, block: suspend (Int) -> T): T {
+ return super.retry(times, initialDelay, delay, block)
+ }
+
fun asServiceDefinition() =
ServiceDefinition(selector, expectations)
diff --git a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt
index 4fed0ce67..fa550d1d0 100644
--- a/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt
+++ b/ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/BlueprintsAcceptanceTest.kt
@@ -19,6 +19,7 @@
*/
package org.onap.ccsdk.cds.blueprintsprocessor.uat
+import kotlinx.coroutines.runBlocking
import org.junit.ClassRule
import org.junit.Rule
import org.junit.runner.RunWith
@@ -38,7 +39,7 @@ import kotlin.test.Test
// See more on https://docs.spring.io/autorepo/docs/spring-framework/current/spring-framework-reference/testing.html#testcontext-junit4-rules
@RunWith(Parameterized::class)
class BlueprintsAcceptanceTest(@Suppress("unused") private val blueprintName: String, // readable test description
- private val rootFs: FileSystem): BaseUatTest() {
+ private val rootFs: FileSystem) : BaseUatTest() {
companion object {
@@ -84,8 +85,10 @@ class BlueprintsAcceptanceTest(@Suppress("unused") private val blueprintName: St
@Test
fun runUat() {
- val uatSpec = rootFs.getPath(UAT_SPECIFICATION_FILE).toFile().readText()
- val cbaBytes = compressToBytes(rootFs.getPath("/"))
- uatExecutor.execute(uatSpec, cbaBytes)
+ runBlocking {
+ val uatSpec = rootFs.getPath(UAT_SPECIFICATION_FILE).toFile().readText()
+ val cbaBytes = compressToBytes(rootFs.getPath("/"))
+ uatExecutor.execute(uatSpec, cbaBytes)
+ }
}
} \ No newline at end of file
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