diff options
author | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-03-26 09:49:13 -0400 |
---|---|---|
committer | Alexis de Talhouët <adetalhouet89@gmail.com> | 2019-03-26 09:49:13 -0400 |
commit | 72d22a4339db09824d46746dacbba1e141763dc0 (patch) | |
tree | 7fbfea4b81afca0bc0c95e5d4b810f236f4dea29 /ms/blueprintsprocessor/modules/services/execution-service | |
parent | ef6983b670796becfa66c69075c1829e8f9aef4b (diff) |
Migrate ccdsk/apps to ccsdk/cds
Change-Id: I020a2ccec4e691717f888e8bd2afec91a7c4e987
Issue-ID: CCSDK-1178
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/blueprintsprocessor/modules/services/execution-service')
11 files changed, 0 insertions, 735 deletions
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml deleted file mode 100644 index 913ce467..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ 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. - ~ 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. - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>services</artifactId> - <version>0.4.2-SNAPSHOT</version> - </parent> - - <artifactId>execution-service</artifactId> - <packaging>jar</packaging> - <name>Blueprints Processor Execution Service</name> - <description>Blueprints Processor Execution Service</description> - - <dependencies> - <dependency> - <groupId>org.python</groupId> - <artifactId>jython-standalone</artifactId> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> - <artifactId>blueprint-core</artifactId> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> - <artifactId>blueprint-scripts</artifactId> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>processor-core</artifactId> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>db-lib</artifactId> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>rest-lib</artifactId> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> - <artifactId>resource-dict</artifactId> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.apps.components</groupId> - <artifactId>proto-definition</artifactId> - </dependency> - - <dependency> - <groupId>org.onap.ccsdk.sli.core</groupId> - <artifactId>sli-provider</artifactId> - </dependency> - </dependencies> -</project> 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 deleted file mode 100644 index 4c381706..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt +++ /dev/null @@ -1,148 +0,0 @@ -/*
- * 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.
- * 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 com.fasterxml.jackson.databind.JsonNode
-import com.fasterxml.jackson.databind.node.JsonNodeFactory
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
-import org.onap.ccsdk.apps.controllerblueprints.common.api.EventType
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
-import org.onap.ccsdk.apps.controllerblueprints.core.asObjectNode
-import org.onap.ccsdk.apps.controllerblueprints.core.getAsString
-import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
-import org.slf4j.LoggerFactory
-
-/**
- * AbstractComponentFunction
- * @author Brinda Santh
- */
-abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {
- @Transient
- private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)
-
- lateinit var executionServiceInput: ExecutionServiceInput
- var executionServiceOutput = ExecutionServiceOutput()
- lateinit var bluePrintRuntimeService: BluePrintRuntimeService<*>
- lateinit var processId: String
- lateinit var workflowName: String
- lateinit var stepName: String
- lateinit var interfaceName: String
- lateinit var operationName: String
- lateinit var nodeTemplateName: String
- var operationInputs: MutableMap<String, JsonNode> = hashMapOf()
-
- override fun getName(): String {
- return stepName
- }
-
- override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput {
- checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }
-
- check(stepName.isNotEmpty()) { "failed to assign step name" }
-
- this.executionServiceInput = executionRequest
-
- processId = executionRequest.commonHeader.requestId
- check(processId.isNotEmpty()) { "couldn't get process id for step($stepName)" }
-
- 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)")
-
- val operationInputs = bluePrintRuntimeService.get("$stepName-step-inputs")
- ?: JsonNodeFactory.instance.objectNode()
-
- operationInputs.fields().forEach {
- this.operationInputs[it.key] = it.value
- }
-
- nodeTemplateName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)
- check(nodeTemplateName.isNotEmpty()) { "couldn't get NodeTemplate name for step($stepName)" }
-
- interfaceName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)
- check(interfaceName.isNotEmpty()) { "couldn't get Interface name for step($stepName)" }
-
- operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)
- check(operationName.isNotEmpty()) { "couldn't get Operation name for step($stepName)" }
-
- val operationResolvedProperties = bluePrintRuntimeService
- .resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)
-
- this.operationInputs.putAll(operationResolvedProperties)
-
- return executionRequest
- }
-
- override fun prepareResponse(): ExecutionServiceOutput {
- log.info("Preparing Response...")
- executionServiceOutput.commonHeader = executionServiceInput.commonHeader
- executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
-
- // Resolve the Output Expression
- val stepOutputs = bluePrintRuntimeService
- .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)
-
- // FIXME("Not the right place to populate the response payload")
- executionServiceOutput.payload = stepOutputs.asObjectNode()
-
- bluePrintRuntimeService.put("$stepName-step-outputs", executionServiceOutput.payload)
-
- // FIXME("Not the right place to populate the status")
- // Populate Status
- val status = Status()
- status.eventType = EventType.EVENT_COMPONENT_EXECUTED.name
- status.code = 200
- status.message = BluePrintConstants.STATUS_SUCCESS
- executionServiceOutput.status = status
- return this.executionServiceOutput
- }
-
- override fun apply(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
- try {
- prepareRequest(executionServiceInput)
- process(executionServiceInput)
- } catch (runtimeException: RuntimeException) {
- recover(runtimeException, executionServiceInput)
- }
- return prepareResponse()
- }
-
- fun getOperationInput(key: String): JsonNode {
- return operationInputs[key]
- ?: throw BluePrintProcessorException("couldn't get the operation input($key) value.")
- }
-
- fun setAttribute(key: String, value: JsonNode) {
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName, key, value)
- }
-
- fun addError(type: String, name: String, error: String) {
- bluePrintRuntimeService.getBluePrintError().addError(type, name, error)
- }
-
- fun addError(error: String) {
- bluePrintRuntimeService.getBluePrintError().addError(error)
- }
-
-}
\ 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/AbstractScriptComponentFunction.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt deleted file mode 100644 index 811ee4a2..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractScriptComponentFunction.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - * 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 com.fasterxml.jackson.databind.JsonNode -import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException - -abstract class AbstractScriptComponentFunction : AbstractComponentFunction() { - - companion object { - const val DYNAMIC_PROPERTIES = "dynamic-properties" - } - - /** - * Store Dynamic Script Dependency Instances, Objects present inside won't be persisted or state maintained. - */ - var functionDependencyInstances: MutableMap<String, Any> = hashMapOf() - - /** - * 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)") - } - - fun checkDynamicProperties(key: String): Boolean { - return operationInputs[DYNAMIC_PROPERTIES]?.has(key) ?: false - } - - fun getDynamicProperties(key: String): JsonNode { - return operationInputs[DYNAMIC_PROPERTIES]!!.get(key) - } - - -}
\ 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 deleted file mode 100644 index 2cf22325..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ComponentFunctionScriptingService.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.interfaces.BlueprintFunctionNode -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 : AbstractScriptComponentFunction> scriptInstance(componentFunction: AbstractComponentFunction, scriptType: String, - scriptClassReference: String, - instanceDependencies: List<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) - - checkNotNull(scriptComponent) { "failed to initialize script component" } - - scriptComponent.bluePrintRuntimeService = componentFunction.bluePrintRuntimeService - scriptComponent.processId = componentFunction.processId - scriptComponent.workflowName = componentFunction.workflowName - scriptComponent.stepName = componentFunction.stepName - scriptComponent.interfaceName = componentFunction.interfaceName - scriptComponent.operationName = componentFunction.operationName - scriptComponent.nodeTemplateName = componentFunction.nodeTemplateName - scriptComponent.operationInputs = componentFunction.operationInputs - - // Populate Instance Properties - instanceDependencies.forEach { instanceDependency -> - scriptComponent.functionDependencyInstances[instanceDependency] = applicationContext - .getBean(instanceDependency) - } - return scriptComponent - } - - - fun <T : BlueprintFunctionNode<*, *>> 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 - } - -}
\ 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/scripts/BlueprintJythonService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt deleted file mode 100644 index 3937f27c..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonService.kt +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright © 2019 IBM, Bell Canada. - * - * 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.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.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.interfaces.BlueprintFunctionNode -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, - private val applicationContext: ApplicationContext) { - - val log: Logger = LoggerFactory.getLogger(BlueprintJythonService::class.java) - - inline fun <reified T> jythonInstance(blueprintContext: BluePrintContext, pythonClassName: String, content: String, - dependencyInstanceNames: MutableMap<String, Any>?): T { - - val blueprintBasePath: String = blueprintContext.rootPath - val pythonPath: MutableList<String> = arrayListOf() - pythonPath.add(blueprintBasePath) - pythonPath.addAll(pythonExecutorProperty.modulePaths) - - val blueprintPythonConfigurations = BluePrintPython(pythonExecutorProperty.executionPath, pythonPath, arrayListOf()) - - val blueprintPythonHost = BlueprintPythonHost(blueprintPythonConfigurations) - val pyObject = blueprintPythonHost.getPythonComponent(content, pythonClassName, dependencyInstanceNames) - - log.info("Component Object {}", pyObject) - - return pyObject.__tojava__(T::class.java) as T - } - - fun jythonComponentInstance(bluePrintContext: BluePrintContext, scriptClassReference: String): - BlueprintFunctionNode<*, *> { - 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<BlueprintFunctionNode<*, *>>(bluePrintContext, pythonClassName, - content, jythonInstances) - } - - fun jythonComponentInstance(abstractComponentFunction: AbstractComponentFunction): AbstractComponentFunction { - - val bluePrintRuntimeService = abstractComponentFunction.bluePrintRuntimeService - val bluePrintContext = bluePrintRuntimeService.bluePrintContext() - val nodeTemplateName: String = abstractComponentFunction.nodeTemplateName - val operationInputs: MutableMap<String, JsonNode> = abstractComponentFunction.operationInputs - - val operationAssignment: OperationAssignment = bluePrintContext - .nodeTemplateInterfaceOperation(abstractComponentFunction.nodeTemplateName, - abstractComponentFunction.interfaceName, abstractComponentFunction.operationName) - - val blueprintBasePath: String = bluePrintContext.rootPath - - val artifactName: String = operationAssignment.implementation?.primary - ?: throw BluePrintProcessorException("missing primary field to get artifact name for node template ($nodeTemplateName)") - - val artifactDefinition = bluePrintRuntimeService.resolveNodeTemplateArtifactDefinition(nodeTemplateName, artifactName) - - val pythonFileName = artifactDefinition.file - ?: throw BluePrintProcessorException("missing file name for node template ($nodeTemplateName)'s artifactName($artifactName)") - - val pythonClassName = FilenameUtils.getBaseName(pythonFileName) - log.info("Getting Jython Script Class($pythonClassName)") - - val content: String? = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName) - - checkNotEmptyOrThrow(content, "artifact ($artifactName) content is empty") - - val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf() - pythonPath.add(blueprintBasePath) - pythonPath.addAll(pythonExecutorProperty.modulePaths) - - val jythonInstances: MutableMap<String, Any> = hashMapOf() - jythonInstances["log"] = LoggerFactory.getLogger(nodeTemplateName) - - val instanceDependenciesNode: ArrayNode = operationInputs[PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES] as? ArrayNode - ?: throw BluePrintProcessorException("Failed to get property(${PythonExecutorConstants.INPUT_INSTANCE_DEPENDENCIES})") - - instanceDependenciesNode.forEach { instanceName -> - jythonInstances[instanceName.textValue()] = applicationContext.getBean(instanceName.textValue()) - } - - val scriptComponentFunction = jythonInstance<AbstractComponentFunction>(bluePrintContext, pythonClassName, - content!!, jythonInstances) - - return scriptComponentFunction - - } - -}
\ 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/scripts/BlueprintPythonHost.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt deleted file mode 100644 index e5b248b6..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonHost.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright © 2019 IBM, Bell Canada. - * - * 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.scripts - -import org.python.core.PyObject -import org.python.util.PythonInterpreter - -open class BlueprintPythonHost(private val bluePrintPython: BluePrintPython){ - private val blueprintPythonInterpreterProxy: BlueprintPythonInterpreterProxy - - init { - PythonInterpreter.initialize(System.getProperties(), bluePrintPython.props, bluePrintPython.argv.toTypedArray()) - blueprintPythonInterpreterProxy = BlueprintPythonInterpreterProxy(bluePrintPython) - } - - /** - * getPythonComponent Purpose: execute the python script and return the python interpreter object - * - * @param content String - * @param interfaceName String - * @param properties MutableMap<String, Any> - * @return pyObject PyObject - */ - fun getPythonComponent(content: String?, interfaceName: String, properties: MutableMap<String, Any>?): PyObject { - bluePrintPython.content = content!! - bluePrintPython.pythonClassName = interfaceName - bluePrintPython.moduleName = "Blueprint Python Script [Class Name = $interfaceName]" - - return blueprintPythonInterpreterProxy.getPythonInstance(properties) - } - - //TODO Check potential errors in python scripts -}
\ 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/scripts/BlueprintPythonInterpreterProxy.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt deleted file mode 100644 index 735b8d77..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintPythonInterpreterProxy.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright © 2019 IBM, Bell Canada. - * - * 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.scripts - -import org.python.core.PyObject -import org.python.util.PythonInterpreter - -open class BlueprintPythonInterpreterProxy(private val bluePrintPython: BluePrintPython): PythonInterpreter(){ - - fun getPythonInstance(properties: MutableMap<String, Any>?): PyObject{ - properties?.forEach { (name, value) -> - this.set(name, value) - } - - this.exec("import sys") - - bluePrintPython.content.let { - this.exec(bluePrintPython.content) - } - - val initCommand = bluePrintPython.pythonClassName.plus(" = ").plus( - bluePrintPython.pythonClassName).plus("()") - this.exec(initCommand) - - return this.get(bluePrintPython.pythonClassName) - } -}
\ 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/scripts/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt deleted file mode 100644 index fa3e3a13..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/PythonExecutorConfiguration.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * - * Modifications Copyright © 2019 IBM, Bell Canada. - * - * 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.scripts - -import org.springframework.beans.factory.annotation.Value -import org.springframework.boot.context.properties.EnableConfigurationProperties -import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.Configuration -import java.io.File -import java.util.* - -@Configuration -@ComponentScan -@EnableConfigurationProperties -open class PythonExecutorConfiguration - -@Configuration -open class PythonExecutorProperty { - @Value("\${blueprints.processor.functions.python.executor.executionPath}") - lateinit var executionPath: String - @Value("#{'\${blueprints.processor.functions.python.executor.modulePaths}'.split(',')}") - lateinit var modulePaths: List<String> -} - -class PythonExecutorConstants { - companion object { - const val INPUT_INSTANCE_DEPENDENCIES = "instance-dependencies" - } -} - -open class BluePrintPython(executablePath: String, blueprintPythonPlatform: MutableList<String>, - val argv: MutableList<String>){ - lateinit var moduleName: String - lateinit var pythonClassName: String - lateinit var content: String - var props: Properties = Properties() - - init { - // Build up the python.path - val sb = StringBuilder() - sb.append(System.getProperty("java.class.path")) - - for (p in blueprintPythonPlatform) { - sb.append(File.pathSeparator).append(p) - } - - props["python.import.site"] = "true" - props.setProperty("python.path", sb.toString()) - props.setProperty("python.verbose", "error") - props.setProperty("python.executable", executablePath) - } -}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt deleted file mode 100644 index b48a10e9..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/scripts/BlueprintJythonServiceTest.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright © 2019 IBM, Bell Canada. - * - * 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.scripts - -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.services.execution.AbstractComponentFunction -import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.test.context.ContextConfiguration -import org.springframework.test.context.TestPropertySource -import org.springframework.test.context.junit4.SpringRunner -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"]) -class BlueprintJythonServiceTest { - - @Autowired - private lateinit var blueprintJythonService: BlueprintJythonService - - @Test - fun testGetAbstractPythonPlugin() { - val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext( - "./../../../../../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 abstractComponentFunction = blueprintJythonService.jythonInstance<AbstractComponentFunction>(bluePrintContext, "SamplePythonComponentNode", content, dependencies) - - assertNotNull(abstractComponentFunction, "failed to get python component") - - abstractComponentFunction.process(ExecutionServiceInput()) - - } -}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/inputs/input.json b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/inputs/input.json deleted file mode 100644 index cd6fac12..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/inputs/input.json +++ /dev/null @@ -1,18 +0,0 @@ -{
- "api-ver": "2.00",
- "originator-id": "MSO",
- "request-id": "123456",
- "service-instance-id": "ibcx0001vm001",
- "service-type": "AVPN",
- "vnf-type": "vUSP - vDBE-IPX HUB",
- "vnf-id": 123456,
- "service-template-name": "VRR-baseconfiguration",
- "service-template-version": "1.0.0",
- "action-name": "resource-assignment-action",
- "group-name": "sample group name",
- "bundle-id": "sample bundle id",
- "bundle-mac": [
- "Sample bundle mac",
- "Sample bundle mac"
- ]
-}
diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json deleted file mode 100644 index b28ac5a2..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json +++ /dev/null @@ -1,20 +0,0 @@ -{
- "actionIdentifiers": {
- "actionName": "sample-action",
- "blueprintName": "sample-blurprint",
- "blueprintVersion": "1.0.0",
- "mode": "sync"
- },
- "commonHeader": {
- "flags": {
- "force": true,
- "ttl": 3600
- },
- "originatorId": "sdnc",
- "requestId": "123456-1000",
- "subRequestId": "sub-123456-1000",
- "timestamp": "2012-04-23T18:25:43.511Z"
- },
- "payload": {
- }
-}
|