import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentRemoteScriptExecutor
import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintConstants.PROPERTY_CONNECTION_CONFIG
-import org.onap.ccsdk.cds.controllerblueprints.core.BlueprintProcessorException
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants.PROPERTY_CONNECTION_CONFIG
+import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils.Companion.jsonNodeFromObject
val webclientService = restconfClientService(deviceInformation)
val nodeId = requestPayloadActionProperty(NODE_ID)?.first()?.textValue()
- ?: throw BlueprintProcessorException("Failed to load $NODE_ID properties.")
+ ?: throw BluePrintProcessorException("Failed to load $NODE_ID properties.")
val mountPayload = requestPayloadActionProperty(MOUNT_PAYLOAD)?.first()
- ?: throw BlueprintProcessorException("Failed to load $MOUNT_PAYLOAD properties.")
+ ?: throw BluePrintProcessorException("Failed to load $MOUNT_PAYLOAD properties.")
restconfMountDeviceJson(webclientService, nodeId, mountPayload.toString())
setAttribute(
ComponentRemoteScriptExecutor.ATTRIBUTE_STATUS,
- BlueprintConstants.STATUS_SUCCESS.asJsonPrimitive()
+ BluePrintConstants.STATUS_SUCCESS.asJsonPrimitive()
)
}
override suspend fun processNB(executionRequest: ExecutionServiceInput) {
val nodeIdJson = requestPayloadActionProperty(NODE_ID)?.first()
- ?: throw BlueprintProcessorException("Failed to load $NODE_ID properties.")
+ ?: throw BluePrintProcessorException("Failed to load $NODE_ID properties.")
val failFastJsonNode = requestPayloadActionProperty(FAIL_FAST)!!
val failFast = if (failFastJsonNode.isEmpty) false else failFastJsonNode.first().booleanValue()
val nodeId = nodeIdJson.textValue()
val actionList = requestPayloadActionProperty("action")?.first()
- ?: throw BlueprintProcessorException("Failed to load action properties.")
+ ?: throw BluePrintProcessorException("Failed to load action properties.")
validateActionList(actionList)
val actionListResults: MutableList<Map<String, JsonNode>> = mutableListOf()
if (response.status in HTTP_SUCCESS_RANGE) {
log.info("\nRestconf execution response : \n{}", responseBody.asJsonType().toPrettyString())
actionResult[ComponentScriptExecutor.ATTRIBUTE_STATUS] =
- BlueprintConstants.STATUS_SUCCESS.asJsonPrimitive()
+ BluePrintConstants.STATUS_SUCCESS.asJsonPrimitive()
} else {
actionResult[ComponentScriptExecutor.ATTRIBUTE_STATUS] =
- BlueprintConstants.STATUS_FAILURE.asJsonPrimitive()
+ BluePrintConstants.STATUS_FAILURE.asJsonPrimitive()
addError(
- BlueprintConstants.STATUS_FAILURE,
+ BluePrintConstants.STATUS_FAILURE,
ComponentScriptExecutor.ATTRIBUTE_STATUS,
actionResponse.asText()
)
}
setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, jsonNodeFromObject(actionListResults))
- setAttribute(ComponentScriptExecutor.ATTRIBUTE_STATUS, BlueprintConstants.STATUS_SUCCESS.asJsonPrimitive())
+ setAttribute(ComponentScriptExecutor.ATTRIBUTE_STATUS, BluePrintConstants.STATUS_SUCCESS.asJsonPrimitive())
actionListResults.forEach { actionResult ->
val actionResultStatus = actionResult[ComponentScriptExecutor.ATTRIBUTE_STATUS]
- if (BlueprintConstants.STATUS_SUCCESS.asJsonPrimitive() != actionResultStatus) {
+ if (BluePrintConstants.STATUS_SUCCESS.asJsonPrimitive() != actionResultStatus) {
setAttribute(
ComponentScriptExecutor.ATTRIBUTE_STATUS,
- BlueprintConstants.STATUS_FAILURE.asJsonPrimitive()
+ BluePrintConstants.STATUS_FAILURE.asJsonPrimitive()
)
val errorResponse = actionResult[ACTION_OUTPUT]!!
addError(
- BlueprintConstants.STATUS_FAILURE, ComponentScriptExecutor.ATTRIBUTE_STATUS,
+ BluePrintConstants.STATUS_FAILURE, ComponentScriptExecutor.ATTRIBUTE_STATUS,
errorResponse.asText()
)
}
private fun validateActionList(actionList: JsonNode) {
if (actionList.isEmpty) {
- throw BlueprintProcessorException("No actions defined")
+ throw BluePrintProcessorException("No actions defined")
}
actionList.forEach { action ->
action.get(ACTION_PATH)
- ?: throw BlueprintProcessorException("Failed to load action path.")
+ ?: throw BluePrintProcessorException("Failed to load action path.")
action.get(ACTION_DATASTORE)
- ?: throw BlueprintProcessorException("Failed to load action datastore.")
+ ?: throw BluePrintProcessorException("Failed to load action datastore.")
val actionTypeJsonNode = action.get(ACTION_TYPE)
- ?: throw BlueprintProcessorException("Failed to load action type.")
+ ?: throw BluePrintProcessorException("Failed to load action type.")
when (val actionType = RestconfRequestType.valueOf(actionTypeJsonNode.asText().toUpperCase())) {
RestconfRequestType.PATCH, RestconfRequestType.PUT, RestconfRequestType.POST -> {
action.get(ACTION_PAYLOAD)
- ?: throw BlueprintProcessorException("Failed to load action $actionType payload.")
+ ?: throw BluePrintProcessorException("Failed to load action $actionType payload.")
}
}
}