aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions
diff options
context:
space:
mode:
Diffstat (limited to 'ms/blueprintsprocessor/functions')
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt52
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/restconf/executor/RestconfExecutorExtensions.kt19
2 files changed, 39 insertions, 32 deletions
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
index 6b1f186c9..91d51757a 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/python/executor/ComponentRemotePythonExecutor.kt
@@ -110,35 +110,38 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
)
val prepareEnvOutput = remoteScriptExecutionService.prepareEnv(prepareEnvInput)
log.info("$ATTRIBUTE_PREPARE_ENV_LOG - ${prepareEnvOutput.response}")
- val logs = JacksonUtils.jsonNodeFromObject(prepareEnvOutput.response)
- setAttribute(ATTRIBUTE_PREPARE_ENV_LOG, logs)
- setAttribute(ATTRIBUTE_EXEC_CMD_LOG, "N/A".asJsonPrimitive())
+ val logs = prepareEnvOutput.response
+ val logsEnv = logs.toString().asJsonPrimitive()
+ setAttribute(ATTRIBUTE_PREPARE_ENV_LOG, logsEnv)
if (prepareEnvOutput.status != StatusType.SUCCESS) {
- setNodeOutputErrors(prepareEnvOutput.status.name, logs)
+ setAttribute(ATTRIBUTE_EXEC_CMD_LOG, "N/A".asJsonPrimitive())
+ setNodeOutputErrors(prepareEnvOutput.status.name, logsEnv)
} else {
- setNodeOutputProperties(prepareEnvOutput.status.name.asJsonPrimitive(), logs, "".asJsonPrimitive())
+ setNodeOutputProperties(prepareEnvOutput.status.name.asJsonPrimitive(), logsEnv, "".asJsonPrimitive())
}
}
- // Populate command execution properties and pass it to the remote server
- val properties = dynamicProperties?.returnNullIfMissing()?.rootFieldsToMap() ?: hashMapOf()
-
- val remoteExecutionInput = RemoteScriptExecutionInput(
- requestId = processId,
- remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
- command = scriptCommand,
- properties = properties)
- val remoteExecutionOutput = remoteScriptExecutionService.executeCommand(remoteExecutionInput)
-
- val logs = JacksonUtils.jsonNodeFromObject(remoteExecutionOutput.response)
- if (remoteExecutionOutput.status != StatusType.SUCCESS) {
- setNodeOutputErrors(remoteExecutionOutput.status.name,logs, remoteExecutionOutput.payload)
- } else {
- setNodeOutputProperties(remoteExecutionOutput.status.name.asJsonPrimitive(), logs,
- remoteExecutionOutput.payload)
+ // if Env preparation was successful, then proceed with command execution in this Env
+ if (bluePrintRuntimeService.getBluePrintError().errors.isEmpty()) {
+ // Populate command execution properties and pass it to the remote server
+ val properties = dynamicProperties?.returnNullIfMissing()?.rootFieldsToMap() ?: hashMapOf()
+
+ val remoteExecutionInput = RemoteScriptExecutionInput(
+ requestId = processId,
+ remoteIdentifier = RemoteIdentifier(blueprintName = blueprintName, blueprintVersion = blueprintVersion),
+ command = scriptCommand,
+ properties = properties)
+ val remoteExecutionOutput = remoteScriptExecutionService.executeCommand(remoteExecutionInput)
+
+ val logs = JacksonUtils.jsonNodeFromObject(remoteExecutionOutput.response)
+ if (remoteExecutionOutput.status != StatusType.SUCCESS) {
+ setNodeOutputErrors(remoteExecutionOutput.status.name, logs, remoteExecutionOutput.payload)
+ } else {
+ setNodeOutputProperties(remoteExecutionOutput.status.name.asJsonPrimitive(), logs,
+ remoteExecutionOutput.payload)
+ }
}
-
} catch (e: Exception) {
log.error("Failed to process on remote executor", e)
} finally {
@@ -178,9 +181,12 @@ open class ComponentRemotePythonExecutor(private val remoteScriptExecutionServic
*/
private fun setNodeOutputErrors(status: String, message: JsonNode, artifacts: JsonNode = "".asJsonPrimitive() ) {
setAttribute(ATTRIBUTE_EXEC_CMD_STATUS, status.asJsonPrimitive())
+ log.info("Executor status : $status")
setAttribute(ATTRIBUTE_EXEC_CMD_LOG, message)
+ log.info("Executor message : $message")
setAttribute(ATTRIBUTE_RESPONSE_DATA, artifacts)
+ log.info("Executor artifacts: $artifacts")
- addError(status, ATTRIBUTE_EXEC_CMD_LOG, message.asText())
+ addError(status, ATTRIBUTE_EXEC_CMD_LOG, message.toString())
}
}
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