aboutsummaryrefslogtreecommitdiffstats
path: root/ms
diff options
context:
space:
mode:
Diffstat (limited to 'ms')
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt34
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt9
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt5
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt81
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt192
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt6
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt12
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt10
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt13
-rw-r--r--ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt12
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt2
-rw-r--r--ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt6
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt112
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt2
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt4
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt55
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt17
-rw-r--r--ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt12
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt2
-rw-r--r--ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt26
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/pom.xml4
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt27
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt77
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt (renamed from ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonService.kt)29
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt (renamed from ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt)3
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt (renamed from ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt)3
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt (renamed from ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt)2
-rw-r--r--ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt (renamed from ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt)11
-rwxr-xr-xms/blueprintsprocessor/parent/pom.xml1
-rw-r--r--ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt1
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt4
-rw-r--r--ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt9
-rw-r--r--ms/controllerblueprints/parent/pom.xml1
35 files changed, 431 insertions, 357 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
index ecf90a28..60f1e4f8 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutor.kt
@@ -18,10 +18,12 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
+import com.fasterxml.jackson.databind.node.ArrayNode
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
+import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
import org.springframework.context.annotation.Scope
@@ -29,22 +31,40 @@ import org.springframework.stereotype.Component
@Component("component-netconf-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentNetconfExecutor(private val blueprintJythonService: BlueprintJythonService,
- private var resourceResolutionService: ResourceResolutionService)
+open class ComponentNetconfExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService)
: AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentNetconfExecutor::class.java)
+ companion object {
+ const val SCRIPT_TYPE = "script-type"
+ const val SCRIPT_CLASS_REFERENCE = "script-class-reference"
+ const val INSTANCE_DEPENDENCIES = "instance-dependencies"
+ }
+
+
lateinit var scriptComponent: NetconfComponentFunction
override fun process(executionRequest: ExecutionServiceInput) {
- scriptComponent = blueprintJythonService.jythonComponentInstance(this) as NetconfComponentFunction
+ val scriptType = operationInputs.getAsString(SCRIPT_TYPE)
+ val scriptClassReference = operationInputs.getAsString(SCRIPT_CLASS_REFERENCE)
+ val instanceDependenciesNode = operationInputs.get(INSTANCE_DEPENDENCIES) as? ArrayNode
+
+ val scriptDependencies: MutableList<String> = arrayListOf()
+ scriptDependencies.add(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+
+ instanceDependenciesNode?.forEach { instanceName ->
+ scriptDependencies.add(instanceName.textValue())
+ }
+
+ scriptComponent = componentFunctionScriptingService.scriptInstance<NetconfComponentFunction>(this, scriptType,
+ scriptClassReference, scriptDependencies)
+
+
checkNotNull(scriptComponent) { "failed to get netconf script component" }
scriptComponent.bluePrintRuntimeService = bluePrintRuntimeService
- scriptComponent.resourceResolutionService = resourceResolutionService
-
scriptComponent.processId = processId
scriptComponent.workflowName = workflowName
scriptComponent.stepName = stepName
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
index e1160acf..26e51ec0 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfComponentFunction.kt
@@ -18,13 +18,16 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor
import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
abstract class NetconfComponentFunction : AbstractComponentFunction() {
- lateinit var resourceResolutionService: ResourceResolutionService
+
+ open fun resourceResolutionService(): ResourceResolutionService =
+ functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
// Called from python script
fun initializeNetconfConnection(requirementName: String): NetconfDevice {
@@ -37,12 +40,12 @@ abstract class NetconfComponentFunction : AbstractComponentFunction() {
}
fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String {
- return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName,
+ return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
artifactMapping, artifactTemplate)
}
fun resolveAndGenerateMessage(artifactPrefix: String): String {
- return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName,
+ return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
artifactPrefix)
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
index 54776621..1c07c5e6 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfDevice.kt
@@ -20,12 +20,11 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.Ne
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfRpcServiceImpl
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionImpl
-class NetconfDevice(deviceInfo: DeviceInfo) {
- val netconfRpcService: NetconfRpcServiceImpl
+data class NetconfDevice(val deviceInfo: DeviceInfo) {
+ val netconfRpcService = NetconfRpcServiceImpl(deviceInfo)
val netconfSession: NetconfSession
init {
- netconfRpcService = NetconfRpcServiceImpl(deviceInfo)
netconfSession = NetconfSessionImpl(deviceInfo, netconfRpcService)
netconfRpcService.setNetconfSession(netconfSession)
}
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
index 554368c7..e2c9bf90 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/api/NetconfRpcService.kt
@@ -15,107 +15,90 @@
*/
package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.ModifyAction
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfDatastore
+
interface NetconfRpcService {
/**
* Lock
- * @param messageId message id of the request.
- * @param configTarget datastore ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ *
+ * @param configTarget running or candidate, default candidate
* @return Device response
*/
- fun lock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun lock(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
/**
* Get-config
- * @param messageId message id of the request.
- * @param filter filter content.
- * @param configTarget config target ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ *
+ * @param filter filter content, default empty
+ * @param configTarget running or candidate, default running
* @return Device response
*/
- fun getConfig(messageId: String, filter: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun getConfig(filter: String = "", configTarget: String = NetconfDatastore.RUNNING.datastore): DeviceResponse
/**
- * Delete config from datastore
- * @param messageId message id of the request.
- * @param configTarget config target ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ * Delete config
+ *
+ * @param configTarget running or candidate, default candidate
* @return Device response
*/
- fun deleteConfig(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun deleteConfig(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
/**
* Edit-config
- * @param messageId message id of the request.
+ *
* @param messageContent edit config content.
- * @param lock lock the device before performing edit.
- * @param configTarget config target ( running or candidate)
- * @param editDefaultOperation edit default operation (merge | replace | create | delete | remove or
- * delete)
- * @param clearCandidate commit after edit config
- * @param commit clear candiate store before edit
- * @param discardChanges Rollback on failure
- * @param validate validate the config before commit
- * @param unlock unlock device after edit
- * @param messageTimeout message timeout of the request.
+ * @param configTarget running or candidate, default candidate
+ * @param editDefaultOperation, default set to none. Valid values: merge, replace, create, delete, none
* @return Device response
*/
- fun editConfig(messageId: String, messageContent: String, lock: Boolean, configTarget: String,
- editDefaultOperation: String, deleteConfig: Boolean, validate: Boolean, commit: Boolean,
- discardChanges: Boolean, unlock: Boolean, messageTimeout: Int): DeviceResponse
+ fun editConfig(messageContent: String, configTarget: String = NetconfDatastore.CANDIDATE.datastore,
+ editDefaultOperation: String = ModifyAction.NONE.action): DeviceResponse
/**
* Validate
- * @param messageId message id of the request.
- * @param configTarget config target ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ *
+ * @param configTarget running or candidate, default candidate
* @return Device response
*/
- fun validate(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun validate(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
/**
* Commit
- * @param messageId message id of the request.
- * @param discardChanges Rollback on failure
- * @param messageTimeout message timeout of the request.
+ *
* @return Device response
*/
- fun commit(messageId: String, discardChanges: Boolean, messageTimeout: Int): DeviceResponse
+ fun commit(): DeviceResponse
/**
* Unlock
- * @param messageId message id of the request.
- * @param configTarget config target ( running or candidate)
- * @param messageTimeout message timeout of the request.
+ *
+ * @param configTarget running or candidate, default candidate
* @return Device response
*/
- fun unLock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse
+ fun unLock(configTarget: String = NetconfDatastore.CANDIDATE.datastore): DeviceResponse
/**
* Discard config
- * @param messageId message id of the request.
- * @param messageTimeout message timeout of the request.
+ *
* @return Device response
*/
- fun discardConfig(messageId: String, messageTimeout: Int): DeviceResponse
+ fun discardConfig(): DeviceResponse
/**
* Close session
- * @param messageId message id of the request.
+ *
* @param force force closeSession
- * @param messageTimeout message timeout of the request.
* @return Device response
*/
- fun closeSession(messageId: String, force: Boolean, messageTimeout: Int): DeviceResponse
+ fun closeSession(force: Boolean): DeviceResponse
/**
* Executes an RPC request to the netconf server.
*
* @param request the XML containing the RPC request for the server.
- * @param messageId message id of the request.
- * @param messageTimeout message timeout of the request.
* @return Device response
*/
- fun asyncRpc(request: String, messageId: String, messageTimeout: Int): DeviceResponse
+ fun asyncRpc(request: String, messageId: String): DeviceResponse
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
index 5c633a5b..be835557 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfRpcServiceImpl.kt
@@ -21,29 +21,33 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.De
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.NetconfException
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.NetconfRpcService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.NetconfSession
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfDatastore
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfMessageUtils
import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.RpcStatus
import org.slf4j.LoggerFactory
import java.util.concurrent.TimeUnit
+import java.util.concurrent.atomic.AtomicInteger
-class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcService {
+class NetconfRpcServiceImpl(private var deviceInfo: DeviceInfo) : NetconfRpcService {
private val log = LoggerFactory.getLogger(NetconfRpcService::class.java)
+ private var responseTimeout: Int = deviceInfo.replyTimeout
+
private lateinit var netconfSession: NetconfSession
+ private val messageIdInteger = AtomicInteger(1)
+
fun setNetconfSession(netconfSession: NetconfSession) {
this.netconfSession = netconfSession
}
- override fun getConfig(messageId: String, filter: String, configTarget: String,
- messageTimeout: Int): DeviceResponse {
+ override fun getConfig(filter: String, configTarget: String): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: getConfig: messageId($messageId)")
try {
val message = NetconfMessageUtils.getConfig(messageId, configTarget, filter)
- output = asyncRpc(message, messageId, messageTimeout)
+ output = asyncRpc(message, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in get-config command $e.message"
@@ -51,13 +55,14 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun deleteConfig(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse {
+ override fun deleteConfig(configTarget: String): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: deleteConfig: messageId($messageId)")
try {
val deleteConfigMessage = NetconfMessageUtils.deleteConfig(messageId, configTarget)
output.requestMessage = deleteConfigMessage
- output = asyncRpc(deleteConfigMessage, messageId, messageTimeout)
+ output = asyncRpc(deleteConfigMessage, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in delete config command $e.message"
@@ -65,13 +70,14 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun lock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse {
+ override fun lock(configTarget: String): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: lock: messageId($messageId)")
try {
val lockMessage = NetconfMessageUtils.lock(messageId, configTarget)
output.requestMessage = lockMessage
- output = asyncRpc(lockMessage, messageId, messageTimeout)
+ output = asyncRpc(lockMessage, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in lock command $e.message"
@@ -80,13 +86,14 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun unLock(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse {
+ override fun unLock(configTarget: String): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: unLock: messageId($messageId)")
try {
val unlockMessage = NetconfMessageUtils.unlock(messageId, configTarget)
output.requestMessage = unlockMessage
- output = asyncRpc(unlockMessage, messageId, messageTimeout)
+ output = asyncRpc(unlockMessage, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in lock command $e.message"
@@ -94,33 +101,28 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun commit(messageId: String, discardChanges: Boolean, messageTimeout: Int): DeviceResponse {
+ override fun commit(): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: commit: messageId($messageId)")
try {
val messageContent = NetconfMessageUtils.commit(messageId)
- output = asyncRpc(messageContent, messageId, messageTimeout)
+ output = asyncRpc(messageContent, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in commit command $e.message"
-
- // If commit failed apply discard changes
- if (discardChanges) {
- val discardChangesConfigMessageId = "$messageId-discard-changes"
- val discardOutput = discardConfig(discardChangesConfigMessageId, deviceInfo.replyTimeout)
- output.addSubDeviceResponse(discardChangesConfigMessageId, discardOutput)
- }
}
return output
}
- override fun discardConfig(messageId: String, messageTimeout: Int): DeviceResponse {
+ override fun discardConfig(): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: discard: messageId($messageId)")
try {
val discardChangesMessage = NetconfMessageUtils.discardChanges(messageId)
output.requestMessage = discardChangesMessage
- output = asyncRpc(discardChangesMessage, messageId, messageTimeout)
+ output = asyncRpc(discardChangesMessage, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in discard changes command " + e.message
@@ -128,12 +130,44 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
return output
}
- override fun closeSession(messageId: String, force: Boolean, messageTimeout: Int): DeviceResponse {
+ override fun editConfig(messageContent: String, configTarget: String,
+ editDefaultOperation: String): DeviceResponse {
+ var response = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
+ log.info("$deviceInfo: editConfig: messageId($messageId)")
+ try {
+ val editMessage =
+ NetconfMessageUtils.editConfig(messageId, configTarget, editDefaultOperation, messageContent)
+ response.requestMessage = editMessage
+ response = asyncRpc(editMessage, messageId)
+ } catch (e: Exception) {
+ response.status = RpcStatus.FAILURE
+ response.errorMessage = e.message
+ }
+ return response
+ }
+
+ override fun validate(configTarget: String): DeviceResponse {
+ var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
+ try {
+ val validateMessage = NetconfMessageUtils.validate(messageId, configTarget)
+ output.requestMessage = validateMessage
+ output = asyncRpc(validateMessage, messageId)
+ } catch (e: Exception) {
+ output.status = RpcStatus.FAILURE
+ output.errorMessage = "$deviceInfo: failed in validate command " + e.message
+ }
+ return output
+ }
+
+ override fun closeSession(force: Boolean): DeviceResponse {
var output = DeviceResponse()
+ val messageId = messageIdInteger.getAndIncrement().toString()
log.info("$deviceInfo: closeSession: messageId($messageId)")
try {
val messageContent = NetconfMessageUtils.closeSession(messageId, force)
- output = asyncRpc(messageContent, messageId, messageTimeout)
+ output = asyncRpc(messageContent, messageId)
} catch (e: Exception) {
output.status = RpcStatus.FAILURE
output.errorMessage = "$deviceInfo: failed in closeSession command " + e.message
@@ -142,12 +176,12 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
}
@Throws(NetconfException::class)
- override fun asyncRpc(request: String, messageId: String, messageTimeout: Int): DeviceResponse {
+ override fun asyncRpc(request: String, messageId: String): DeviceResponse {
val response = DeviceResponse()
log.info("$deviceInfo: send asyncRpc with messageId($messageId)")
response.requestMessage = request
- val rpcResponse = netconfSession.asyncRpc(request, messageId).get(messageTimeout.toLong(), TimeUnit.SECONDS)
+ val rpcResponse = netconfSession.asyncRpc(request, messageId).get(responseTimeout.toLong(), TimeUnit.SECONDS)
if (!NetconfMessageUtils.checkReply(rpcResponse)) {
throw NetconfException(rpcResponse)
}
@@ -156,110 +190,4 @@ class NetconfRpcServiceImpl(private val deviceInfo: DeviceInfo) : NetconfRpcServ
response.errorMessage = null
return response
}
-
- override fun editConfig(messageId: String, messageContent: String, lock: Boolean, configTarget: String,
- editDefaultOperation: String, deleteConfig: Boolean, validate: Boolean, commit: Boolean,
- discardChanges: Boolean, unlock: Boolean, messageTimeout: Int): DeviceResponse {
- var editConfigDeviceResponse =
- DeviceResponse()
-
- try {
- val editMessage =
- NetconfMessageUtils.editConfig(messageId, configTarget, editDefaultOperation, messageContent)
- editConfigDeviceResponse.requestMessage = editMessage
-
- if (lock) {
- val lockMessageId = "$messageId-lock"
- val lockDeviceResponse = lock(lockMessageId, configTarget, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(lockMessageId, lockDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(lockDeviceResponse.status, ignoreCase = true)) {
- throw NetconfException(
- lockDeviceResponse.errorMessage!!)
- }
- }
-
- if (deleteConfig) {
- val deleteConfigMessageId = "$messageId-delete"
- val deleteConfigDeviceResponse = deleteConfig(deleteConfigMessageId,
- NetconfDatastore.CANDIDATE, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(deleteConfigMessageId, deleteConfigDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(deleteConfigDeviceResponse.status,
- ignoreCase = true)) {
- throw NetconfException(
- deleteConfigDeviceResponse.errorMessage!!)
- }
- }
-
- if (discardChanges) {
- val discardConfigMessageId = "$messageId-discard"
- val discardConfigDeviceResponse = discardConfig(discardConfigMessageId, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(discardConfigMessageId, discardConfigDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(discardConfigDeviceResponse.status,
- ignoreCase = true)) {
- throw NetconfException(
- discardConfigDeviceResponse.errorMessage!!)
- }
- }
-
- editConfigDeviceResponse = asyncRpc(editMessage, messageId, messageTimeout)
- if (!RpcStatus.SUCCESS.equals(editConfigDeviceResponse.status, ignoreCase = true)) {
- throw NetconfException(
- editConfigDeviceResponse.errorMessage!!)
- }
-
- if (validate) {
- val validateMessageId = "$messageId-validate"
- val validateDeviceResponse = validate(validateMessageId,
- NetconfDatastore.CANDIDATE, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(validateMessageId, validateDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(validateDeviceResponse.status, ignoreCase = true)) {
- throw NetconfException(
- validateDeviceResponse.errorMessage!!)
- }
- }
-
- /**
- * If Commit is enable, the commit response is treated as Edit config response, If commit failed, we
- * need not to throw an exception, until we unlock the device.
- */
- if (commit) {
- val commitMessageId = "$messageId-commit"
- val commitDeviceResponse =
- commit(commitMessageId, discardChanges, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(commitMessageId, commitDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(commitDeviceResponse.status, ignoreCase = true)) {
- throw NetconfException(
- commitDeviceResponse.errorMessage!!)
- }
- }
-
- } catch (e: Exception) {
- editConfigDeviceResponse.status = RpcStatus.FAILURE
- editConfigDeviceResponse.errorMessage = e.message
- } finally {
- if (unlock) {
- val unlockMessageId = "$messageId-unlock"
- val unlockDeviceResponse = unLock(unlockMessageId, configTarget, deviceInfo.replyTimeout)
- editConfigDeviceResponse.addSubDeviceResponse(unlockMessageId, unlockDeviceResponse)
- if (!RpcStatus.SUCCESS.equals(unlockDeviceResponse.status, ignoreCase = true)) {
- editConfigDeviceResponse.status = RpcStatus.FAILURE
- editConfigDeviceResponse.errorMessage = unlockDeviceResponse.errorMessage
- }
- }
- }
- return editConfigDeviceResponse
- }
-
- override fun validate(messageId: String, configTarget: String, messageTimeout: Int): DeviceResponse {
- var output = DeviceResponse()
- try {
- val validateMessage = NetconfMessageUtils.validate(messageId, configTarget)
- output.requestMessage = validateMessage
- output = asyncRpc(validateMessage, messageId, messageTimeout)
- } catch (e: Exception) {
- output.status = RpcStatus.FAILURE
- output.errorMessage = "$deviceInfo: failed in validate command " + e.message
- }
- return output
- }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
index 21570a23..cf11cfdd 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/core/NetconfSessionImpl.kt
@@ -40,7 +40,6 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.ExecutionException
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
-import java.util.concurrent.atomic.AtomicInteger
class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcService: NetconfRpcService) :
NetconfSession {
@@ -61,7 +60,6 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
private lateinit var channel: ClientChannel
private lateinit var streamHandler: NetconfDeviceCommunicator
- private val messageIdInteger = AtomicInteger(1)
private var capabilities =
ImmutableList.of(RpcMessageUtils.NETCONF_10_CAPABILITY, RpcMessageUtils.NETCONF_11_CAPABILITY)
@@ -78,9 +76,9 @@ class NetconfSessionImpl(private val deviceInfo: DeviceInfo, private val rpcServ
}
override fun disconnect() {
- if (rpcService.closeSession(messageIdInteger.incrementAndGet().toString(), false, replyTimeout).status.equals(
+ if (rpcService.closeSession(false).status.equals(
RpcStatus.FAILURE, true)) {
- rpcService.closeSession(messageIdInteger.incrementAndGet().toString(), true, replyTimeout)
+ rpcService.closeSession(true)
}
session.close()
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
index e0cbde53..3b3b0c02 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfConstant.kt
@@ -15,9 +15,15 @@
*/
package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils
-object NetconfDatastore {
- const val RUNNING = "running"
- const val CANDIDATE = "candidate"
+enum class NetconfDatastore(val datastore: String) {
+ RUNNING("running"),
+ CANDIDATE("candidate");
+}
+
+enum class ModifyAction(val action: String) {
+ MERGE("merge"),
+ REPLACE("replace"),
+ NONE("none")
}
object RpcStatus {
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
index b0310d78..7e48912d 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/NetconfMessageUtils.kt
@@ -139,9 +139,9 @@ class NetconfMessageUtils {
}
@Throws(NetconfException::class)
- fun deleteConfig(messageId: String, netconfTargetConfig: String): String {
- if (netconfTargetConfig == NetconfDatastore.RUNNING) {
- log.warn("Target configuration for delete operation can't be \"running\" {}", netconfTargetConfig)
+ fun deleteConfig(messageId: String, configType: String): String {
+ if (configType == NetconfDatastore.RUNNING.datastore) {
+ log.warn("Target configuration for delete operation can't be \"running\" {}", configType)
throw NetconfException("Target configuration for delete operation can't be running")
}
@@ -149,7 +149,7 @@ class NetconfMessageUtils {
request.append("<delete-config>").append(NEW_LINE)
request.append(RpcMessageUtils.TARGET_OPEN).append(NEW_LINE)
- request.append(RpcMessageUtils.OPEN).append(netconfTargetConfig)
+ request.append(RpcMessageUtils.OPEN).append(configType)
.append(RpcMessageUtils.TAG_CLOSE)
.append(NEW_LINE)
request.append(RpcMessageUtils.TARGET_CLOSE).append(NEW_LINE)
@@ -304,8 +304,6 @@ class NetconfMessageUtils {
}
if (!message.startsWith(RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH)) {
// chunk encode message
- //message = (RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + message.getBytes(UTF_8).size + RpcMessageUtils.NEW_LINE + message +RpcMessageUtils. NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH
- // + RpcMessageUtils.NEW_LINE)
message =
(RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + message.toByteArray(UTF_8).size + RpcMessageUtils.NEW_LINE + message + RpcMessageUtils.NEW_LINE + RpcMessageUtils.HASH + RpcMessageUtils.HASH
+ RpcMessageUtils.NEW_LINE)
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
index 5b7b14ad..6ed3a6d9 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt
@@ -22,14 +22,16 @@ import com.fasterxml.jackson.databind.JsonNode
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionServiceImpl
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.TestPropertySource
@@ -37,6 +39,7 @@ import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class,
+ BluePrintScriptsServiceImpl::class, ComponentFunctionScriptingService::class,
ComponentNetconfExecutor::class, JsonParserService::class, ResourceResolutionServiceImpl::class])
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf,./../../../../components/scripts/python/ccsdk_blueprints",
@@ -51,17 +54,17 @@ class ComponentNetconfExecutorTest {
fun testComponentNetconfExecutor() {
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json",
- ExecutionServiceInput::class.java)!!
+ ExecutionServiceInput::class.java)!!
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
val executionContext = bluePrintRuntimeService.getExecutionContext()
componentNetconfExecutor.bluePrintRuntimeService = bluePrintRuntimeService
-
+ //TODO("Set Attribute properties")
val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-netconf")
stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentNetconfExecutor")
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
index 20b04fb5..2cd2d109 100644
--- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
+++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt
@@ -29,7 +29,7 @@ class RpcMessageUtilsTest {
+ "</get-config></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val filterContent = "Test-Filter-Content"
val result = NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
@@ -48,7 +48,7 @@ class RpcMessageUtilsTest {
+ "</get-config></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val filterContent = "Test-Filter-Content"
val result = NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "")
@@ -64,7 +64,7 @@ class RpcMessageUtilsTest {
+ "<validate><source><candidate/></source></validate></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val result = NetconfMessageUtils.validate(messageId, configType).replace("[\n\r\t]".toRegex(), "")
@@ -94,7 +94,7 @@ class RpcMessageUtilsTest {
+ "<unlock><target><candidate/></target></unlock></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val result = NetconfMessageUtils.unlock(messageId, configType).replace("[\n\r\t]".toRegex(), "")
@@ -109,7 +109,7 @@ class RpcMessageUtilsTest {
+ "<delete-config><target><candidate/></target></delete-config></rpc>")
val messageId = "Test-Message-ID"
- val netconfTargetConfig = "candidate"
+ val netconfTargetConfig = NetconfDatastore.CANDIDATE.datastore
val result = NetconfMessageUtils.deleteConfig(messageId, netconfTargetConfig).replace("[\n\r\t]".toRegex(), "")
@@ -138,7 +138,7 @@ class RpcMessageUtilsTest {
+ "<lock><target><candidate/></target></lock></rpc>")
val messageId = "Test-Message-ID"
- val configType = "candidate"
+ val configType = NetconfDatastore.CANDIDATE.datastore
val result = NetconfMessageUtils.lock(messageId, configType).replace("[\n\r\t]".toRegex(), "")
assertTrue(NetconfMessageUtils.validateRPCXML(result))
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
index a74a7790..b7f77719 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt
@@ -22,6 +22,8 @@ import com.fasterxml.jackson.databind.node.ArrayNode
import org.apache.commons.io.FilenameUtils
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
index 67a3d955..dd8eb503 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt
@@ -20,6 +20,9 @@ import com.fasterxml.jackson.databind.JsonNode
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.mock.MockInstanceConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
@@ -31,7 +34,8 @@ import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [PythonExecutorConfiguration::class, PythonExecutorProperty::class])
+@ContextConfiguration(classes = [PythonExecutorConfiguration::class, PythonExecutorProperty::class,
+ ComponentJythonExecutor::class, MockInstanceConfiguration::class])
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
"blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
index eaa8eacc..5765609b 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionConstants.kt
@@ -18,6 +18,8 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution
class ResourceResolutionConstants {
companion object {
+ const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
+
const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
index 34985527..24401ccf 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/ResourceResolutionService.kt
@@ -22,7 +22,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.uti
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
@@ -32,39 +32,39 @@ import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
import java.io.File
-interface ResourceResolutionService {
-
- fun registeredResourceSources(): List<String>
-
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>): MutableMap<String, String>
-
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String): String
-
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactMapping: String, artifactTemplate: String?): String
-
- fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDictionaries: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>,
- identifierName: String)
-}
-
-@Service
-open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext) :
- ResourceResolutionService {
+interface ResourceResolutionService {
+
+ fun registeredResourceSources(): List<String>
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactNames: List<String>): MutableMap<String, String>
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactPrefix: String): String
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactMapping: String, artifactTemplate: String?): String
+
+ fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ identifierName: String)
+}
+
+@Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext) :
+ ResourceResolutionService {
private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
- override fun registeredResourceSources(): List<String> {
+ override fun registeredResourceSources(): List<String> {
return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
.filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
.map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
}
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactNames: List<String>): MutableMap<String, String> {
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactNames: List<String>): MutableMap<String, String> {
val resolvedParams: MutableMap<String, String> = hashMapOf()
artifactNames.forEach { artifactName ->
@@ -74,27 +74,27 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
return resolvedParams
}
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactPrefix: String): String {
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactPrefix: String): String {
// Velocity Artifact Definition Name
- val artifactTemplate = "$artifactPrefix-template"
+ val artifactTemplate = "$artifactPrefix-template"
// Resource Assignment Artifact Definition Name
- val artifactMapping = "$artifactPrefix-mapping"
-
- return resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactMapping, artifactTemplate)
- }
-
-
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
- artifactMapping: String, artifactTemplate: String?): String {
-
- var resolvedContent = ""
- log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
-
- val identifierName = artifactTemplate ?: "no-template"
-
- val resourceAssignmentContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
+ val artifactMapping = "$artifactPrefix-mapping"
+
+ return resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactMapping, artifactTemplate)
+ }
+
+
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactMapping: String, artifactTemplate: String?): String {
+
+ var resolvedContent = ""
+ log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
+
+ val identifierName = artifactTemplate ?: "no-template"
+
+ val resourceAssignmentContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
as? MutableList<ResourceAssignment>
@@ -108,28 +108,28 @@ open class ResourceResolutionServiceImpl(private var applicationContext: Applica
val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
- // Resolve resources
- resolveResourceAssignments(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, identifierName)
+ // Resolve resources
+ resolveResourceAssignments(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, identifierName)
- val resolvedParamJsonContent = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
+ val resolvedParamJsonContent = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
- // Check Template is there
- if (artifactTemplate != null) {
- val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
- resolvedContent = BluePrintTemplateService.generateContent(templateContent, resolvedParamJsonContent)
+ // Check Template is there
+ if (artifactTemplate != null) {
+ val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
+ resolvedContent = BluePrintTemplateService.generateContent(templateContent, resolvedParamJsonContent)
} else {
resolvedContent = resolvedParamJsonContent
}
return resolvedContent
}
- override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
- resourceDictionaries: MutableMap<String, ResourceDefinition>,
- resourceAssignments: MutableList<ResourceAssignment>,
- identifierName: String) {
+ override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ identifierName: String) {
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
- val resourceAssignmentRuntimeService = ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)
+ val resourceAssignmentRuntimeService = ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)
bulkSequenced.map { batchResourceAssignments ->
batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
index 162a7b49..489645fd 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessor.kt
@@ -18,7 +18,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.CapabilityResourceSource
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
index f1a4dbb0..a264ba50 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/SimpleRestResourceAssignmentProcessor.kt
@@ -70,7 +70,7 @@ open class SimpleRestResourceAssignmentProcessor(private val blueprintRestLibPro
val inputKeyMapping = checkNotNull(sourceProperties.inputKeyMapping) { "failed to get input-key-mappings for $dName under $dSource properties" }
logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})")
-
+ // TODO("Dynamic Rest Client Service, call (blueprintDynamicWebClientService || blueprintWebClientService")
val restClientService = blueprintRestLibPropertyService.blueprintWebClientService("primary-config-data")
val response = restClientService.getResource(urlPath, String::class.java)
if (response.isNotBlank()) {
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
index 64281264..0dbd0f6e 100644
--- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceAssignmentProcessorTest.kt
@@ -20,8 +20,8 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.pr
import org.junit.Test
import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.data.PropertyDefinition
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt
index 9bcc23b6..742fef4b 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt
@@ -16,28 +16,21 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor
+import com.fasterxml.jackson.databind.node.ArrayNode
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestLibConstants
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.config.ConfigurableBeanFactory
-import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Scope
import org.springframework.stereotype.Component
@Component("component-restconf-executor")
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
-open class ComponentRestconfExecutor(private var applicationContext: ApplicationContext,
- private val blueprintJythonService: BlueprintJythonService,
- private val bluePrintScriptsService: BluePrintScriptsService,
- private var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService,
- private var resourceResolutionService: ResourceResolutionService) :
+open class ComponentRestconfExecutor(private var componentFunctionScriptingService: ComponentFunctionScriptingService) :
AbstractComponentFunction() {
private val log = LoggerFactory.getLogger(ComponentRestconfExecutor::class.java)
@@ -47,16 +40,28 @@ open class ComponentRestconfExecutor(private var applicationContext: Application
companion object {
const val SCRIPT_TYPE = "script-type"
const val SCRIPT_CLASS_REFERENCE = "script-class-reference"
+ const val INSTANCE_DEPENDENCIES = "instance-dependencies"
}
override fun process(executionRequest: ExecutionServiceInput) {
val scriptType = operationInputs.getAsString(SCRIPT_TYPE)
val scriptClassReference = operationInputs.getAsString(SCRIPT_CLASS_REFERENCE)
+ val instanceDependenciesNode = operationInputs.get(INSTANCE_DEPENDENCIES) as? ArrayNode
+
+ val scriptDependencies: MutableList<String> = arrayListOf()
+ scriptDependencies.add(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
+ scriptDependencies.add(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+
+ instanceDependenciesNode?.forEach { instanceName ->
+ scriptDependencies.add(instanceName.textValue())
+ }
/**
* Populate the Script Instance based on the Type
*/
- restconfComponentFunction(scriptType, scriptClassReference)
+ scriptComponent = componentFunctionScriptingService.scriptInstance<RestconfComponentFunction>(this, scriptType,
+ scriptClassReference, scriptDependencies)
+
checkNotNull(scriptComponent) { "failed to get restconf script component" }
scriptComponent.bluePrintRuntimeService = bluePrintRuntimeService
@@ -68,34 +73,10 @@ open class ComponentRestconfExecutor(private var applicationContext: Application
scriptComponent.nodeTemplateName = nodeTemplateName
scriptComponent.operationInputs = operationInputs
- // Set the Rest Lib Property Service
- scriptComponent.bluePrintRestLibPropertyService = bluePrintRestLibPropertyService
- scriptComponent.resourceResolutionService = resourceResolutionService
-
scriptComponent.process(executionServiceInput)
}
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
scriptComponent.recover(runtimeException, executionRequest)
}
-
- fun restconfComponentFunction(scriptType: String, scriptClassReference: String): RestconfComponentFunction {
- log.info("processing restconf script type($scriptType), reference name($scriptClassReference)")
- when (scriptType) {
- BluePrintConstants.SCRIPT_INTERNAL -> {
- scriptComponent = bluePrintScriptsService.scriptInstance<RestconfComponentFunction>(scriptClassReference)
- }
- BluePrintConstants.SCRIPT_KOTLIN -> {
- scriptComponent = bluePrintScriptsService.scriptInstance<RestconfComponentFunction>(bluePrintRuntimeService
- .bluePrintContext(), scriptClassReference, false)
- }
- BluePrintConstants.SCRIPT_JYTHON -> {
- scriptComponent = blueprintJythonService.jythonComponentInstance(this) as RestconfComponentFunction
- }
- else -> {
- throw BluePrintProcessorException("script type($scriptType) is not supported")
- }
- }
- return scriptComponent
- }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
index d9362af8..c6afc3b8 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt
@@ -14,9 +14,12 @@
* limitations under the License.
*/
@file:Suppress("unused")
+
package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
+import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestLibConstants
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BlueprintWebClientService
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
@@ -24,11 +27,15 @@ import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractCompon
abstract class RestconfComponentFunction : AbstractComponentFunction() {
- lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService
- lateinit var resourceResolutionService: ResourceResolutionService
+ open fun bluePrintRestLibPropertyService(): BluePrintRestLibPropertyService =
+ functionDependencyInstanceAsType(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
+
+ open fun resourceResolutionService(): ResourceResolutionService =
+ functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+
fun restClientService(selector: String): BlueprintWebClientService {
- return bluePrintRestLibPropertyService.blueprintWebClientService(selector)
+ return bluePrintRestLibPropertyService().blueprintWebClientService(selector)
}
fun generateMessage(artifactName: String): String {
@@ -36,12 +43,12 @@ abstract class RestconfComponentFunction : AbstractComponentFunction() {
}
fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String {
- return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName,
+ return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
artifactMapping, artifactTemplate)
}
fun resolveAndGenerateMessage(artifactPrefix: String): String {
- return resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName,
+ return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
artifactPrefix)
}
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
index 31bd4eb7..c8a2090b 100644
--- a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
+++ b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt
@@ -17,6 +17,7 @@
package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor
import com.fasterxml.jackson.databind.JsonNode
+import com.fasterxml.jackson.databind.node.ArrayNode
import com.fasterxml.jackson.databind.node.ObjectNode
import io.mockk.every
import io.mockk.mockk
@@ -27,13 +28,15 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfigurati
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionServiceImpl
import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
@@ -48,7 +51,7 @@ import kotlin.test.assertNotNull
@ContextConfiguration(classes = [RestconfExecutorConfiguration::class, ComponentRestconfExecutor::class,
BlueprintJythonService::class, PythonExecutorProperty::class, BluePrintRestLibPropertyService::class,
BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintScriptsServiceImpl::class,
- ResourceResolutionServiceImpl::class])
+ ResourceResolutionServiceImpl::class, ComponentFunctionScriptingService::class])
@TestPropertySource(properties =
["server.port=9111",
"blueprintsprocessor.restconfEnabled=true",
@@ -83,7 +86,10 @@ class ComponentRestconfExecutorTest {
operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive()
operationInputs[ComponentRestconfExecutor.SCRIPT_TYPE] = BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive()
operationInputs[ComponentRestconfExecutor.SCRIPT_CLASS_REFERENCE] = "InternalSimpleRestconf_cba\$TestRestconfConfigure".asJsonPrimitive()
+ operationInputs[ComponentRestconfExecutor.INSTANCE_DEPENDENCIES] = JacksonUtils.jsonNode("[]") as ArrayNode
+ val blueprintContext = mockk<BluePrintContext>()
+ every { bluePrintRuntime.bluePrintContext() } returns blueprintContext
every { bluePrintRuntime.get("sample-step-step-inputs") } returns operationInputs.asJsonNode()
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs("activate-restconf",
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
index 50d69aee..f63e39f3 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/BluePrintRestLibConfiguration.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +29,7 @@ open class BluePrintRestLibConfiguration
class RestLibConstants {
companion object {
+ const val SERVICE_BLUEPRINT_REST_LIB_PROPERTY = "blueprint-rest-lib-property-service"
const val TYPE_BASIC_AUTH = "basic-auth"
const val TYPE_SSL_BASIC_AUTH = "ssl-basic-auth"
const val TYPE_DME2_PROXY = "dme2-proxy"
diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
index 21d080d5..47577b39 100644
--- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
+++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyService.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.rest.*
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.springframework.stereotype.Service
-@Service
+@Service(RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
open class BluePrintRestLibPropertyService(private var bluePrintProperties: BluePrintProperties) {
@Throws(BluePrintProcessorException::class)
@@ -49,22 +50,31 @@ open class BluePrintRestLibPropertyService(private var bluePrintProperties: Blue
@Throws(BluePrintProcessorException::class)
fun blueprintWebClientService(selector: String): BlueprintWebClientService {
val prefix = "blueprintsprocessor.restclient.$selector"
- val beanProperties = restClientProperties(prefix)
- when (beanProperties) {
+ val restClientProperties = restClientProperties(prefix)
+ return blueprintWebClientService(restClientProperties)
+ }
+
+
+ fun blueprintDynamicWebClientService(sourceType: String, selector: String): BlueprintWebClientService {
+ TODO()
+ }
+
+ @Throws(BluePrintProcessorException::class)
+ fun blueprintWebClientService(restClientProperties: RestClientProperties): BlueprintWebClientService {
+ when (restClientProperties) {
is BasicAuthRestClientProperties -> {
- return BasicAuthRestClientService(beanProperties)
+ return BasicAuthRestClientService(restClientProperties)
}
is SSLBasicAuthRestClientProperties -> {
- return SSLBasicAuthRestClientService(beanProperties)
+ return SSLBasicAuthRestClientService(restClientProperties)
}
is DME2RestClientProperties -> {
- return DME2ProxyRestClientService(beanProperties)
+ return DME2ProxyRestClientService(restClientProperties)
}
else -> {
- throw BluePrintProcessorException("couldn't get rest service for selector($selector)")
+ throw BluePrintProcessorException("couldn't get rest service for")
}
}
-
}
fun basicAuthRestClientProperties(prefix: String): BasicAuthRestClientProperties {
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
index ea5f31a3..283a8a66 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
+++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml
@@ -30,6 +30,10 @@
<dependencies>
<dependency>
+ <groupId>org.python</groupId>
+ <artifactId>jython-standalone</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
<artifactId>blueprint-core</artifactId>
</dependency>
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
index f7c901df..930dc074 100644
--- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2019 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -48,22 +49,26 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
lateinit var operationName: String
lateinit var nodeTemplateName: String
var operationInputs: MutableMap<String, JsonNode> = hashMapOf()
+ /**
+ * Store Dynamic Dependency Instances
+ */
+ var functionDependencyInstances: MutableMap<String, Any> = hashMapOf()
override fun getName(): String {
return stepName
}
- override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput {
+ override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput {
checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }
check(stepName.isNotEmpty()) { "failed to assign step name" }
- this.executionServiceInput = executionRequest
+ this.executionServiceInput = executionRequest
- processId = executionRequest.commonHeader.requestId
+ processId = executionRequest.commonHeader.requestId
check(processId.isNotEmpty()) { "couldn't get process id for step($stepName)" }
- workflowName = executionRequest.actionIdentifiers.actionName
+ workflowName = executionRequest.actionIdentifiers.actionName
check(workflowName.isNotEmpty()) { "couldn't get action name for step($stepName)" }
log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")
@@ -88,14 +93,14 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
this.operationInputs.putAll(operationResolvedProperties)
- return executionRequest
+ return executionRequest
}
override fun prepareResponse(): ExecutionServiceOutput {
log.info("Preparing Response...")
executionServiceOutput.commonHeader = executionServiceInput.commonHeader
- executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
- executionServiceOutput.payload = executionServiceInput.payload
+ executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
+ executionServiceOutput.payload = executionServiceInput.payload
// Resolve the Output Expression
val stepOutputs = bluePrintRuntimeService
@@ -126,4 +131,12 @@ abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServic
fun setAttribute(key: String, value: JsonNode) {
bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName, key, value)
}
+
+ /**
+ * This will be called from the scripts to serve instance from runtime to scripts.
+ */
+ open fun <T> functionDependencyInstanceAsType(name: String): T {
+ return functionDependencyInstances[name] as? T
+ ?: throw BluePrintProcessorException("couldn't get script property instance ($name)")
+ }
} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
new file mode 100644
index 00000000..ecdd454e
--- /dev/null
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt
@@ -0,0 +1,77 @@
+/*
+ * Copyright © 2018 IBM.
+ *
+ * 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.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.execution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintScriptsService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.slf4j.LoggerFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+
+@Service
+class ComponentFunctionScriptingService(private val applicationContext: ApplicationContext,
+ private val bluePrintScriptsService: BluePrintScriptsService,
+ private val blueprintJythonService: BlueprintJythonService) {
+
+ private val log = LoggerFactory.getLogger(ComponentFunctionScriptingService::class.java)
+
+ fun <T : AbstractComponentFunction> scriptInstance(componentFunction: AbstractComponentFunction, scriptType: String,
+ scriptClassReference: String,
+ instanceDependencies: MutableList<String>): T {
+ log.info("creating component function of script type($scriptType), reference name($scriptClassReference) and " +
+ "instanceDependencies($instanceDependencies)")
+
+ val scriptComponent: T = scriptInstance(componentFunction.bluePrintRuntimeService.bluePrintContext(),
+ scriptType, scriptClassReference)
+ populateScriptDependencies(scriptComponent, instanceDependencies)
+ return scriptComponent
+ }
+
+
+ fun <T : AbstractComponentFunction> scriptInstance(bluePrintContext: BluePrintContext, scriptType: String,
+ scriptClassReference: String): T {
+ var scriptComponent: T? = null
+
+ when (scriptType) {
+ BluePrintConstants.SCRIPT_INTERNAL -> {
+ scriptComponent = bluePrintScriptsService.scriptInstance<T>(scriptClassReference)
+ }
+ BluePrintConstants.SCRIPT_KOTLIN -> {
+ scriptComponent = bluePrintScriptsService.scriptInstance<T>(bluePrintContext, scriptClassReference, false)
+ }
+ BluePrintConstants.SCRIPT_JYTHON -> {
+ scriptComponent = blueprintJythonService.jythonComponentInstance(bluePrintContext, scriptClassReference) as T
+ }
+ else -> {
+ throw BluePrintProcessorException("script type($scriptType) is not supported")
+ }
+ }
+ return scriptComponent
+ }
+
+
+ private fun populateScriptDependencies(componentFunction: AbstractComponentFunction,
+ instanceDependencies: MutableList<String>) {
+ instanceDependencies.forEach { instanceDependency ->
+ componentFunction.functionDependencyInstances[instanceDependency] = applicationContext
+ .getBean(instanceDependency)
+ }
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
index fcaa57b3..9c039016 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonService.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt
@@ -13,21 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
+package org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
import org.apache.commons.io.FilenameUtils
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.plugin.BlueprintPythonHost
import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
+import java.io.File
@Service
class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
@@ -53,6 +54,30 @@ class BlueprintJythonService(val pythonExecutorProperty: PythonExecutorProperty,
return pyObject.__tojava__(T::class.java) as T
}
+ fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String):
+ AbstractComponentFunction {
+ val blueprintBasePath: String = bluePrintContext.rootPath
+
+ val pythonFileName = bluePrintContext.rootPath
+ .plus(File.separator)
+ .plus(scriptClassReference)
+
+ val pythonClassName = FilenameUtils.getBaseName(pythonFileName)
+ log.info("Getting Jython Script Class($pythonClassName)")
+
+ val content: String = JacksonUtils.getContent(pythonFileName)
+
+ val pythonPath: MutableList<String> = arrayListOf()
+ pythonPath.add(blueprintBasePath)
+ pythonPath.addAll(pythonExecutorProperty.modulePaths)
+
+ val jythonInstances: MutableMap<String, Any> = hashMapOf()
+ jythonInstances["log"] = LoggerFactory.getLogger(pythonClassName)
+
+ return jythonInstance<AbstractComponentFunction>(bluePrintContext, pythonClassName,
+ content, jythonInstances)
+ }
+
fun jythonComponentInstance(abstractComponentFunction: AbstractComponentFunction): AbstractComponentFunction {
val bluePrintRuntimeService = abstractComponentFunction.bluePrintRuntimeService
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
index 7278ced5..e5b248b6 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonHost.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt
@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.plugin
+package org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BluePrintPython
import org.python.core.PyObject
import org.python.util.PythonInterpreter
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
index d3b433af..735b8d77 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/plugin/BlueprintPythonInterpreterProxy.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt
@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.plugin
+package org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BluePrintPython
import org.python.core.PyObject
import org.python.util.PythonInterpreter
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
index 6d17f932..fa3e3a13 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt
@@ -16,7 +16,7 @@
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
+package org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.context.properties.EnableConfigurationProperties
diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
index f6103a4d..b48a10e9 100644
--- a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/BlueprintJythonServiceTest.kt
+++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor
+package org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts
import org.junit.Test
import org.junit.runner.RunWith
@@ -30,8 +30,8 @@ import kotlin.test.assertNotNull
@RunWith(SpringRunner::class)
@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class])
@TestPropertySource(properties =
-["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints"])
+["blueprints.processor.functions.python.executor.modulePaths=./../../../../../components/scripts/python/ccsdk_blueprints",
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../../components/scripts/python/ccsdk_blueprints"])
class BlueprintJythonServiceTest {
@Autowired
@@ -40,11 +40,12 @@ class BlueprintJythonServiceTest {
@Test
fun testGetAbstractPythonPlugin() {
val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext(
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
val dependencies: MutableMap<String, Any> = hashMapOf()
- val content = JacksonUtils.getContent("./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py")
+ val content = JacksonUtils.getContent("./../../../../." +
+ "./components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Scripts/python/SamplePythonComponentNode.py")
val abstractComponentFunction = blueprintJythonService.jythonInstance<AbstractComponentFunction>(bluePrintContext, "SamplePythonComponentNode", content, dependencies)
diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml
index 6b16a7f8..ab418f47 100755
--- a/ms/blueprintsprocessor/parent/pom.xml
+++ b/ms/blueprintsprocessor/parent/pom.xml
@@ -31,6 +31,7 @@
<name>Blueprints Processor Parent</name>
<description>Blueprints Processor Parent</description>
<properties>
+ <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
<spring.boot.version>2.1.2.RELEASE</spring.boot.version>
<spring.version>5.1.4.RELEASE</spring.version>
<kotlin.version>1.3.20</kotlin.version>
diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
index 8724a9f3..d89e9547 100644
--- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
+++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt
@@ -154,6 +154,7 @@ object BluePrintConstants {
const val TOSCA_SCRIPTS_DIR: String = "Scripts"
const val TOSCA_MAPPINGS_DIR: String = "Mappings"
const val TOSCA_TEMPLATES_DIR: String = "Templates"
+ const val TOSCA_ENVIRONMENTS_DIR: String = "Environments"
const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin"
const val TOSCA_SCRIPTS_JYTHON_DIR: String = "$TOSCA_SCRIPTS_DIR/python"
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
index d4e4a24c..63171de6 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/BluePrintEnhancerServiceImpl.kt
@@ -67,14 +67,14 @@ open class BluePrintEnhancerServiceImpl(private val bluePrintTypeEnhancerService
}
} catch (e: Exception) {
- log.error("failed in blueprint enhancement", e)
+ throw e
}
return blueprintRuntimeService.bluePrintContext()
}
private fun enhanceResourceDefinition(blueprintRuntimeService: BluePrintRuntimeService<*>) {
-
+ log.info("##### Enhancing blueprint Resource Definitions")
resourceDefinitionEnhancerService.enhance(blueprintRuntimeService)
}
diff --git a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
index ab5ca74c..43eb019e 100644
--- a/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
+++ b/ms/controllerblueprints/modules/service/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/service/enhancer/ResourceDefinitionEnhancerService.kt
@@ -1,5 +1,6 @@
/*
* Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,7 +76,7 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
artifactDefinitionMap.value.file
}
- }?.single { it.isNotEmpty() }?.distinct()
+ }?.flatten()?.distinct()
}
// Convert file content to ResourceAssignments asynchronously
@@ -103,12 +104,12 @@ class ResourceDefinitionEnhancerServiceImpl(private val resourceDefinitionRepoSe
// Read the Resource Definitions from the Database and write to type file.
private fun generateResourceDictionaryFile(blueprintBasePath: String, resourceAssignments: List<ResourceAssignment>) {
- val resourcekeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct()
- log.info("distinct resource keys ($resourcekeys)")
+ val resourceKeys = resourceAssignments.mapNotNull { it.dictionaryName }.distinct().sorted()
+ log.info("distinct resource keys ($resourceKeys)")
//TODO("Optimise DB single Query to multiple Query")
// Collect the Resource Definition from database and convert to map to save in file
- val resourceDefinitionMap = resourcekeys.map { resourceKey ->
+ val resourceDefinitionMap = resourceKeys.map { resourceKey ->
getResourceDefinition(resourceKey)
}.map { it.name to it }.toMap()
diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml
index f29e5014..ea7b4e40 100644
--- a/ms/controllerblueprints/parent/pom.xml
+++ b/ms/controllerblueprints/parent/pom.xml
@@ -29,6 +29,7 @@
<name>Controller Blueprints Parent</name>
<packaging>pom</packaging>
<properties>
+ <kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
<spring.boot.version>2.1.2.RELEASE</spring.boot.version>
<spring.version>5.1.4.RELEASE</spring.version>
<kotlin.version>1.3.20</kotlin.version>