diff options
Diffstat (limited to 'ms')
33 files changed, 726 insertions, 61 deletions
diff --git a/ms/blueprintsprocessor/.gitignore b/ms/blueprintsprocessor/.gitignore index b25ff7b0..983e231d 100644 --- a/ms/blueprintsprocessor/.gitignore +++ b/ms/blueprintsprocessor/.gitignore @@ -15,6 +15,7 @@ **/target/* **/logs/* **/tokens/* +**/lib/cachedir/** # Added for Intellij IDEA IDE **/debug-logs/* diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java index 0b5f6227..fc1007f7 100644 --- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java +++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/SwaggerConfig.java @@ -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.
@@ -19,9 +20,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-import org.springframework.web.bind.annotation.RequestMapping;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
@@ -44,7 +43,7 @@ import java.util.Set; @EnableSwagger2
public class SwaggerConfig {
private static final Set<String> DEFAULT_PRODUCES_AND_CONSUMES =
- new HashSet<String>(Arrays.asList("application/json",
+ new HashSet<>(Arrays.asList("application/json",
"application/xml"));
private static Logger log = LoggerFactory.getLogger(SwaggerConfig.class);
diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java index f1b8f9d6..3742f560 100644 --- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java +++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/WebConfig.java @@ -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.
@@ -16,10 +17,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
-import org.springframework.format.FormatterRegistry;
import org.springframework.web.reactive.config.*;
/**
@@ -29,6 +27,7 @@ import org.springframework.web.reactive.config.*; */
@Configuration
public class WebConfig extends WebFluxConfigurationSupport {
+ @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml index 50ea7b0e..efd550dd 100644 --- a/ms/blueprintsprocessor/functions/pom.xml +++ b/ms/blueprintsprocessor/functions/pom.xml @@ -31,6 +31,7 @@ <description>Blueprints Processor Functions POM</description> <modules> <module>resource-resolution</module> + <module>python-executor</module> </modules> <dependencies> diff --git a/ms/blueprintsprocessor/functions/python-executor/pom.xml b/ms/blueprintsprocessor/functions/python-executor/pom.xml new file mode 100644 index 00000000..4f9cc745 --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/pom.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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"> + <parent> + <artifactId>functions</artifactId> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> + <version>0.4.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> + <artifactId>python-executor</artifactId> + <name>Blueprints Processor Function - Python Executor</name> + <description>Blueprints Processor Function - Python Executor</description> + + <dependencies> + <dependency> + <groupId>org.python</groupId> + <artifactId>jython-standalone</artifactId> + </dependency> + </dependencies> + + +</project>
\ 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/ComponentJythonExecutor.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt new file mode 100644 index 00000000..2965cb5d --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutor.kt @@ -0,0 +1,83 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.functions.python.executor + +import org.apache.commons.io.FilenameUtils +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils +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.controllerblueprints.core.checkNotEmptyNThrow +import org.onap.ccsdk.apps.controllerblueprints.core.data.OperationAssignment +import org.slf4j.LoggerFactory +import org.springframework.stereotype.Component + +@Component("component-jython-executor") +class ComponentJythonExecutor(private val pythonExecutorProperty: PythonExecutorProperty) : AbstractComponentFunction() { + + private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java) + + private var componentFunction: AbstractComponentFunction? = null + + + override fun process(executionServiceInput: ExecutionServiceInput) { + + log.info("Processing : ${executionServiceInput.metadata}") + checkNotNull(bluePrintRuntimeService) { "failed to get bluePrintRuntimeService" } + + val bluePrintContext = bluePrintRuntimeService!!.bluePrintContext() + + val operationAssignment: OperationAssignment = bluePrintContext + .nodeTemplateInterfaceOperation(nodeTemplateName, interfaceName, operationName) + + val blueprintBasePath: String = bluePrintRuntimeService!!.get(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)?.asText() + ?: throw BluePrintProcessorException("python execute path is missing for node template ($nodeTemplateName)") + + 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) + + val content: String? = bluePrintRuntimeService!!.resolveNodeTemplateArtifact(nodeTemplateName, artifactName) + + checkNotEmptyNThrow(content, "artifact ($artifactName) content is empty") + + val pythonPath: MutableList<String> = operationAssignment.implementation?.dependencies ?: arrayListOf() + pythonPath.add(blueprintBasePath) + pythonPath.addAll(pythonExecutorProperty.modulePaths) + + val properties: MutableMap<String, Any> = hashMapOf() + properties["log"] = log + + componentFunction = PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath, + pythonPath, content, pythonClassName, properties) + + componentFunction!!.process(executionServiceInput) + + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + componentFunction!!.recover(runtimeException, executionRequest) + } + +}
\ 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/JythonExecutionService.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt new file mode 100644 index 00000000..dc372af4 --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/JythonExecutionService.kt @@ -0,0 +1,51 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.functions.python.executor + +import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.utils.PythonExecutorUtils +import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service + +@Service +class JythonExecutionService(private val pythonExecutorProperty: PythonExecutorProperty) { + + + private val log = LoggerFactory.getLogger(ComponentJythonExecutor::class.java) + + @Autowired + lateinit var applicationContext: ApplicationContext + + + fun processJythonNodeTemplate(pythonClassName: String, content: String, pythonPath: MutableList<String>, + jythonContextInstance: MutableMap<String, Any>, + dependencyInstanceNames: List<String>): AbstractComponentFunction { + + + dependencyInstanceNames.forEach { instanceName -> + jythonContextInstance[instanceName] = applicationContext.getBean(instanceName) + + } + + return PythonExecutorUtils.getPythonComponent(pythonExecutorProperty.executionPath, + pythonPath, content, pythonClassName, jythonContextInstance) + + } + +}
\ 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/PythonExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt new file mode 100644 index 00000000..dd80fb0a --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/PythonExecutorConfiguration.kt @@ -0,0 +1,36 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.functions.python.executor + +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 + +@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> + +}
\ 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/utils/PythonExecutorUtils.kt b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt new file mode 100644 index 00000000..66c919d4 --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtils.kt @@ -0,0 +1,77 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.functions.python.executor.utils + +import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.python.core.PyObject +import org.python.util.PythonInterpreter +import org.slf4j.LoggerFactory +import java.util.* + +class PythonExecutorUtils { + companion object { + + private val log = LoggerFactory.getLogger(PythonExecutorUtils::class.java) + + fun getPythonComponent(executePath: String, pythonPath: MutableList<String>, content: String?, interfaceName: String, + properties: MutableMap<String, Any>): AbstractComponentFunction { + + initPython(executePath, pythonPath, arrayListOf()) + val pythonInterpreter = PythonInterpreter() + + properties.forEach { (name, value) -> + pythonInterpreter.set(name, value) + } + + pythonInterpreter.exec("import sys") + + content?.let { + pythonInterpreter.exec(content) + } + + val initCommand = interfaceName.plus(" = ").plus(interfaceName).plus("()") + pythonInterpreter.exec(initCommand) + val pyObject: PyObject = pythonInterpreter.get(interfaceName) + + log.info("Component Object {}", pyObject) + + return pyObject.__tojava__(AbstractComponentFunction::class.java) as AbstractComponentFunction + } + + private fun initPython(executablePath: String, + pythonPath: MutableList<String>, argv: MutableList<String>) { + + val props = Properties() + // Build up the python.path + val sb = StringBuilder() + sb.append(System.getProperty("java.class.path")) + + for (p in pythonPath) { + sb.append(":").append(p) + } + log.debug("Paths : $sb") + + props["python.import.site"] = "true" + props.setProperty("python.path", sb.toString()) + props.setProperty("python.verbose", "error") + props.setProperty("python.executable", executablePath) + + PythonInterpreter.initialize(System.getProperties(), props, argv.toTypedArray()) + } + + } +}
\ No newline at end of file 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 new file mode 100644 index 00000000..1ce8d05b --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/ComponentJythonExecutorTest.kt @@ -0,0 +1,76 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.functions.python.executor + +import com.fasterxml.jackson.databind.JsonNode +import org.junit.Test +import org.junit.runner.RunWith +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.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +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 + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [PythonExecutorConfiguration::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 ComponentJythonExecutorTest { + + @Autowired + lateinit var componentJythonExecutor: ComponentJythonExecutor + + + @Test + fun testPythonComponentInjection() { + + val executionServiceInput = ExecutionServiceInput() + val commonHeader = CommonHeader() + commonHeader.requestId = "1234" + executionServiceInput.commonHeader = commonHeader + + val actionIdentifiers = ActionIdentifiers() + actionIdentifiers.blueprintName = "baseconfiguration" + actionIdentifiers.blueprintVersion = "1.0.0" + actionIdentifiers.actionName = "activate" + executionServiceInput.actionIdentifiers = actionIdentifiers + + + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(commonHeader.requestId, + "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + + componentJythonExecutor.bluePrintRuntimeService = bluePrintRuntimeService + + + val metaData: MutableMap<String, JsonNode> = hashMapOf() + metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "resource-assignment-py") + metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "resource-assignment-py") + metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ResourceAssignmentComponent") + metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") + executionServiceInput.metadata = metaData + + componentJythonExecutor.apply(executionServiceInput) + + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt new file mode 100644 index 00000000..6197c4b2 --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/python/executor/utils/PythonExecutorUtilsTest.kt @@ -0,0 +1,52 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.functions.python.executor.utils + +import org.junit.Test +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.slf4j.LoggerFactory +import kotlin.test.assertNotNull + + +class PythonExecutorUtilsTest { + + private val log = LoggerFactory.getLogger(PythonExecutorUtils::class.java) + + @Test + fun testGetPythonComponent() { + + val pythonPath: MutableList<String> = arrayListOf() + pythonPath.add("./../../../../components/scripts/python/ccsdk_blueprints") + + val properties: MutableMap<String, Any> = hashMapOf() + properties["logger"] = log + + val content = JacksonUtils.getContent("./../../../../components/scripts/python/ccsdk_blueprints/sample_blueprint_component.py") + + val abstractComponentFunction = PythonExecutorUtils.getPythonComponent("/home/brindasanth/onap/apps/components/scripts/python/ccsdk_blueprints", pythonPath, content, + "SampleBlueprintComponent", properties) + + assertNotNull(abstractComponentFunction, "failed to get python component") + + abstractComponentFunction.process(ExecutionServiceInput()) + + } + + +} + diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml new file mode 100644 index 00000000..a816a06c --- /dev/null +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml @@ -0,0 +1,35 @@ +<!--
+ ~ Copyright © 2017-2018 AT&T Intellectual Property.
+ ~
+ ~ 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.
+ -->
+
+<configuration>
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <!-- encoders are assigned the type
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+
+ <logger name="org.springframework" level="warn"/>
+ <logger name="org.hibernate" level="info"/>
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>
+
+ <root level="warn">
+ <appender-ref ref="STDOUT"/>
+ </root>
+
+</configuration>
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml index a2d3bb85..858be70c 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml +++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml @@ -25,7 +25,7 @@ <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> <artifactId>resource-resolution</artifactId> <packaging>jar</packaging> - <name>Blueprints Processor Resolution Service</name> - <description>Blueprints Processor Resolution Service</description> + <name>Blueprints Processor Function - Resource Resolution</name> + <description>Blueprints Processor Function - Resource Resolution</description> </project> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt index 155b3b03..9e735cf0 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt @@ -47,8 +47,6 @@ class ResourceResolutionService { resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
- val context = hashMapOf<String, Any>()
-
process(resourceResolutionOutput.resourceAssignments)
val status = Status()
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt index 45f684f1..adce865a 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorData.kt @@ -22,6 +22,7 @@ import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.node.ObjectNode
import io.swagger.annotations.ApiModelProperty
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import java.util.*
/**
* BlueprintProcessorData
@@ -87,7 +88,7 @@ open class ActionIdentifiers { open class CommonHeader {
@get:ApiModelProperty(required = true, example = "2012-04-23T18:25:43.511Z")
@get:JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
- lateinit var timestamp: String
+ var timestamp: Date = Date()
@get:ApiModelProperty(required = true)
lateinit var originatorId: String
@get:ApiModelProperty(required = true)
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 9a0d1f91..dfdf6259 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 @@ -19,7 +19,10 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.execution 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.controllerblueprints.core.BluePrintConstants
+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
/**
@@ -29,14 +32,39 @@ import org.slf4j.LoggerFactory abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {
private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)
- override fun prepareRequest(executionRequest: ExecutionServiceInput): ExecutionServiceInput {
+ var executionServiceInput: ExecutionServiceInput? = null
+ var executionServiceOutput = ExecutionServiceOutput()
+ var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null
+ var processId: String = ""
+ var workflowName: String = ""
+ var stepName: String = ""
+ var interfaceName: String = ""
+ var operationName: String = ""
+ var nodeTemplateName: String = ""
+
+
+ override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput {
+
+ this.executionServiceInput = this.executionServiceInput
+
+ processId = executionServiceInput.commonHeader.requestId
+ workflowName = executionServiceInput.actionIdentifiers.actionName
+
+ val metadata = executionServiceInput.metadata
+ stepName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_STEP)
+ nodeTemplateName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)
+ interfaceName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)
+ operationName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)
+
+ checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }
+
log.info("prepareRequest...")
- return executionRequest
+ return executionServiceInput
}
override fun prepareResponse(): ExecutionServiceOutput {
log.info("Preparing Response...")
- return ExecutionServiceOutput()
+ return this.executionServiceOutput
}
override fun apply(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt new file mode 100644 index 00000000..993f10ee --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionService.kt @@ -0,0 +1,71 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.workflow + +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.services.workflow.utils.SvcGraphUtils +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.slf4j.LoggerFactory +import org.springframework.stereotype.Service +import java.io.File + + +interface BlueprintDGExecutionService { + + fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>, + executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput + +} + +@Service +class DefaultBlueprintDGExecutionService(val blueprintSvcLogicService: BlueprintSvcLogicService) : BlueprintDGExecutionService { + + private val log = LoggerFactory.getLogger(DefaultBlueprintDGExecutionService::class.java) + + override fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>, + executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput { + + val bluePrintContext = bluePrintRuntimeService.bluePrintContext() + + val workflowName = executionServiceInput.actionIdentifiers.actionName + + // Get the DG Node Template + val nodeTemplateName = bluePrintContext.workflowFirstStepNodeTemplate(workflowName) + + log.info("Executing workflow($workflowName) directed graph NodeTemplate($nodeTemplateName)") + + // Get the DG file info + val artifactDefinition = bluePrintContext.nodeTemplateArtifactForArtifactType(nodeTemplateName, + WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH) + + // Populate the DG Path + val dgFilePath = bluePrintRuntimeService.getAsString(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH) + .plus(File.separator).plus(artifactDefinition.file) + + log.info("Executing directed graph ($dgFilePath)") + + // Create DG instance + val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath) + + // Execute the DG + return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput + + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt index 8750d98b..ab7d7385 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt @@ -36,7 +36,7 @@ interface BlueprintSvcLogicService : SvcLogicService { fun unRegisterExecutors(name: String) - fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>): Any + fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any @Deprecated("Populate Graph Dynamically from Blueprints, No need to get from Database Store ") override fun getStore(): SvcLogicStore { @@ -93,10 +93,11 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { } } - override fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>): Any { - //Initialise BlueprintSvcLogic Context + override fun execute(graph: SvcLogicGraph, bluePrintRuntimeService: BluePrintRuntimeService<*>, input: Any): Any { + //Initialise BlueprintSvcLogic Context with Blueprint Runtime Service and Input Request val blueprintSvcLogicContext = BlueprintSvcLogicContext() blueprintSvcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) + blueprintSvcLogicContext.setRequest(input) // Execute the Graph execute(graph, blueprintSvcLogicContext) // Get the Response @@ -125,12 +126,6 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { override fun execute(graph: SvcLogicGraph, svcLogicContext: SvcLogicContext): SvcLogicContext { MDC.put("currentGraph", graph.toString()) - val ctx = svcLogicContext as BlueprintSvcLogicContext - - val blueprintRuntimeService = ctx.getBluePrintService() - - log.info("Blueprint Runtime Service : ${blueprintRuntimeService}") - var curNode: SvcLogicNode? = graph.getRootNode() log.info("About to execute graph {}", graph.toString()) @@ -138,7 +133,7 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { while (curNode != null) { MDC.put("nodeId", curNode.nodeId.toString() + " (" + curNode.nodeType + ")") log.info("About to execute node # {} ({})", curNode.nodeId, curNode.nodeType) - val nextNode = this.executeNode(curNode, ctx) + val nextNode = this.executeNode(curNode, svcLogicContext) curNode = nextNode } } catch (var5: ExitNodeException) { @@ -147,6 +142,6 @@ class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { MDC.remove("nodeId") MDC.remove("currentGraph") - return ctx + return svcLogicContext } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt index b9c041e9..b3186e84 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt @@ -21,6 +21,11 @@ import org.springframework.context.annotation.Configuration @Configuration @ComponentScan -open class WorkflowServiceConfiguration { +open class WorkflowServiceConfiguration + +class WorkflowServiceConstants { + companion object { + const val ARTIFACT_TYPE_DIRECTED_GRAPH = "artifact-directed-graph" + } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt index 125a1ff6..ace9f278 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.kt @@ -60,6 +60,8 @@ open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() { log.info("executing node template($nodeTemplateName) component($componentName)") // Get the Component Instance val plugin = this.getComponentFunction(componentName) + // Set the Blueprint Service + plugin.bluePrintRuntimeService = ctx.getBluePrintService() val executionInput = ctx.getRequest() as ExecutionServiceInput // Get the Request from the Context and Set to the Function Input and Invoke the function diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt new file mode 100644 index 00000000..46bb6f08 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintDGExecutionServiceTest.kt @@ -0,0 +1,53 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * 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.workflow + +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.workflow.executor.ComponentExecuteNodeExecutor +import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.junit4.SpringRunner + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class]) +class BlueprintDGExecutionServiceTest { + + private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java) + + @Autowired + lateinit var blueprintDGExecutionService: BlueprintDGExecutionService + + + @Test + fun testExecuteDirectedGraph() { + + val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", + "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + + val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!! + + blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput) + + } + + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt index 5c90852e..341b6f84 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt @@ -22,6 +22,7 @@ import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInp import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils.SvcGraphUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.test.context.ContextConfiguration @@ -36,6 +37,8 @@ class BlueprintServiceLogicTest { val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration") + val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/default-input.json", ExecutionServiceInput::class.java)!! + @Autowired lateinit var blueprintSvcLogicService: BlueprintSvcLogicService @@ -43,20 +46,15 @@ class BlueprintServiceLogicTest { fun testExecuteGraphWithSingleComponent() { val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml") - val svcLogicContext = BlueprintSvcLogicContext() - svcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) - svcLogicContext.setRequest(ExecutionServiceInput()) - blueprintSvcLogicService.execute(graph, svcLogicContext) + blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) } @Test fun testExecuteGraphWithMultipleComponents() { val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml") - val svcLogicContext = BlueprintSvcLogicContext() - svcLogicContext.setBluePrintRuntimeService(bluePrintRuntimeService) - svcLogicContext.setRequest(ExecutionServiceInput()) - blueprintSvcLogicService.execute(graph, svcLogicContext) + blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) } + }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt index 5aa90130..747be76c 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt @@ -17,6 +17,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.mock 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.services.execution.AbstractComponentFunction import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor.ComponentExecuteNodeExecutor import org.slf4j.LoggerFactory @@ -38,6 +39,8 @@ class MockComponentFunction : AbstractComponentFunction() { override fun process(executionRequest: ExecutionServiceInput) { log.info("Processing component..") + + this.executionServiceOutput = ExecutionServiceOutput() } override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json new file mode 100644 index 00000000..20401fd1 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/execution-input/default-input.json @@ -0,0 +1,20 @@ +{ + "commonHeader" : { + "originatorId" : "System", + "requestId" : "1234", + "subRequestId" : "1234-12234" + }, + "actionIdentifiers" : { + "blueprintName" : "baseconfiguration", + "blueprintVersion" : "1.0.0", + "actionName" : "activate", + "mode" : "sync" + }, + "payload" : { }, + "metadata" : { + "current-node-template" : "resource-assignment-py", + "current-step" : "resource-assignment-py", + "current-operation" : "process", + "current-interface" : "ResourceAssignmentComponent" + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index 761fdc72..ba8e9211 100644 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -33,11 +33,13 @@ <spring.boot.version>2.0.6.RELEASE</spring.boot.version> <spring.version>5.0.10.RELEASE</spring.version> <kotlin.version>1.3.10</kotlin.version> - <kotlin.maven.version>1.3.0</kotlin.maven.version> + <kotlin.maven.version>1.3.10</kotlin.maven.version> <kotlin.couroutines.version>1.0.1</kotlin.couroutines.version> + <grpc.version>1.16.1</grpc.version> <eelf.version>1.0.0</eelf.version> <sli.version>0.3.1</sli.version> <guava.version>26.0-jre</guava.version> + <jython.version>2.7.1</jython.version> <springfox.swagger2.version>2.9.2</springfox.swagger2.version> <h2database.version>1.4.197</h2database.version> <onap.logger.slf4j>1.2.2</onap.logger.slf4j> @@ -73,8 +75,8 @@ <version>${kotlin.version}</version> </dependency> <dependency> - <groupId>org.jetbrains.kotlin</groupId> - <artifactId>kotlinx-couroutines-core</artifactId> + <groupId>org.jetbrains.kotlinx</groupId> + <artifactId>kotlinx-coroutines-core</artifactId> <version>${kotlin.couroutines.version}</version> </dependency> <dependency> @@ -93,6 +95,23 @@ <version>${kotlin.version}</version> </dependency> + <!-- GRPC Dependencies --> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-netty</artifactId> + <version>${grpc.version}</version> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-protobuf</artifactId> + <version>${grpc.version}</version> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-stub</artifactId> + <version>${grpc.version}</version> + </dependency> + <!-- SLI Version --> <dependency> <groupId>org.onap.ccsdk.sli.core</groupId> @@ -228,6 +247,11 @@ <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> + <dependency> + <groupId>org.python</groupId> + <artifactId>jython-standalone</artifactId> + <version>${jython.version}</version> + </dependency> <!-- Database --> <dependency> @@ -297,6 +321,19 @@ <groupId>com.fasterxml.jackson.module</groupId> <artifactId>jackson-module-kotlin</artifactId> </dependency> + <!-- GRPC Dependencies --> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-netty</artifactId> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-protobuf</artifactId> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-stub</artifactId> + </dependency> </dependencies> <build> diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java index 81f7d701..77de8e7c 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/SwaggerGenerator.java @@ -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.
@@ -40,6 +41,7 @@ import java.util.*; public class SwaggerGenerator {
private ServiceTemplate serviceTemplate;
+ public static final String INPUTS="inputs";
/**
* This is a SwaggerGenerator constructor
@@ -54,8 +56,7 @@ public class SwaggerGenerator { * @return String
*/
public String generateSwagger() {
- String swaggerContent = null;
-
+
Swagger swagger = new Swagger().info(getInfo());
swagger.setPaths(getPaths());
@@ -86,7 +87,7 @@ public class SwaggerGenerator { List<Parameter> parameters = new ArrayList<>();
Parameter in = new BodyParameter().schema(new RefModel("#/definitions/inputs"));
in.setRequired(true);
- in.setName("inputs");
+ in.setName(INPUTS);
parameters.add(in);
post.setParameters(parameters);
@@ -107,18 +108,17 @@ public class SwaggerGenerator { Map<String, Model> models = new HashMap<>();
ModelImpl inputmodel = new ModelImpl();
- inputmodel.setTitle("inputs");
+ inputmodel.setTitle(INPUTS);
serviceTemplate.getTopologyTemplate().getInputs().forEach((propertyName, property) -> {
Property defProperty = getPropery(propertyName, property);
inputmodel.property(propertyName, defProperty);
});
- models.put("inputs", inputmodel);
+ models.put(INPUTS, inputmodel);
if (MapUtils.isNotEmpty(serviceTemplate.getDataTypes())) {
serviceTemplate.getDataTypes().forEach((name, dataType) -> {
ModelImpl model = new ModelImpl();
model.setDescription(dataType.getDescription());
- // model.setType("object");
if (dataType != null && MapUtils.isNotEmpty(dataType.getProperties())) {
dataType.getProperties().forEach((propertyName, property) -> {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java index d8fea60e..33c7ae42 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ModelType.java @@ -84,7 +84,7 @@ public class ModelType implements Serializable { @Override
public String toString() {
- String buffer = "[" + ", modelName = " + modelName +
+ return "[" + ", modelName = " + modelName +
", derivedFrom = " + derivedFrom +
", definitionType = " + definitionType +
", description = " + description +
@@ -93,7 +93,6 @@ public class ModelType implements Serializable { ", updatedBy = " + updatedBy +
", tags = " + tags +
"]";
- return buffer;
}
public String getModelName() {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java index 42c8e83b..5352d9c9 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ResourceDictionary.java @@ -78,7 +78,7 @@ public class ResourceDictionary implements Serializable { @Override
public String toString() {
- String buffer = "[" + ", name = " + name +
+ return "[" + ", name = " + name +
", dataType = " + dataType +
", entrySchema = " + entrySchema +
", definition =" + definition +
@@ -87,7 +87,6 @@ public class ResourceDictionary implements Serializable { ", tags = " + tags +
", creationDate = " + creationDate +
"]";
- return buffer;
}
public String getName() {
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java index 287d413c..9b2209e8 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ResourceDictionaryRest.java @@ -47,13 +47,12 @@ public class ResourceDictionaryRest { @PostMapping(path = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary)
- throws BluePrintException {
+ ResourceDictionary saveResourceDictionary(@RequestBody ResourceDictionary dataDictionary) {
return resourceDictionaryService.saveResourceDictionary(dataDictionary);
}
@DeleteMapping(path = "/{name}")
- public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) throws BluePrintException {
+ public void deleteResourceDictionaryByName(@PathVariable(value = "name") String name) {
resourceDictionaryService.deleteResourceDictionary(name);
}
@@ -65,14 +64,13 @@ public class ResourceDictionaryRest { @PostMapping(path = "/by-names", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names)
- throws BluePrintException {
+ List<ResourceDictionary> searchResourceDictionaryByNames(@RequestBody List<String> names) {
return resourceDictionaryService.searchResourceDictionaryByNames(names);
}
@GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) throws BluePrintException {
+ List<ResourceDictionary> searchResourceDictionaryByTags(@PathVariable(value = "tags") String tags) {
return resourceDictionaryService.searchResourceDictionaryByTags(tags);
}
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json index 782ed505..b066dad6 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhance-template.json @@ -64,7 +64,7 @@ }
},
"interfaces": {
- "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode": {
+ "NetconfExecutorComponent": {
"operations": {
"process": {
"inputs": {
@@ -114,7 +114,7 @@ "component-node": {}
},
"interfaces": {
- "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode": {
+ "ResourceAssignmentComponent": {
"operations": {
"process": {
"inputs": {
diff --git a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json index d49ab8fe..5e41a507 100644 --- a/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json +++ b/ms/controllerblueprints/modules/service/src/test/resources/enhance/enhanced-template.json @@ -336,7 +336,7 @@ } }, "interfaces" : { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode" : { + "ResourceAssignmentComponent" : { "operations" : { "process" : { "inputs" : { @@ -395,6 +395,11 @@ }, "derived_from" : "tosca.nodes.Component" }, + "tosca.nodes.component.Jython" : { + "description" : "This is Jython Component", + "version" : "1.0.0", + "derived_from" : "tosca.nodes.Root" + }, "tosca.nodes.DG" : { "description" : "This is Directed Graph Node Type", "version" : "1.0.0", @@ -548,7 +553,7 @@ } }, "interfaces" : { - "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode" : { + "NetconfExecutorComponent" : { "operations" : { "process" : { "inputs" : { @@ -609,7 +614,7 @@ } } }, - "derived_from" : "tosca.nodes.Component" + "derived_from" : "tosca.nodes.component.Jython" } }, "topology_template" : { @@ -671,7 +676,7 @@ } }, "interfaces" : { - "org-openecomp-sdnc-netconf-adaptor-service-NetconfExecutorNode" : { + "NetconfExecutorComponent" : { "operations" : { "process" : { "implementation" : { @@ -715,7 +720,7 @@ "component-node" : { } }, "interfaces" : { - "org-onap-ccsdk-config-assignment-service-ConfigAssignmentNode" : { + "ResourceAssignmentComponent" : { "operations" : { "process" : { "inputs" : { diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index e69a947b..4f6a316b 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -31,7 +31,7 @@ <spring.boot.version>2.0.6.RELEASE</spring.boot.version> <spring.version>5.0.10.RELEASE</spring.version> <kotlin.version>1.3.10</kotlin.version> - <kotlin.maven.version>1.3.0</kotlin.maven.version> + <kotlin.maven.version>1.3.10</kotlin.maven.version> <kotlin.couroutines.version>1.0.1</kotlin.couroutines.version> <eelf.version>1.0.0</eelf.version> <guava.version>26.0-jre</guava.version> diff --git a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java index 2378584e..f312cc36 100644 --- a/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java +++ b/ms/vlantag-api/src/main/java/org/onap/ccsdk/apps/ms/vlantagapi/extinf/pm/PolicyManagerClient.java @@ -93,6 +93,7 @@ public class PolicyManagerClient { result = response.getBody();
} catch (RestClientException rce) {
+ log.error(rce.getMessage());
throw new VlantagApiException(rce.getLocalizedMessage());
}
return result;
@@ -118,6 +119,7 @@ public class PolicyManagerClient { requestObject.setPolicyName(policyName);
retVal = extractResourceModelsFromResponse(getConfigUsingPost(requestObject));
} catch (IOException e) {
+ log.error(e.getMessage());
throw new VlantagApiException(e);
}
return retVal;
|