diff options
Diffstat (limited to 'ms')
100 files changed, 2825 insertions, 1085 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/pom.xml b/ms/blueprintsprocessor/application/pom.xml index 0fe62e9e..086a9883 100644 --- a/ms/blueprintsprocessor/application/pom.xml +++ b/ms/blueprintsprocessor/application/pom.xml @@ -40,6 +40,7 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> + <!-- North Bound --> <dependency> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>resource-api</artifactId> diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java index 2a13f929..241d920a 100644 --- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java +++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/BlueprintProcessorApplication.java @@ -19,6 +19,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.reactive.config.EnableWebFlux;
@@ -28,7 +29,7 @@ import org.springframework.web.reactive.config.EnableWebFlux; * @author Brinda Santh 8/14/2018
*/
@SpringBootApplication
-@EnableAutoConfiguration
+@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
@EnableWebFlux
@ComponentScan(basePackages = {"org.onap.ccsdk.apps.controllerblueprints",
"org.onap.ccsdk.apps.blueprintsprocessor"})
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/application/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml new file mode 100644 index 00000000..a816a06c --- /dev/null +++ b/ms/blueprintsprocessor/application/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/pom.xml b/ms/blueprintsprocessor/functions/pom.xml new file mode 100644 index 00000000..efd550dd --- /dev/null +++ b/ms/blueprintsprocessor/functions/pom.xml @@ -0,0 +1,64 @@ +<?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> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> + <artifactId>parent</artifactId> + <version>0.4.0-SNAPSHOT</version> + <relativePath>../parent</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + <packaging>pom</packaging> + <artifactId>functions</artifactId> + <name>Blueprints Processor Functions POM</name> + <description>Blueprints Processor Functions POM</description> + <modules> + <module>resource-resolution</module> + <module>python-executor</module> + </modules> + + <dependencies> + <dependency> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> + <artifactId>execution-service</artifactId> + </dependency> + <!-- Test Dependencies --> + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-test-junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.projectreactor</groupId> + <artifactId>reactor-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> +</project>
\ No newline at end of file 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/modules/services/resolution-service/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml index 21464c14..858be70c 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/pom.xml +++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml @@ -19,18 +19,13 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>services</artifactId> + <artifactId>functions</artifactId> <version>0.4.0-SNAPSHOT</version> </parent> - <artifactId>resolution-service</artifactId> + <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> - <dependencies> - <dependency> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>db-service</artifactId> - </dependency> - </dependencies> </project> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt new file mode 100644 index 00000000..a485fa62 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt @@ -0,0 +1,32 @@ +/*
+ * 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.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.springframework.stereotype.Component
+
+@Component("component-resource-resolution")
+open class ResourceResolutionComponent : AbstractComponentFunction() {
+ override fun process(executionRequest: ExecutionServiceInput) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt new file mode 100644 index 00000000..e234d056 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionConstants.kt @@ -0,0 +1,25 @@ +/* + * 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.resolution + +class ResourceResolutionConstants { + companion object { + const val PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR = "resource-assignment-processor-" + + } + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/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 d442c96b..9e735cf0 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/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 @@ -17,14 +17,15 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.BlueprintProcessorException
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status
-import org.onap.ccsdk.apps.controllerblueprints.core.format
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.context.ApplicationContext
import org.springframework.stereotype.Service
/**
@@ -34,7 +35,11 @@ import org.springframework.stereotype.Service */
@Service
-class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {
+class ResourceResolutionService {
+
+
+ @Autowired
+ private lateinit var applicationContext: ApplicationContext
fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
val resourceResolutionOutput = ResourceResolutionOutput()
@@ -42,9 +47,7 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory: resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
- val context = hashMapOf<String, Any>()
-
- process(resourceResolutionOutput.resourceAssignments, context)
+ process(resourceResolutionOutput.resourceAssignments)
val status = Status()
status.code = 200
@@ -54,27 +57,33 @@ class ResourceResolutionService(private val resourceAssignmentProcessorFactory: return resourceResolutionOutput
}
- fun process(resourceAssignments: MutableList<ResourceAssignment>, context: MutableMap<String, Any>): Unit {
+ fun registeredResourceSources(): List<String> {
+ return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR) }
+ }
+
+ fun process(resourceAssignments: MutableList<ResourceAssignment>) {
val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
bulkSequenced.map { batchResourceAssignments ->
- batchResourceAssignments.filter { it.name != "*" && it.name != "start"}
- .map { resourceAssignment ->
- val dictionarySource = resourceAssignment.dictionarySource
- val processorInstanceName = "resource-assignment-processor-".plus(dictionarySource)
- val resourceAssignmentProcessor = resourceAssignmentProcessorFactory.getInstance(processorInstanceName)
- ?: throw BlueprintProcessorException(format("failed to get resource processor for instance name({}) " +
- "for resource assignment({})", processorInstanceName, resourceAssignment.name))
- try {
- resourceAssignmentProcessor.validate(resourceAssignment, context)
- resourceAssignmentProcessor.process(resourceAssignment, context)
- } catch (e: Exception) {
- resourceAssignmentProcessor.errorHandle(resourceAssignment, context)
- throw BlueprintProcessorException(e)
- }
+ batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
+ .map { resourceAssignment ->
+ val dictionarySource = resourceAssignment.dictionarySource
+ val processorInstanceName = ResourceResolutionConstants.PREFIX_RESOURCE_ASSIGNMENT_PROCESSOR.plus(dictionarySource)
- }
+ val resourceAssignmentProcessor = applicationContext.getBean(processorInstanceName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for instance name($processorInstanceName) " +
+ "for resource assignment(${resourceAssignment.name})")
+ try {
+ // Invoke Apply Method
+ resourceAssignmentProcessor.apply(resourceAssignment)
+ } catch (e: RuntimeException) {
+ resourceAssignmentProcessor.recover(e, resourceAssignment)
+ throw BluePrintProcessorException(e)
+ }
+ }
}
}
}
diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt index 4b11f580..66e43f1b 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DataBaseResourceAssignmentProcessor.kt @@ -1,5 +1,6 @@ /* * Copyright © 2018 IBM. + * Modifications 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. @@ -16,35 +17,21 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor -import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor import org.springframework.stereotype.Service /** - * SdncResourceAssignmentProcessor + * DataBaseResourceAssignmentProcessor * * @author Brinda Santh */ @Service("resource-assignment-processor-db") -open class SdncResourceAssignmentProcessor : ResourceAssignmentProcessor { +open class DataBaseResourceAssignmentProcessor : ResourceAssignmentProcessor(){ - private val log = EELFManager.getInstance().getLogger(SdncResourceAssignmentProcessor::class.java) - - override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { - log.info("Validation Resource Assignments") - } - - override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { - log.info("Processing Resource Assignments") + override fun process(executionRequest: ResourceAssignment) { } - override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { - log.info("ErrorHandle Resource Assignments") + override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { } - - override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { - log.info("Re Trigger Resource Assignments") - } - }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt index 9580ca49..e701e718 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt @@ -17,7 +17,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
-import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
@@ -28,22 +27,11 @@ import org.springframework.stereotype.Service * @author Brinda Santh
*/
@Service("resource-assignment-processor-default")
-open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor {
- private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java)
+open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor() {
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Validation Resource Assignments")
+ override fun process(executionRequest: ResourceAssignment) {
}
- override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Processing Resource Assignments")
- }
-
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("ErrorHandle Resource Assignments")
- }
-
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Re Trigger Resource Assignments")
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
}
}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt index 05f7d5cd..9e177d46 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt @@ -17,7 +17,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor
-import com.att.eelf.configuration.EELFManager
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.stereotype.Service
@@ -28,22 +27,11 @@ import org.springframework.stereotype.Service * @author Brinda Santh
*/
@Service("resource-assignment-processor-input")
-open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor {
- private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java)
+open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor() {
- override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Validation Resource Assignments")
+ override fun process(executionRequest: ResourceAssignment) {
}
- override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Processing Resource Assignments")
- }
-
- override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("ErrorHandle Resource Assignments")
- }
-
- override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
- log.info("Re Trigger Resource Assignments")
+ override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) {
}
}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt index 9d54cd46..e1b9a8ef 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SimpleRestResourceAssignmentProcessor.kt @@ -1,5 +1,6 @@ /* * Copyright © 2018 IBM. + * Modifications 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. @@ -16,33 +17,21 @@ package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor -import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor import org.springframework.stereotype.Service /** - * MDSALResourceAssignmentProcessor + * SimpleRestResourceAssignmentProcessor * * @author Brinda Santh */ @Service("resource-assignment-processor-mdsal") -open class MDSALResourceAssignmentProcessor : ResourceAssignmentProcessor { - private val log = EELFManager.getInstance().getLogger(MDSALResourceAssignmentProcessor::class.java) +open class SimpleRestResourceAssignmentProcessor : ResourceAssignmentProcessor() { - override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { - log.info("Validation Resource Assignments") + override fun process(executionRequest: ResourceAssignment) { } - override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { - log.info("Processing Resource Assignments") - } - - override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { - log.info("ErrorHandle Resource Assignments") - } - - override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) { - log.info("Re Trigger Resource Assignments") + override fun recover(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt new file mode 100644 index 00000000..a7d573c6 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.kt @@ -0,0 +1,95 @@ +/* + * 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.resolution + +import com.fasterxml.jackson.databind.node.ObjectNode +import org.apache.commons.collections.CollectionUtils +import org.apache.commons.io.FileUtils +import org.junit.Assert +import org.junit.Test +import org.junit.runner.RunWith +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput +import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory +import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DataBaseResourceAssignmentProcessor +import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor +import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor +import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SimpleRestResourceAssignmentProcessor +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.junit4.SpringRunner +import java.io.File +import java.nio.charset.Charset +import kotlin.test.assertNotNull +import kotlin.test.assertTrue + +/** + * ResourceResolutionServiceTest + * + * @author Brinda Santh DATE : 8/15/2018 + */ +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [ResourceResolutionService::class, ResourceAssignmentProcessorFactory::class, + InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class, + DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class]) +class ResourceResolutionServiceTest { + + private val log = LoggerFactory.getLogger(ResourceResolutionServiceTest::class.java) + + @Autowired + lateinit var resourceResolutionService: ResourceResolutionService + + + @Test + fun testRegisteredSource() { + val sources = resourceResolutionService.registeredResourceSources() + assertNotNull(sources, "failed to get registered sources") + assertTrue(sources.containsAll(arrayListOf("input", "default", "db", "mdsal")), "failed to get registered sources") + } + + @Test + @Throws(Exception::class) + fun testResolveResource() { + + Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService) + + val resourceResolutionInputContent = FileUtils.readFileToString( + File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset()) + + val resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput::class.java) + Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput) + + val resourceAssignmentContent = FileUtils.readFileToString( + File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset()) + val batchResourceAssignment = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java) + + Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment)) + resourceResolutionInput!!.resourceAssignments = batchResourceAssignment as MutableList<ResourceAssignment> + + val inputContent = JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json") as ObjectNode + Assert.assertNotNull("failed to populate input payload ", inputContent) + resourceResolutionInput.payload = inputContent + log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true)) + + val resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput) + Assert.assertNotNull("failed to populate output", resourceResolutionOutput) + + } + +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml new file mode 100644 index 00000000..a816a06c --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/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/modules/services/resolution-service/src/test/resources/mapping/db/db-array.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json index 679b92db..679b92db 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/db-array.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-array.json diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/db-complex.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json index 32d04b69..32d04b69 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/db-complex.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-complex.json diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/db-simple.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json index 841404f2..841404f2 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/db-simple.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/db-simple.json diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/dt-location.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json index 52e0a796..52e0a796 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/dt-location.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/dt-location.json diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json index ddcf32ee..ddcf32ee 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/mapping/db/resource-assignments-simple.json diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/payload/inputs/input.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json index cd6fac12..cd6fac12 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/payload/inputs/input.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/payload/requests/sample-resourceresolution-request.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json index e8830a8a..e8830a8a 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/payload/requests/sample-resourceresolution-request.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json diff --git a/ms/blueprintsprocessor/modules/commons/adaptors/pom.xml b/ms/blueprintsprocessor/modules/commons/adaptors/pom.xml deleted file mode 100644 index 410111b4..00000000 --- a/ms/blueprintsprocessor/modules/commons/adaptors/pom.xml +++ /dev/null @@ -1,34 +0,0 @@ -<?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"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>commons</artifactId> - <version>0.4.0-SNAPSHOT</version> - </parent> - - <artifactId>adaptors</artifactId> - <packaging>pom</packaging> - <name>Blueprints Processor Adaptors POM</name> - <description>Blueprints Processor Adaptors</description> - <modules> - - </modules> - -</project> diff --git a/ms/blueprintsprocessor/modules/commons/core/pom.xml b/ms/blueprintsprocessor/modules/commons/core/pom.xml index 094f42b7..626a27a3 100644 --- a/ms/blueprintsprocessor/modules/commons/core/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/core/pom.xml @@ -17,27 +17,27 @@ ~ 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>commons</artifactId> - <version>0.4.0-SNAPSHOT</version> - </parent> + 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>commons</artifactId> + <version>0.4.0-SNAPSHOT</version> + </parent> - <artifactId>core</artifactId> - <packaging>jar</packaging> - <name>Blueprints Processor Core</name> - <description>Blueprints Processor Core</description> + <artifactId>core</artifactId> + <packaging>jar</packaging> + <name>Blueprints Processor Core</name> + <description>Blueprints Processor Core</description> - <dependencies> - <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> - </dependencies> + <dependencies> + <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> + </dependencies> </project> 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 6fed53e6..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 @@ -18,9 +18,11 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.api.data
import com.fasterxml.jackson.annotation.JsonFormat
+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
@@ -29,69 +31,71 @@ import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment */
open class ResourceResolutionInput {
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var resourceAssignments: MutableList<ResourceAssignment>
- @get:ApiModelProperty(required=true )
+ @get:ApiModelProperty(required = true)
lateinit var payload: ObjectNode
}
open class ResourceResolutionOutput {
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var status: Status
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var resourceAssignments: MutableList<ResourceAssignment>
}
open class ExecutionServiceInput {
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var payload: ObjectNode
+ var metadata: MutableMap<String, JsonNode> = hashMapOf()
}
open class ExecutionServiceOutput {
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var commonHeader: CommonHeader
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var actionIdentifiers: ActionIdentifiers
- @get:ApiModelProperty(required=true)
- lateinit var status: Status
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
+ var status: Status = Status()
+ @get:ApiModelProperty(required = true)
lateinit var payload: ObjectNode
+ var metadata: MutableMap<String, JsonNode> = hashMapOf()
}
open class ActionIdentifiers {
- @get:ApiModelProperty(required=false)
+ @get:ApiModelProperty(required = false)
lateinit var blueprintName: String
- @get:ApiModelProperty(required=false)
+ @get:ApiModelProperty(required = false)
lateinit var blueprintVersion: String
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var actionName: String
- @get:ApiModelProperty(required=true, allowableValues = "sync, async")
+ @get:ApiModelProperty(required = true, allowableValues = "sync, async")
lateinit var mode: String
}
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
- @get:ApiModelProperty(required=true)
+ @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'")
+ var timestamp: Date = Date()
+ @get:ApiModelProperty(required = true)
lateinit var originatorId: String
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var requestId: String
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
lateinit var subRequestId: String
- @get:ApiModelProperty(required=false)
+ @get:ApiModelProperty(required = false)
var flags: Flags? = null
}
@@ -102,12 +106,12 @@ open class Flags { }
open class Status {
- @get:ApiModelProperty(required=true)
+ @get:ApiModelProperty(required = true)
var code: Int = 200
- @get:ApiModelProperty(required=false)
+ @get:ApiModelProperty(required = false)
var errorMessage: String? = null
- @get:ApiModelProperty(required=true)
- lateinit var message: String
+ @get:ApiModelProperty(required = true)
+ var message: String = "success"
}
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorException.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorException.kt deleted file mode 100644 index df4d6703..00000000 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/api/data/BlueprintProcessorException.kt +++ /dev/null @@ -1,48 +0,0 @@ -/*
- * 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.core.api.data
-
-/**
- * BlueprintProcessorException
- * @author Brinda Santh
- * DATE : 8/15/2018
- */
-open class BlueprintProcessorException : Exception {
- var code: Int = 100
-
- constructor(cause: Throwable) : super(cause)
- constructor(message: String) : super(message)
- constructor(message: String, cause: Throwable) : super(message, cause)
- constructor(cause: Throwable, message: String, vararg args: Any?) : super(String.format(message, *args), cause)
-
- constructor(code: Int, cause: Throwable) : super(cause) {
- this.code = code
- }
-
- constructor(code: Int, message: String) : super(message) {
- this.code = code
- }
-
- constructor(code: Int, message: String, cause: Throwable) : super(message, cause) {
- this.code = code
- }
-
- constructor(code: Int, cause: Throwable, message: String, vararg args: Any?)
- : super(String.format(message, *args), cause) {
- this.code = code
- }
-}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt index feacbcab..66643ee0 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ComponentNodeFactory.kt @@ -21,7 +21,6 @@ import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
-import org.springframework.stereotype.Service
/**
* ComponentNode
@@ -48,7 +47,6 @@ interface ComponentNode { *
* @author Brinda Santh
*/
-@Service
open class ComponentNodeFactory : ApplicationContextAware {
private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java)
diff --git a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt index 01a110d5..80ad0e67 100644 --- a/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt +++ b/ms/blueprintsprocessor/modules/commons/core/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/core/factory/ResourceAssignmentProcessorFactory.kt @@ -21,14 +21,14 @@ import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationContextAware
-import org.springframework.stereotype.Service
+import org.springframework.context.annotation.Configuration
/**
* ResourceAssignmentProcessorFactory
*
* @author Brinda Santh
*/
-@Service
+@Configuration
open class ResourceAssignmentProcessorFactory : ApplicationContextAware {
private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java)
diff --git a/ms/blueprintsprocessor/modules/commons/pom.xml b/ms/blueprintsprocessor/modules/commons/pom.xml index 299a87d6..7bfec58c 100644 --- a/ms/blueprintsprocessor/modules/commons/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/pom.xml @@ -31,21 +31,12 @@ <modules> <module>db-lib</module> <module>rest-lib</module> - <module>adaptors</module> <module>core</module> </modules> <dependencies> <dependency> - <groupId>com.fasterxml.jackson.module</groupId> - <artifactId>jackson-module-kotlin</artifactId> - </dependency> - <dependency> - <groupId>org.jetbrains.kotlin</groupId> - <artifactId>kotlin-stdlib-jdk8</artifactId> - </dependency> - <dependency> - <groupId>org.jetbrains.kotlin</groupId> - <artifactId>kotlin-reflect</artifactId> + <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> + <artifactId>resource-dict</artifactId> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml index f03e5557..e26af0f0 100644 --- a/ms/blueprintsprocessor/modules/inbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml @@ -33,16 +33,13 @@ <module>selfservice-api</module> </modules> <dependencies> - - - <dependency> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>execution-service</artifactId> + <artifactId>workflow-service</artifactId> </dependency> <dependency> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>resolution-service</artifactId> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> + <artifactId>resource-resolution</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.java b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.java index 75407c52..3b5dfabe 100644 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.java +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/src/main/java/org/onap/ccsdk/apps/blueprintsprocessor/selfservice/api/ExecutionServiceController.java @@ -19,7 +19,6 @@ package org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api; import io.swagger.annotations.ApiOperation;
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.ExecutionService;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Mono;
@@ -33,11 +32,6 @@ import reactor.core.publisher.Mono; @RequestMapping("/api/v1/execution-service")
public class ExecutionServiceController {
- private ExecutionService executionService;
-
- public ExecutionServiceController(ExecutionService executionService) {
- this.executionService = executionService;
- }
@RequestMapping(path = "/ping", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
@@ -50,6 +44,6 @@ public class ExecutionServiceController { notes = "Takes the blueprint information and process as per the payload")
public @ResponseBody
Mono<ExecutionServiceOutput> process(@RequestBody ExecutionServiceInput executionServiceInput) {
- return Mono.just(executionService.process(executionServiceInput));
+ return Mono.just(new ExecutionServiceOutput());
}
}
diff --git a/ms/blueprintsprocessor/modules/pom.xml b/ms/blueprintsprocessor/modules/pom.xml index 93f312b8..0230cd7e 100644 --- a/ms/blueprintsprocessor/modules/pom.xml +++ b/ms/blueprintsprocessor/modules/pom.xml @@ -17,56 +17,32 @@ ~ 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>parent</artifactId> - <version>0.4.0-SNAPSHOT</version> - <relativePath>../parent</relativePath> - </parent> + 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>parent</artifactId> + <version>0.4.0-SNAPSHOT</version> + <relativePath>../parent</relativePath> + </parent> - <artifactId>modules</artifactId> - <packaging>pom</packaging> - <name>Blueprints Processor Modules POM</name> - <description>Blueprints Processor Modules</description> - - <modules> - <module>commons</module> - <module>outbounds</module> - <module>services</module> - <module>inbounds</module> - </modules> - - <dependencies> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito2</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.jetbrains.kotlin</groupId> - <artifactId>kotlin-test-junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>io.projectreactor</groupId> - <artifactId>reactor-test</artifactId> - <scope>test</scope> - </dependency> - </dependencies> + <artifactId>modules</artifactId> + <packaging>pom</packaging> + <name>Blueprints Processor Modules POM</name> + <description>Blueprints Processor Modules</description> + <modules> + <module>commons</module> + <module>outbounds</module> + <module>services</module> + <module>inbounds</module> + </modules> <build> <plugins> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> - <version>${kotlin.version}</version> + <version>${kotlin.maven.version}</version> <executions> <execution> <id>compile</id> diff --git a/ms/blueprintsprocessor/modules/services/db-service/pom.xml b/ms/blueprintsprocessor/modules/services/db-service/pom.xml deleted file mode 100644 index 4ff4d8c0..00000000 --- a/ms/blueprintsprocessor/modules/services/db-service/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?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"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>services</artifactId> - <version>0.4.0-SNAPSHOT</version> - </parent> - - <artifactId>db-service</artifactId> - <packaging>jar</packaging> - <name>Blueprints Processor DB Service</name> - <description>Blueprints Processor DB Service</description> - - <dependencies> - </dependencies> -</project> diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml index 158496df..4f0e6c0b 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml +++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml @@ -31,7 +31,37 @@ <dependencies> <dependency> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>db-service</artifactId> + <artifactId>core</artifactId> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> + <artifactId>resource-dict</artifactId> + </dependency> + + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>sli-provider</artifactId> + </dependency> + + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-test-junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.projectreactor</groupId> + <artifactId>reactor-test</artifactId> + <scope>test</scope> </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 new file mode 100644 index 00000000..dfdf6259 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/AbstractComponentFunction.kt @@ -0,0 +1,75 @@ +/*
+ * 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.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
+
+/**
+ * AbstractComponentFunction
+ * @author Brinda Santh
+ */
+abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {
+ private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)
+
+ 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 executionServiceInput
+ }
+
+ override fun prepareResponse(): ExecutionServiceOutput {
+ log.info("Preparing Response...")
+ return this.executionServiceOutput
+ }
+
+ override fun apply(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+ prepareRequest(executionServiceInput)
+ process(executionServiceInput)
+ return prepareResponse()
+ }
+}
\ 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/ExecutionService.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionService.kt deleted file mode 100644 index 75b26bb5..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionService.kt +++ /dev/null @@ -1,46 +0,0 @@ -/*
- * 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.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.blueprintsprocessor.core.api.data.Status
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.springframework.stereotype.Service
-import com.fasterxml.jackson.databind.node.ObjectNode
-
-/**
- * ExecutionService
- * @author Brinda Santh
- * 8/14/2018
- */
-@Service
-class ExecutionService {
-
- fun process(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
- val executionServiceOutput = ExecutionServiceOutput()
- executionServiceOutput.actionIdentifiers = executionServiceInput.actionIdentifiers
- executionServiceOutput.commonHeader = executionServiceInput.commonHeader
- executionServiceOutput.payload = JacksonUtils.jsonNode("{}") as ObjectNode
- val status = Status()
- status.code = 200
- status.message = "Success"
- executionServiceOutput.status = status
- return executionServiceOutput
- }
-}
\ 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/JavaScriptExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt deleted file mode 100644 index 427dc873..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt +++ /dev/null @@ -1,45 +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.core.factory.ComponentNode -import org.springframework.stereotype.Component - -/** - * JavaScriptExecuteComponent - * - * @author Brinda Santh - */ -@Component("component-javascript-executor") -class JavaScriptExecuteComponent : ComponentNode { - - override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } -}
\ 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/PythonExecuteComponent.kt b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt deleted file mode 100644 index 59be1f51..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt +++ /dev/null @@ -1,44 +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.core.factory.ComponentNode -import org.springframework.stereotype.Component - -/** - * PythonExecuteComponent - * - * @author Brinda Santh - */ -@Component("component-python-executor") -class PythonExecuteComponent : ComponentNode { - override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } - - override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. - } -}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionServiceTest.java b/ms/blueprintsprocessor/modules/services/execution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionServiceTest.java deleted file mode 100644 index 0df95d2d..00000000 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/ExecutionServiceTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/*
- * 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.execution;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.commons.io.FileUtils;
-import org.junit.Assert;
-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.core.api.data.ExecutionServiceOutput;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.io.File;
-import java.nio.charset.Charset;
-
-
-/**
- * ExecutionServiceTest
- *
- * @author Brinda Santh
- * DATE : 8/15/2018
- */
-@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = ExecutionService.class)
-public class ExecutionServiceTest {
- private static Logger log = LoggerFactory.getLogger(ExecutionServiceTest.class);
-
- @Autowired
- private ExecutionService executionService;
-
- @Test
- public void testExecutionService() throws Exception {
-
- Assert.assertNotNull("failed to create ResourceResolutionService", executionService);
-
- String resourceResolutionInputContent = FileUtils.readFileToString(
- new File("src/test/resources/payload/requests/sample-execution-request.json"), Charset.defaultCharset());
-
- ExecutionServiceInput executionServiceInput = JacksonUtils.readValue(resourceResolutionInputContent, ExecutionServiceInput.class );
- Assert.assertNotNull("failed to populate executionServiceInput request ",executionServiceInput);
-
- ObjectNode inputContent = (ObjectNode)JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");
- Assert.assertNotNull("failed to populate input payload ",inputContent);
- executionServiceInput.setPayload(inputContent);
-
- ExecutionServiceOutput executionServiceOutput = executionService.process(executionServiceInput);
- Assert.assertNotNull("failed to populate output",executionServiceOutput);
-
- }
-}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/pom.xml b/ms/blueprintsprocessor/modules/services/pom.xml index eb3bda08..d2f2e0cb 100644 --- a/ms/blueprintsprocessor/modules/services/pom.xml +++ b/ms/blueprintsprocessor/modules/services/pom.xml @@ -29,15 +29,7 @@ <packaging>pom</packaging> <modules> - <module>db-service</module> - <module>resolution-service</module> <module>execution-service</module> + <module>workflow-service</module> </modules> - - <dependencies> - <dependency> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>core</artifactId> - </dependency> - </dependencies> </project> diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt deleted file mode 100644 index ff1a01d5..00000000 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt +++ /dev/null @@ -1,39 +0,0 @@ -/*
- * 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.resolution
-
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode
-import org.springframework.stereotype.Component
-
-@Component("component-resource-resolution")
-open class ResourceResolutionComponent : ComponentNode {
- override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-
- override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
- }
-}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java deleted file mode 100644 index 0768c609..00000000 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/java/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionServiceTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/*
- * 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.
- */
-
-package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.FileUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionInput;
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ResourceResolutionOutput;
-import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory;
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.DefaultResourceAssignmentProcessor;
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.InputResourceAssignmentProcessor;
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.MDSALResourceAssignmentProcessor;
-import org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.processor.SdncResourceAssignmentProcessor;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.io.File;
-import java.nio.charset.Charset;
-import java.util.List;
-
-/**
- * ResourceResolutionServiceTest
- *
- * @author Brinda Santh DATE : 8/15/2018
- */
-@RunWith(SpringRunner.class)
-@ContextConfiguration(classes = {ResourceResolutionService.class, ResourceAssignmentProcessorFactory.class,
- InputResourceAssignmentProcessor.class, DefaultResourceAssignmentProcessor.class,
- SdncResourceAssignmentProcessor.class, MDSALResourceAssignmentProcessor.class})
-public class ResourceResolutionServiceTest {
- private static Logger log = LoggerFactory.getLogger(ResourceResolutionServiceTest.class);
-
- @Autowired
- private ResourceResolutionService resourceResolutionService;
-
- @Test
- public void testResolveResource() throws Exception {
-
- Assert.assertNotNull("failed to create ResourceResolutionService", resourceResolutionService);
-
- String resourceResolutionInputContent = FileUtils.readFileToString(
- new File("src/test/resources/payload/requests/sample-resourceresolution-request.json"), Charset.defaultCharset());
-
- ResourceResolutionInput resourceResolutionInput = JacksonUtils.readValue(resourceResolutionInputContent, ResourceResolutionInput.class);
- Assert.assertNotNull("failed to populate resourceResolutionInput request ", resourceResolutionInput);
-
- String resourceAssignmentContent = FileUtils.readFileToString(
- new File("src/test/resources/mapping/db/resource-assignments-simple.json"), Charset.defaultCharset());
- List<ResourceAssignment> batchResourceAssignment =
- JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment.class);
-
- Assert.assertTrue("failed to create ResourceAssignment from file", CollectionUtils.isNotEmpty(batchResourceAssignment));
- resourceResolutionInput.setResourceAssignments(batchResourceAssignment);
-
- ObjectNode inputContent = (ObjectNode) JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");
- Assert.assertNotNull("failed to populate input payload ", inputContent);
- resourceResolutionInput.setPayload(inputContent);
- log.info("ResourceResolutionInput : {}", JacksonUtils.getJson(resourceResolutionInput, true));
-
- ResourceResolutionOutput resourceResolutionOutput = resourceResolutionService.resolveResource(resourceResolutionInput);
- Assert.assertNotNull("failed to populate output", resourceResolutionOutput);
-
- }
-}
diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml new file mode 100644 index 00000000..5caeac13 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/pom.xml @@ -0,0 +1,65 @@ +<?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> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> + <artifactId>services</artifactId> + <version>0.4.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>workflow-service</artifactId> + <name>Blueprints Processor Workflow Service</name> + <description>Blueprints Processor Workflow Service</description> + + <dependencies> + <dependency> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> + <artifactId>execution-service</artifactId> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.sli.core</groupId> + <artifactId>sli-provider</artifactId> + </dependency> + + <dependency> + <groupId>org.powermock</groupId> + <artifactId>powermock-api-mockito2</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-test-junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>io.projectreactor</groupId> + <artifactId>reactor-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + +</project>
\ 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/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/BlueprintSvcLogicContext.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.kt new file mode 100644 index 00000000..d2648c07 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicContext.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.services.workflow + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.sli.core.sli.SvcLogicContext + +class BlueprintSvcLogicContext : SvcLogicContext() { + + private var bluePrintRuntimeService: BluePrintRuntimeService<*>? = null + private var request: Any? = null + private var response: Any? = null + + fun getBluePrintService(): BluePrintRuntimeService<*> { + return this.bluePrintRuntimeService!! + } + + fun setBluePrintRuntimeService(bluePrintRuntimeService: BluePrintRuntimeService<*>) { + this.bluePrintRuntimeService = bluePrintRuntimeService + } + + fun setRequest(request: Any) { + this.request = request + } + + fun getRequest(): Any { + return this.request!! + } + + fun setResponse(response: Any) { + this.response = response + } + + fun getResponse(): Any { + return this.response!! + } + +}
\ 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 new file mode 100644 index 00000000..ab7d7385 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintSvcLogicService.kt @@ -0,0 +1,147 @@ +/* + * 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.controllerblueprints.core.service.BluePrintRuntimeService +import org.onap.ccsdk.sli.core.sli.* +import org.onap.ccsdk.sli.core.sli.provider.* +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker +import org.slf4j.LoggerFactory +import org.slf4j.MDC +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service +import java.util.* +import javax.annotation.PostConstruct + +interface BlueprintSvcLogicService : SvcLogicService { + + fun registerDefaultExecutors() + + fun registerExecutors(name: String, svcLogicNodeExecutor: SvcLogicNodeExecutor) + + fun unRegisterExecutors(name: String) + + 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 { + TODO("not implemented") + } + + @Deprecated("Not used in Micro service Implementation") + override fun hasGraph(module: String, rpc: String, version: String?, mode: String): Boolean { + TODO("not implemented") + } + + @Deprecated("Not used in Micro service Implementation") + override fun execute(p0: String?, p1: String?, p2: String?, p3: String?, p4: Properties?): Properties { + TODO("not implemented") + } + + @Deprecated("Not used in Micro service Implementation") + override fun execute(p0: String?, p1: String?, p2: String?, p3: String?, p4: Properties?, p5: DOMDataBroker?): Properties { + TODO("not implemented") + } +} + + +@Service +class DefaultBlueprintSvcLogicService : BlueprintSvcLogicService { + + private val log = LoggerFactory.getLogger(DefaultBlueprintSvcLogicService::class.java) + + private val nodeExecutors: MutableMap<String, SvcLogicNodeExecutor> = hashMapOf() + + @Autowired + private lateinit var context: ApplicationContext + + @PostConstruct + override fun registerDefaultExecutors() { + + val executeNodeExecutor = context.getBean(ExecuteNodeExecutor::class.java) + registerExecutors("execute", executeNodeExecutor) + registerExecutors("block", BlockNodeExecutor()) + registerExecutors("return", ReturnNodeExecutor()) + registerExecutors("break", BreakNodeExecutor()) + registerExecutors("exit", ExitNodeExecutor()) + } + + override fun registerExecutors(name: String, svcLogicNodeExecutor: SvcLogicNodeExecutor) { + log.info("Registering executors($name) with type(${svcLogicNodeExecutor.javaClass}") + nodeExecutors.put(name, svcLogicNodeExecutor) + } + + override fun unRegisterExecutors(name: String) { + if (nodeExecutors.containsKey(name)) { + log.info("UnRegistering executors($name)") + nodeExecutors.remove(name) + } + } + + 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 + return blueprintSvcLogicContext.getResponse() + } + + override fun executeNode(node: SvcLogicNode?, ctx: SvcLogicContext): SvcLogicNode? { + if (node == null) { + return null + } else { + if (log.isDebugEnabled()) { + log.debug("Executing node {}", node.getNodeId()) + } + + val executor = this.nodeExecutors[node.getNodeType()] + + if (executor != null) { + log.debug("Executing node executor for node type {} - {}", node.getNodeType(), executor.javaClass.name) + return executor.execute(this, node, ctx) + } else { + throw SvcLogicException("Attempted to execute a node of type " + node.getNodeType() + ", but no executor was registered for this type") + } + } + } + + override fun execute(graph: SvcLogicGraph, svcLogicContext: SvcLogicContext): SvcLogicContext { + MDC.put("currentGraph", graph.toString()) + + var curNode: SvcLogicNode? = graph.getRootNode() + log.info("About to execute graph {}", graph.toString()) + + try { + 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, svcLogicContext) + curNode = nextNode + } + } catch (var5: ExitNodeException) { + log.debug("SvcLogicServiceImpl caught ExitNodeException") + } + + MDC.remove("nodeId") + MDC.remove("currentGraph") + 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 new file mode 100644 index 00000000..b3186e84 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/WorkflowServiceConfiguration.kt @@ -0,0 +1,31 @@ +/* + * 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.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Configuration + +@Configuration +@ComponentScan +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 new file mode 100644 index 00000000..ace9f278 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/executor/ComponentExecuteNodeExecutor.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.services.workflow.executor + +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintSvcLogicContext +import org.onap.ccsdk.sli.core.sli.SvcLogicContext +import org.onap.ccsdk.sli.core.sli.SvcLogicException +import org.onap.ccsdk.sli.core.sli.SvcLogicNode +import org.onap.ccsdk.sli.core.sli.provider.ExecuteNodeExecutor +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicExpressionResolver +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.ApplicationContext +import org.springframework.stereotype.Service + +@Service +open class ComponentExecuteNodeExecutor : ExecuteNodeExecutor() { + + private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java) + + @Autowired + private lateinit var context: ApplicationContext + + fun getComponentFunction(pluginName: String): AbstractComponentFunction { + return context.getBean(pluginName, AbstractComponentFunction::class.java) + } + + @Throws(SvcLogicException::class) + override fun execute(svc: SvcLogicService, node: SvcLogicNode, svcLogicContext: SvcLogicContext): SvcLogicNode { + + var outValue: String + + val ctx = svcLogicContext as BlueprintSvcLogicContext + + val nodeTemplateName = SvcLogicExpressionResolver.evaluate(node.getAttribute("plugin"), node, ctx) + + try { + // Get the Blueprint Context + val blueprintContext = ctx.getBluePrintService().bluePrintContext() + // Get the Component Name, NodeTemplate type is mapped to Component Name + val componentName = blueprintContext.nodeTemplateByName(nodeTemplateName).type + + 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 + val executionOutput = plugin.apply(executionInput) + + ctx.setResponse(executionOutput) + + outValue = executionOutput.status.message + ctx.status = executionOutput.status.message + + } catch (e: Exception) { + this.log.error("Could not execute plugin($nodeTemplateName) : ", e) + outValue = "failure" + ctx.status = "failure" + } + + return this.getNextNode(node, outValue) + } +}
\ 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/utils/SvcGraphUtils.kt b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt new file mode 100644 index 00000000..ada36ac0 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/utils/SvcGraphUtils.kt @@ -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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.utils + +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph +import org.onap.ccsdk.sli.core.sli.SvcLogicParser + +object SvcGraphUtils { + + @JvmStatic + fun getSvcGraphFromClassPathFile(fileName: String): SvcLogicGraph { + val url = SvcGraphUtils::class.java.classLoader.getResource(fileName) + return getSvcGraphFromFile(url.path) + } + + @JvmStatic + fun getSvcGraphFromFile(fileName: String): SvcLogicGraph { + val svcLogicParser = SvcLogicParser() + return svcLogicParser.parse(fileName).first + } +}
\ 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/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 new file mode 100644 index 00000000..341b6f84 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/BlueprintServiceLogicTest.kt @@ -0,0 +1,60 @@ +/* + * 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.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 +import org.springframework.test.context.junit4.SpringRunner + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [WorkflowServiceConfiguration::class, ComponentExecuteNodeExecutor::class]) +class BlueprintServiceLogicTest { + + private val log = LoggerFactory.getLogger(BlueprintServiceLogicTest::class.java) + + 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 + + @Test + fun testExecuteGraphWithSingleComponent() { + + val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml") + blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) + + } + + @Test + fun testExecuteGraphWithMultipleComponents() { + val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml") + 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 new file mode 100644 index 00000000..747be76c --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/workflow/mock/MockComponentFunction.kt @@ -0,0 +1,49 @@ +/* + * 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.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 +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +open class MockComponentConfiguration { + + @Bean(name = ["component-resource-assignment", "component-netconf-executor"]) + open fun createComponentFunction(): AbstractComponentFunction { + return MockComponentFunction() + } +} + +class MockComponentFunction : AbstractComponentFunction() { + + private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java) + + override fun process(executionRequest: ExecutionServiceInput) { + log.info("Processing component..") + + this.executionServiceOutput = ExecutionServiceOutput() + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + log.info("Recovering component..") + } +}
\ No newline at end of file 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/modules/services/workflow-service/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml new file mode 100644 index 00000000..a816a06c --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.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/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml new file mode 100644 index 00000000..5ff26ad2 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/one-component.xml @@ -0,0 +1,34 @@ +<!-- + ~ 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. + --> + +<service-logic + xmlns='http://www.onap.org/sdnc/svclogic' + xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'> + <method rpc='ActivateNetconf' mode='sync'> + <block atomic="true"> + <execute plugin="resource-assignment" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <return status='success'> + </return> + </outcome> + </execute> + </block> + </method> +</service-logic>
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml new file mode 100644 index 00000000..7de61db5 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/service-logic/two-component.xml @@ -0,0 +1,42 @@ +<!-- + ~ 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. + --> + +<service-logic + xmlns='http://www.onap.org/sdnc/svclogic' + xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='CONFIG' version='1.0.0'> + <method rpc='ResourceAssignAndActivate' mode='sync'> + <block atomic="true"> + <execute plugin="resource-assignment" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <execute plugin="resource-assignment-py" method="process"> + <outcome value='failure'> + <return status="failure"> + </return> + </outcome> + <outcome value='success'> + <return status='success'> + </return> + </outcome> + </execute> + </outcome> + </execute> + </block> + </method> +</service-logic>
\ No newline at end of file diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index fd32ae12..ba8e9211 100644 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -16,7 +16,8 @@ ~ 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"> +<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</groupId> @@ -31,12 +32,17 @@ <properties> <spring.boot.version>2.0.6.RELEASE</spring.boot.version> <spring.version>5.0.10.RELEASE</spring.version> - <kotlin.version>1.3.0</kotlin.version> + <kotlin.version>1.3.10</kotlin.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> <powermock.version>1.7.4</powermock.version> </properties> <dependencyManagement> @@ -56,6 +62,11 @@ <artifactId>eelf-core</artifactId> <version>${eelf.version}</version> </dependency> + <dependency> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-slf4j</artifactId> + <version>${onap.logger.slf4j}</version> + </dependency> <!-- Kotlin Dependencies --> <dependency> @@ -64,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> @@ -84,6 +95,68 @@ <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> + <artifactId>sli-provider</artifactId> + <version>${sli.version}</version> + <exclusions> + <exclusion> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.commons</groupId> + <artifactId>*</artifactId> + </exclusion> + <exclusion> + <groupId>org.slf4j</groupId> + <artifactId>*</artifactId> + </exclusion> + <exclusion> + <groupId>org.opendaylight.mdsal.model</groupId> + <artifactId>*</artifactId> + </exclusion> + <!--<exclusion>--> + <!--<groupId>org.opendaylight.controller</groupId>--> + <!--<artifactId>*</artifactId>--> + <!--</exclusion>--> + <exclusion> + <groupId>org.apache.tomcat</groupId> + <artifactId>*</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.karaf.shell</groupId> + <artifactId>*</artifactId> + </exclusion> + <exclusion> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>*</artifactId> + </exclusion> + <exclusion> + <groupId>org.powermock</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- Application Module Dependencies --> <dependency> @@ -103,17 +176,12 @@ </dependency> <dependency> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>db-service</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> <artifactId>execution-service</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> - <artifactId>resolution-service</artifactId> + <artifactId>workflow-service</artifactId> <version>${project.version}</version> </dependency> <dependency> @@ -127,6 +195,13 @@ <version>${project.version}</version> </dependency> + <!-- Functions --> + <dependency> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> + <artifactId>resource-resolution</artifactId> + <version>${project.version}</version> + </dependency> + <!-- Application Component Dependency --> <dependency> <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> @@ -172,12 +247,18 @@ <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> + <dependency> + <groupId>org.python</groupId> + <artifactId>jython-standalone</artifactId> + <version>${jython.version}</version> + </dependency> <!-- Database --> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>${h2database.version}</version> + <scope>test</scope> </dependency> <!-- Test Dependency --> <dependency> @@ -194,24 +275,77 @@ </dependency> </dependencies> </dependencyManagement> - <dependencies> - <!-- Application Component Dependency --> + <dependencies> + <dependency> + <groupId>com.att.eelf</groupId> + <artifactId>eelf-core</artifactId> + </dependency> <dependency> - <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId> - <artifactId>resource-dict</artifactId> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-slf4j</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>com.jayway.jsonpath</groupId> + <artifactId>json-path</artifactId> + </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger2</artifactId> + </dependency> + <dependency> + <groupId>io.springfox</groupId> + <artifactId>springfox-swagger-ui</artifactId> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib</artifactId> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib-jdk8</artifactId> + </dependency> + <dependency> + <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> <plugins> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> - <version>${kotlin.version}</version> + <version>${kotlin.maven.version}</version> <executions> <execution> <id>compile</id> - <goals> + <goals> <goal>compile</goal> </goals> <configuration> diff --git a/ms/blueprintsprocessor/pom.xml b/ms/blueprintsprocessor/pom.xml index 740407dc..4e119b77 100644 --- a/ms/blueprintsprocessor/pom.xml +++ b/ms/blueprintsprocessor/pom.xml @@ -43,6 +43,7 @@ <modules> <module>parent</module> <module>modules</module> + <module>functions</module> <module>application</module> </modules> diff --git a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java index 7a5f952d..de907e76 100644 --- a/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java +++ b/ms/controllerblueprints/application/src/test/java/org/onap/ccsdk/apps/controllerblueprints/ControllerBluprintsApplicationTest.java @@ -16,21 +16,18 @@ package org.onap.ccsdk.apps.controllerblueprints;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.http.*;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
import org.springframework.http.client.support.BasicAuthorizationInterceptor;
import org.springframework.test.context.junit4.SpringRunner;
-import static org.assertj.core.api.Assertions.assertThat;
-
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class ControllerBluprintsApplicationTest {
@@ -47,19 +44,19 @@ public class ControllerBluprintsApplicationTest { public void testConfigModel() {
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
- ResponseEntity<ConfigModel> entity = this.restTemplate
- .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
- assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
- Assert.assertNotNull("failed to get response Config model",entity.getBody());
+// ResponseEntity<ConfigModel> entity = this.restTemplate
+// .exchange("/api/v1/config-model/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
+// assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
+// Assert.assertNotNull("failed to get response Config model",entity.getBody());
}
@Test
public void testConfigModelFailure() {
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
- ResponseEntity<ConfigModel> entity = this.restTemplate
- .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
- assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
- Assert.assertNotNull("failed to get response Config model",entity.getBody());
+// ResponseEntity<ConfigModel> entity = this.restTemplate
+// .exchange("/api/v1/config-model-not-found/1", HttpMethod.GET, new HttpEntity<>(headers),ConfigModel.class);
+// assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
+// Assert.assertNotNull("failed to get response Config model",entity.getBody());
}
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java index 92fe8def..74faa4df 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/DataBaseInitService.java @@ -1,318 +1,325 @@ -/*
- * 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.
- */
-
-package org.onap.ccsdk.apps.controllerblueprints.service;
-
-import com.google.common.base.Preconditions;
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.text.StrBuilder;
-import org.jetbrains.annotations.NotNull;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants;
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType;
-import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType;
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType;
-import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary;
-import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.context.event.ApplicationReadyEvent;
-import org.springframework.context.event.EventListener;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.ResourcePatternResolver;
-import org.springframework.stereotype.Component;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.List;
-
-/**
- * DataBaseInitService.java Purpose: Provide DataBaseInitService Service
- *
- * @author Brinda Santh
- * @version 1.0
- */
-
-@Component
-@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true")
-public class DataBaseInitService {
-
- private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class);
- private ModelTypeService modelTypeService;
- private ResourceDictionaryService resourceDictionaryService;
- private ConfigModelService configModelService;
-
- @Value("${load.dataTypePath}")
- private String dataTypePath;
- @Value("${load.nodeTypePath}")
- private String nodeTypePath;
- @Value("${load.artifactTypePath}")
- private String artifactTypePath;
- @Value("${load.resourceDictionaryPath}")
- private String resourceDictionaryPath;
- @Value("${load.blueprintsPath}")
- private String bluePrintsPath;
-
- @Autowired
- private ResourcePatternResolver resourceLoader;
-
- /**
- * This is a DataBaseInitService, used to load the initial data
- *
- * @param modelTypeService modelTypeService
- * @param resourceDictionaryService resourceDictionaryService
- * @param configModelService configModelService
- */
- public DataBaseInitService(ModelTypeService modelTypeService, ResourceDictionaryService resourceDictionaryService,
- ConfigModelService configModelService) {
- this.modelTypeService = modelTypeService;
- this.resourceDictionaryService = resourceDictionaryService;
- this.configModelService = configModelService;
- log.info("DataBaseInitService started...");
-
- }
-
- @SuppressWarnings("unused")
- @EventListener(ApplicationReadyEvent.class)
- private void initDatabase() {
- log.info("loading dataTypePath from DIR : {}", dataTypePath);
- log.info("loading nodeTypePath from DIR : {}", nodeTypePath);
- log.info("loading artifactTypePath from DIR : {}", artifactTypePath);
- log.info("loading resourceDictionaryPath from DIR : {}", resourceDictionaryPath);
- log.info("loading bluePrintsPath from DIR : {}", bluePrintsPath);
-
- loadModelType();
- loadResourceDictionary();
- loadBlueprints();
- }
-
- private void loadModelType() {
- log.info(" *************************** loadModelType **********************");
- try {
- Resource[] dataTypefiles = getPathResources(dataTypePath, ".json");
- StrBuilder errorBuilder = new StrBuilder();
- for (Resource file : dataTypefiles) {
- if (file != null) {
- loadDataType(file, errorBuilder);
- }
- }
-
- Resource[] nodeTypefiles = getPathResources(nodeTypePath, ".json");
- for (Resource file : nodeTypefiles) {
- if (file != null) {
- loadNodeType(file, errorBuilder);
- }
- }
-
-
- Resource[] artifactTypefiles = getPathResources(artifactTypePath, ".json");
-
- for (Resource file : artifactTypefiles) {
- if (file != null) {
- loadArtifactType(file, errorBuilder);
- }
- }
-
-
- if (!errorBuilder.isEmpty()) {
- log.error(errorBuilder.toString());
- }
- } catch (Exception e) {
- log.error("Failed in Data type loading", e);
- }
- }
-
- private void loadResourceDictionary() {
- log.info(
- " *************************** loadResourceDictionary **********************");
- try {
- Resource[] dataTypefiles = getPathResources(resourceDictionaryPath, ".json");
-
- StrBuilder errorBuilder = new StrBuilder();
- String fileName;
- for (Resource file : dataTypefiles) {
- try {
- fileName = file.getFilename();
- log.trace("Loading : {}", fileName);
- String definitionContent = getResourceContent(file);
- ResourceDefinition resourceDefinition =
- JacksonUtils.readValue(definitionContent, ResourceDefinition.class);
- if (resourceDefinition != null) {
- Preconditions.checkNotNull(resourceDefinition.getProperty(), "Failed to get Property Definition");
- ResourceDictionary resourceDictionary = new ResourceDictionary();
- resourceDictionary.setName(resourceDefinition.getName());
- resourceDictionary.setDefinition(resourceDefinition);
-
- Preconditions.checkNotNull(resourceDefinition.getProperty(), "Property field is missing");
- resourceDictionary.setDescription(resourceDefinition.getProperty().getDescription());
- resourceDictionary.setDataType(resourceDefinition.getProperty().getType());
- if(resourceDefinition.getProperty().getEntrySchema() != null){
- resourceDictionary.setEntrySchema(resourceDefinition.getProperty().getEntrySchema().getType());
- }
- resourceDictionary.setUpdatedBy(resourceDefinition.getUpdatedBy());
- if (StringUtils.isBlank(resourceDefinition.getTags())) {
- resourceDictionary.setTags(
- resourceDefinition.getName() + ", " + resourceDefinition.getUpdatedBy()
- + ", " + resourceDefinition.getUpdatedBy());
-
- } else {
- resourceDictionary.setTags(resourceDefinition.getTags());
- }
- resourceDictionaryService.saveResourceDictionary(resourceDictionary);
-
- log.trace(" Loaded successfully : {}", file.getFilename());
- } else {
- throw new BluePrintException("couldn't get dictionary from content information");
- }
- } catch (Exception e) {
- errorBuilder.appendln("Dictionary loading Errors : " + file.getFilename() + ":" + e.getMessage());
- }
- }
- if (!errorBuilder.isEmpty()) {
- log.error(errorBuilder.toString());
- }
-
-
- } catch (Exception e) {
- log.error(
- "Failed in Resource dictionary loading", e);
- }
- }
-
- private void loadBlueprints() {
- log.info("*************************** loadServiceTemplate **********************");
- try {
- List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(bluePrintsPath);
- if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) {
- StrBuilder errorBuilder = new StrBuilder();
- for (String fileName : serviceTemplateDirs) {
- try {
- String bluePrintPath = this.bluePrintsPath.concat("/").concat(fileName);
- log.debug("***** Loading service template : {}", bluePrintPath);
- ConfigModel configModel = ConfigModelUtils.getConfigModel(bluePrintPath);
-
- configModel = this.configModelService.saveConfigModel(configModel);
-
- log.info("Publishing : {}", configModel.getId());
-
- this.configModelService.publishConfigModel(configModel.getId());
-
- log.info("Loaded service template successfully: {}", fileName);
-
- } catch (Exception e) {
- errorBuilder.appendln("load config model " + fileName + " error : " + e.getMessage());
- }
- }
-
- if (!errorBuilder.isEmpty()) {
- log.error(errorBuilder.toString());
- }
- }
- } catch (Exception e) {
- log.error("Failed in Service Template loading", e);
- }
- }
-
- private void loadNodeType(Resource file, StrBuilder errorBuilder) {
- try {
- log.trace("Loading Node Type : {}", file.getFilename());
- String nodeKey = file.getFilename().replace(".json", "");
- String definitionContent = getResourceContent(file);
- NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class);
- Preconditions.checkNotNull(nodeType, String.format("failed to get node type from file : %s", file.getFilename()));
- ModelType modelType = new ModelType();
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE);
- modelType.setDerivedFrom(nodeType.getDerivedFrom());
- modelType.setDescription(nodeType.getDescription());
- modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
- modelType.setModelName(nodeKey);
- modelType.setVersion(nodeType.getVersion());
- modelType.setUpdatedBy("System");
- modelType.setTags(nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + ","
- + nodeType.getDerivedFrom());
- modelTypeService.saveModel(modelType);
- log.trace("Loaded Node Type successfully : {}", file.getFilename());
- } catch (Exception e) {
- errorBuilder.appendln("Node type loading error : " + file.getFilename() + ":" + e.getMessage());
- }
- }
-
- private void loadDataType(@NotNull Resource file, StrBuilder errorBuilder) {
- try {
- log.trace("Loading Data Type: {}", file.getFilename());
- String dataKey = file.getFilename().replace(".json", "");
- String definitionContent = getResourceContent(file);
- DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class);
- Preconditions.checkNotNull(dataType, String.format("failed to get data type from file : %s", file.getFilename()));
- ModelType modelType = new ModelType();
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- modelType.setDerivedFrom(dataType.getDerivedFrom());
- modelType.setDescription(dataType.getDescription());
- modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
- modelType.setModelName(dataKey);
- modelType.setVersion(dataType.getVersion());
- modelType.setUpdatedBy("System");
- modelType.setTags(dataKey + "," + dataType.getDerivedFrom() + ","
- + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE);
- modelTypeService.saveModel(modelType);
- log.trace(" Loaded Data Type successfully : {}", file.getFilename());
- } catch (Exception e) {
- errorBuilder.appendln("Data type loading error : " + file.getFilename() + ":" + e.getMessage());
- }
- }
-
- private void loadArtifactType(Resource file, StrBuilder errorBuilder) {
- try {
- log.trace("Loading Artifact Type: {}", file.getFilename());
- String dataKey = file.getFilename().replace(".json", "");
- String definitionContent = getResourceContent(file);
- ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class);
- Preconditions.checkNotNull(artifactType, String.format("failed to get artifact type from file : %s", file.getFilename()));
- ModelType modelType = new ModelType();
- modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
- modelType.setDerivedFrom(artifactType.getDerivedFrom());
- modelType.setDescription(artifactType.getDescription());
- modelType.setDefinition(JacksonUtils.jsonNode(definitionContent));
- modelType.setModelName(dataKey);
- modelType.setVersion(artifactType.getVersion());
- modelType.setUpdatedBy("System");
- modelType.setTags(dataKey + "," + artifactType.getDerivedFrom() + ","
- + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE);
- modelTypeService.saveModel(modelType);
- log.trace("Loaded Artifact Type successfully : {}", file.getFilename());
- } catch (Exception e) {
- errorBuilder.appendln("Artifact type loading error : " + file.getFilename() + ":" + e.getMessage());
- }
- }
-
- private Resource[] getPathResources(String path, String extension) throws IOException {
- return resourceLoader.getResources("file:" + path + "/*" + extension);
- }
-
- private String getResourceContent(Resource resource) throws IOException {
- return IOUtils.toString(resource.getInputStream(), Charset.defaultCharset());
- }
-
-}
+/* + * 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.service; + +import com.google.common.base.Preconditions; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.text.StrBuilder; +import org.jetbrains.annotations.NotNull; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants; +import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException; +import org.onap.ccsdk.apps.controllerblueprints.core.data.ArtifactType; +import org.onap.ccsdk.apps.controllerblueprints.core.data.DataType; +import org.onap.ccsdk.apps.controllerblueprints.core.data.NodeType; +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils; +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition; +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel; +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ModelType; +import org.onap.ccsdk.apps.controllerblueprints.service.domain.ResourceDictionary; +import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; +import org.springframework.core.io.Resource; +import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.List; + +/** + * DataBaseInitService.java Purpose: Provide DataBaseInitService Service + * + * @author Brinda Santh + * @version 1.0 + */ + +@Component +@ConditionalOnProperty(name = "blueprints.load.initial-data", havingValue = "true") +public class DataBaseInitService { + + private static EELFLogger log = EELFManager.getInstance().getLogger(DataBaseInitService.class); + private ModelTypeService modelTypeService; + private ResourceDictionaryService resourceDictionaryService; + private ConfigModelService configModelService; + private String updateBySystem = "System"; + private static final String JSON_EXTN= ".json"; + private static final String EXCEPTION= "Exception"; + + @Value("${load.dataTypePath}") + private String dataTypePath; + @Value("${load.nodeTypePath}") + private String nodeTypePath; + @Value("${load.artifactTypePath}") + private String artifactTypePath; + @Value("${load.resourceDictionaryPath}") + private String resourceDictionaryPath; + @Value("${load.blueprintsPath}") + private String bluePrintsPath; + + @Autowired + private ResourcePatternResolver resourceLoader; + + /** + * This is a DataBaseInitService, used to load the initial data + * + * @param modelTypeService modelTypeService + * @param resourceDictionaryService resourceDictionaryService + * @param configModelService configModelService + */ + public DataBaseInitService(ModelTypeService modelTypeService, ResourceDictionaryService resourceDictionaryService, + ConfigModelService configModelService) { + this.modelTypeService = modelTypeService; + this.resourceDictionaryService = resourceDictionaryService; + this.configModelService = configModelService; + log.info("DataBaseInitService started..."); + + } + + @SuppressWarnings("unused") + @EventListener(ApplicationReadyEvent.class) + private void initDatabase() { + log.info("loading dataTypePath from DIR : {}", dataTypePath); + log.info("loading nodeTypePath from DIR : {}", nodeTypePath); + log.info("loading artifactTypePath from DIR : {}", artifactTypePath); + log.info("loading resourceDictionaryPath from DIR : {}", resourceDictionaryPath); + log.info("loading bluePrintsPath from DIR : {}", bluePrintsPath); + + loadModelType(); + loadResourceDictionary(); + } + + private void loadModelType() { + log.info(" *************************** loadModelType **********************"); + try { + Resource[] dataTypefiles = getPathResources(dataTypePath, JSON_EXTN); + StrBuilder errorBuilder = new StrBuilder(); + for (Resource file : dataTypefiles) { + if (file != null) { + loadDataType(file, errorBuilder); + } + } + + Resource[] nodeTypefiles = getPathResources(nodeTypePath, JSON_EXTN); + for (Resource file : nodeTypefiles) { + if (file != null) { + loadNodeType(file, errorBuilder); + } + } + + + Resource[] artifactTypefiles = getPathResources(artifactTypePath, JSON_EXTN); + + for (Resource file : artifactTypefiles) { + if (file != null) { + loadArtifactType(file, errorBuilder); + } + } + + + if (!errorBuilder.isEmpty()) { + log.error(errorBuilder.toString()); + } + } catch (Exception e) { + log.error("Failed in Data type loading", e); + } + } + + private void loadResourceDictionary() { + log.info( + " *************************** loadResourceDictionary **********************"); + try { + Resource[] dataTypefiles = getPathResources(resourceDictionaryPath, JSON_EXTN); + + StrBuilder errorBuilder = new StrBuilder(); + String fileName; + for (Resource file : dataTypefiles) { + try { + fileName = file.getFilename(); + log.trace("Loading : {}", fileName); + String definitionContent = getResourceContent(file); + ResourceDefinition resourceDefinition = + JacksonUtils.readValue(definitionContent, ResourceDefinition.class); + if (resourceDefinition != null) { + Preconditions.checkNotNull(resourceDefinition.getProperty(), "Failed to get Property Definition"); + ResourceDictionary resourceDictionary = new ResourceDictionary(); + resourceDictionary.setName(resourceDefinition.getName()); + resourceDictionary.setDefinition(resourceDefinition); + + Preconditions.checkNotNull(resourceDefinition.getProperty(), "Property field is missing"); + resourceDictionary.setDescription(resourceDefinition.getProperty().getDescription()); + resourceDictionary.setDataType(resourceDefinition.getProperty().getType()); + if(resourceDefinition.getProperty().getEntrySchema() != null){ + resourceDictionary.setEntrySchema(resourceDefinition.getProperty().getEntrySchema().getType()); + } + resourceDictionary.setUpdatedBy(resourceDefinition.getUpdatedBy()); + if (StringUtils.isBlank(resourceDefinition.getTags())) { + resourceDictionary.setTags( + resourceDefinition.getName() + ", " + resourceDefinition.getUpdatedBy() + + ", " + resourceDefinition.getUpdatedBy()); + + } else { + resourceDictionary.setTags(resourceDefinition.getTags()); + } + resourceDictionaryService.saveResourceDictionary(resourceDictionary); + + log.trace(" Loaded successfully : {}", file.getFilename()); + } else { + throw new BluePrintException("couldn't get dictionary from content information"); + } + } catch (Exception e) { + log.error(EXCEPTION, e); + errorBuilder.appendln("Dictionary loading Errors : " + file.getFilename() + ":" + e.getMessage()); + } + } + if (!errorBuilder.isEmpty()) { + log.error(errorBuilder.toString()); + } + + + } catch (Exception e) { + log.error( + "Failed in Resource dictionary loading", e); + } + } + + private void loadBlueprints() { + log.info("*************************** loadServiceTemplate **********************"); + try { + List<String> serviceTemplateDirs = ConfigModelUtils.getBlueprintNames(bluePrintsPath); + if (CollectionUtils.isNotEmpty(serviceTemplateDirs)) { + StrBuilder errorBuilder = new StrBuilder(); + for (String fileName : serviceTemplateDirs) { + try { + String bluePrintPath = this.bluePrintsPath.concat("/").concat(fileName); + log.debug("***** Loading service template : {}", bluePrintPath); + ConfigModel configModel = ConfigModelUtils.getConfigModel(bluePrintPath); + + configModel = this.configModelService.saveConfigModel(configModel); + + log.info("Publishing : {}", configModel.getId()); + + this.configModelService.publishConfigModel(configModel.getId()); + + log.info("Loaded service template successfully: {}", fileName); + + } catch (Exception e) { + log.error(EXCEPTION, e); + errorBuilder.appendln("load config model " + fileName + " error : " + e.getMessage()); + } + } + + if (!errorBuilder.isEmpty()) { + log.error(errorBuilder.toString()); + } + } + } catch (Exception e) { + log.error("Failed in Service Template loading", e); + } + } + + private void loadNodeType(Resource file, StrBuilder errorBuilder) { + try { + log.trace("Loading Node Type : {}", file.getFilename()); + String nodeKey = file.getFilename().replace(JSON_EXTN, ""); + String definitionContent = getResourceContent(file); + NodeType nodeType = JacksonUtils.readValue(definitionContent, NodeType.class); + Preconditions.checkNotNull(nodeType, String.format("failed to get node type from file : %s", file.getFilename())); + ModelType modelType = new ModelType(); + modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE); + modelType.setDerivedFrom(nodeType.getDerivedFrom()); + modelType.setDescription(nodeType.getDescription()); + modelType.setDefinition(JacksonUtils.jsonNode(definitionContent)); + modelType.setModelName(nodeKey); + modelType.setVersion(nodeType.getVersion()); + modelType.setUpdatedBy(updateBySystem); + modelType.setTags(nodeKey + "," + BluePrintConstants.MODEL_DEFINITION_TYPE_NODE_TYPE + "," + + nodeType.getDerivedFrom()); + modelTypeService.saveModel(modelType); + log.trace("Loaded Node Type successfully : {}", file.getFilename()); + } catch (Exception e) { + log.error(EXCEPTION, e); + errorBuilder.appendln("Node type loading error : " + file.getFilename() + ":" + e.getMessage()); + } + } + + private void loadDataType(@NotNull Resource file, StrBuilder errorBuilder) { + try { + log.trace("Loading Data Type: {}", file.getFilename()); + String dataKey = file.getFilename().replace(JSON_EXTN, ""); + String definitionContent = getResourceContent(file); + DataType dataType = JacksonUtils.readValue(definitionContent, DataType.class); + Preconditions.checkNotNull(dataType, String.format("failed to get data type from file : %s", file.getFilename())); + ModelType modelType = new ModelType(); + modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelType.setDerivedFrom(dataType.getDerivedFrom()); + modelType.setDescription(dataType.getDescription()); + modelType.setDefinition(JacksonUtils.jsonNode(definitionContent)); + modelType.setModelName(dataKey); + modelType.setVersion(dataType.getVersion()); + modelType.setUpdatedBy(updateBySystem); + modelType.setTags(dataKey + "," + dataType.getDerivedFrom() + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_DATA_TYPE); + modelTypeService.saveModel(modelType); + log.trace(" Loaded Data Type successfully : {}", file.getFilename()); + } catch (Exception e) { + log.error(EXCEPTION, e); + errorBuilder.appendln("Data type loading error : " + file.getFilename() + ":" + e.getMessage()); + } + } + + private void loadArtifactType(Resource file, StrBuilder errorBuilder) { + try { + log.trace("Loading Artifact Type: {}", file.getFilename()); + String dataKey = file.getFilename().replace(JSON_EXTN, ""); + String definitionContent = getResourceContent(file); + ArtifactType artifactType = JacksonUtils.readValue(definitionContent, ArtifactType.class); + Preconditions.checkNotNull(artifactType, String.format("failed to get artifact type from file : %s", file.getFilename())); + ModelType modelType = new ModelType(); + modelType.setDefinitionType(BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE); + modelType.setDerivedFrom(artifactType.getDerivedFrom()); + modelType.setDescription(artifactType.getDescription()); + modelType.setDefinition(JacksonUtils.jsonNode(definitionContent)); + modelType.setModelName(dataKey); + modelType.setVersion(artifactType.getVersion()); + modelType.setUpdatedBy(updateBySystem); + modelType.setTags(dataKey + "," + artifactType.getDerivedFrom() + "," + + BluePrintConstants.MODEL_DEFINITION_TYPE_ARTIFACT_TYPE); + modelTypeService.saveModel(modelType); + log.trace("Loaded Artifact Type successfully : {}", file.getFilename()); + } catch (Exception e) { + log.error(EXCEPTION, e); + errorBuilder.appendln("Artifact type loading error : " + file.getFilename() + ":" + e.getMessage()); + } + } + + private Resource[] getPathResources(String path, String extension) throws IOException { + return resourceLoader.getResources("file:" + path + "/*" + extension); + } + + private String getResourceContent(Resource resource) throws IOException { + return IOUtils.toString(resource.getInputStream(), Charset.defaultCharset()); + } + +} diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java index 8dd74840..d16f1b13 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/common/ApplicationConstants.java @@ -23,11 +23,12 @@ package org.onap.ccsdk.apps.controllerblueprints.service.common; * @version 1.0
*/
public final class ApplicationConstants {
- private ApplicationConstants() {
-
- }
public static final String ACTIVE_Y = "Y";
public static final String ACTIVE_N = "N";
public static final String ASDC_ARTIFACT_TYPE_SDNC_MODEL = "SDNC_MODEL";
+
+ private ApplicationConstants() {
+
+ }
}
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/ConfigModelContent.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java index ae374a78..71904fb3 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/domain/ConfigModelContent.java @@ -76,11 +76,10 @@ public class ConfigModelContent { @Override
public String toString() {
- String builder = "[" + "id = " + id +
+ return "[" + "id = " + id +
", name = " + name +
", contentType = " + contentType +
"]";
- return builder;
}
@Override
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/ConfigModelRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java index fc2956be..95e551b1 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ConfigModelRest.java @@ -81,7 +81,7 @@ public class ConfigModelRest { @GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) throws BluePrintException {
+ List<ConfigModel> searchConfigModels(@PathVariable(value = "tags") String tags) {
return this.configModelService.searchConfigModels(tags);
}
diff --git a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java index 988cad06..0f485a08 100644 --- a/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java +++ b/ms/controllerblueprints/modules/service/src/main/java/org/onap/ccsdk/apps/controllerblueprints/service/rs/ModelTypeRest.java @@ -44,18 +44,18 @@ public class ModelTypeRest { }
@GetMapping(path = "/{name}", produces = MediaType.APPLICATION_JSON_VALUE)
- public ModelType getModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {
+ public ModelType getModelTypeByName(@PathVariable(value = "name") String name) {
return modelTypeService.getModelTypeByName(name);
}
@GetMapping(path = "/search/{tags}", produces = MediaType.APPLICATION_JSON_VALUE)
- public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) throws BluePrintException {
+ public List<ModelType> searchModelTypes(@PathVariable(value = "tags") String tags) {
return modelTypeService.searchModelTypes(tags);
}
@GetMapping(path = "/by-definition/{definitionType}", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody
- List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) throws BluePrintException {
+ List<ModelType> getModelTypeByDefinitionType(@PathVariable(value = "definitionType") String definitionType) {
return modelTypeService.getModelTypeByDefinitionType(definitionType);
}
@@ -66,7 +66,7 @@ public class ModelTypeRest { }
@DeleteMapping(path = "/{name}")
- public void deleteModelTypeByName(@PathVariable(value = "name") String name) throws BluePrintException {
+ public void deleteModelTypeByName(@PathVariable(value = "name") String name) {
modelTypeService.deleteByModelName(name);
}
}
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 76ea4dcb..4f6a316b 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -30,7 +30,8 @@ <properties> <spring.boot.version>2.0.6.RELEASE</spring.boot.version> <spring.version>5.0.10.RELEASE</spring.version> - <kotlin.version>1.3.0</kotlin.version> + <kotlin.version>1.3.10</kotlin.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> @@ -126,8 +127,6 @@ <version>${kotlin.version}</version> </dependency> - - <!-- Database --> <dependency> <groupId>com.h2database</groupId> @@ -240,7 +239,7 @@ <plugin> <artifactId>kotlin-maven-plugin</artifactId> <groupId>org.jetbrains.kotlin</groupId> - <version>${kotlin.version}</version> + <version>${kotlin.maven.version}</version> <executions> <execution> <id>compile</id> diff --git a/ms/neng/src/main/docker/startService.sh b/ms/neng/src/main/docker/startService.sh index be45897f..814fc475 100644 --- a/ms/neng/src/main/docker/startService.sh +++ b/ms/neng/src/main/docker/startService.sh @@ -29,7 +29,7 @@ APP_ARGS=${APP_ARGS}" -Dpol_req_id="${POL_REQ_ID} APP_ARGS=${APP_ARGS}" -Daai_cert_pass="${AAI_CERT_PASS} APP_ARGS=${APP_ARGS}" -Daai_cert_path="${AAI_CERT_PATH} APP_ARGS=${APP_ARGS}" -Daai_uri="${AAI_URI} -APP_ARGS=${APP_ARGS}" -Daai_auth="${AAIC_AUTH} +APP_ARGS=${APP_ARGS}" -Daai_auth="${AAI_AUTH} APP_ARGS=${APP_ARGS}" -cp /opt/etc/config" echo "APP_ARGS ="${APP_ARGS} diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java index 6efa94de..1287a273 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java @@ -21,6 +21,9 @@ package org.onap.ccsdk.apps.ms.neng.core; import java.util.Arrays; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -38,6 +41,9 @@ import org.springframework.scheduling.annotation.EnableAsync; @ComponentScan(basePackages = "org.onap.ccsdk") @EnableAsync public class Application extends SpringBootServletInitializer { + + private Logger log = LoggerFactory.getLogger(Application.class); + /** * Configures the application. */ @@ -49,7 +55,7 @@ public class Application extends SpringBootServletInitializer { /** * Entry point for the application. */ - public static void main(String[] args) throws Exception { + public static void main(String[] args) { SpringApplication.run(Application.class, args); } @@ -59,14 +65,15 @@ public class Application extends SpringBootServletInitializer { @Bean public CommandLineRunner commandLineRunner(ApplicationContext ctx) { return args -> { - System.out.println("################################"); - System.out.println("Inspecting the beans provided by Spring Boot:"); + log.info("################################"); + log.info("Inspecting the beans provided by Spring Boot:"); String[] beanNames = ctx.getBeanDefinitionNames(); Arrays.sort(beanNames); for (String beanName : beanNames) { System.out.println(beanName); + log.info(beanName); } - System.out.println("################################"); + log.info("################################"); }; } diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParser.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParser.java index d9eda66a..e808b8c2 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParser.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParser.java @@ -37,6 +37,9 @@ public class RecipeParser { * @return a list containing the items in the recipe * @throws Exception all exceptions are propagated */ + private RecipeParser(){ + + } public static List<String> parseRecipe(PolicyParameters policyParams, String recipe) throws Exception { String separatorAll = policyParams.getRecipeSeparator(); if (separatorAll == null) { diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequest.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequest.java index e8bc555d..c233a28b 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequest.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigRequest.java @@ -29,10 +29,10 @@ import java.util.Map; public class GetConfigRequest implements Serializable { private static final long serialVersionUID = -8039686696076337053L; - Map<String, Object> configAttributes; - String configName; - String ecompName; - String policyName; + private static Map<String, Object> configAttributes; + private static String configName; + private static String ecompName; + private static String policyName; boolean unique; public Map<String, Object> getConfigAttributes() { diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponse.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponse.java index 9fe567f1..f8ea6e1e 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponse.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/GetConfigResponse.java @@ -27,7 +27,7 @@ import java.io.Serializable; */ public class GetConfigResponse implements Serializable { private static final long serialVersionUID = -8039686696076337053L; - Object response; + private static Object response; public Object getResponse() { return response; diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponse.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponse.java index c4ac7fcb..35da40c2 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponse.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/resource/model/NameGenResponse.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 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 @@ -29,7 +31,7 @@ import java.util.Map; */ public class NameGenResponse implements Serializable { private static final long serialVersionUID = -8039686696076337053L; - List<Map<String, String>> elements; + private static List<Map<String, String>> elements; public List<Map<String, String>> getElements() { return elements; diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImpl.java index 6c4ae889..7356c3bd 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImpl.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImpl.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 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 @@ -125,4 +127,8 @@ public class AaiServiceImpl { } return this.restTemplate; } + + public void setAaiProps(AaiProps aaiProps) { + this.aaiProps = aaiProps; + } } diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/ExternalKeyValidatorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/ExternalKeyValidatorTest.java new file mode 100644 index 00000000..7c6c95f3 --- /dev/null +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/validator/ExternalKeyValidatorTest.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : CCSDK.apps + * ================================================================================ + * Copyright (C) 2018 IBM. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.apps.ms.neng.core.validator; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.ccsdk.apps.ms.neng.persistence.repository.GeneratedNameRespository; + +@RunWith(MockitoJUnitRunner.class) +public class ExternalKeyValidatorTest { + + @InjectMocks + ExternalKeyValidator externalKeyValidator; + + @Mock + GeneratedNameRespository genNameRepo; + + @Test + public void testIsPresent() + { + externalKeyValidator.isPresent("testId"); + } +} diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImplTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImplTest.java index b25de210..8507bf65 100644 --- a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImplTest.java +++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImplTest.java @@ -4,8 +4,6 @@ * ================================================================================ * Copyright (C) 2018 IBM. * ================================================================================ - * Modifications Copyright (C) 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 @@ -26,7 +24,9 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.onap.ccsdk.apps.ms.neng.core.resource.model.AaiResponse; +import org.onap.ccsdk.apps.ms.neng.extinf.props.AaiProps; import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.web.client.RestTemplate; public class AaiServiceImplTest { private AaiServiceImpl aaiServiceImpl; @@ -48,4 +48,14 @@ public class AaiServiceImplTest { AaiResponse aaiResponse = aaiServiceImpl.buildResponse(true); Assert.assertEquals(aaiResponse.isRecFound(), true); } + + @Test(expected= Exception.class) + public void testValidate() throws Exception { + AaiProps aaiProps=new AaiProps(); + aaiProps.setUriBase("http://"); + aaiServiceImpl.setAaiProps(aaiProps); + aaiServiceImpl.setRestTemplate(new RestTemplate()); + aaiServiceImpl.validate("testUrl/","testName"); + + } } @@ -19,14 +19,15 @@ * ============LICENSE_END========================================================= --> -<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"> +<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.parent</groupId> <artifactId>odlparent-lite</artifactId> <version>1.2.0-SNAPSHOT</version> - <relativePath /> + <relativePath/> </parent> <groupId>org.onap.ccsdk.apps</groupId> @@ -38,9 +39,10 @@ <description>Micro-services</description> <modules> - <module>controllerblueprints</module> + <module>controllerblueprints</module> + <module>blueprintsprocessor</module> <module>neng</module> - <!--module>vlantag-api</module--> + <module>vlantag-api</module> </modules> </project> 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;
diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlangtagapi/core/model/AssignVlanTagResponseTest.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlangtagapi/core/model/AssignVlanTagResponseTest.java index bbcebbad..30f817ee 100644 --- a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlangtagapi/core/model/AssignVlanTagResponseTest.java +++ b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlangtagapi/core/model/AssignVlanTagResponseTest.java @@ -62,5 +62,12 @@ public class AssignVlanTagResponseTest { assertTrue((Integer)assignVlanTagResponse.hashCode() instanceof Integer); } + @Test + public void testErrorMessage() + { + assignVlanTagResponse.errorMessage("test error message"); + assertEquals("test error message",assignVlanTagResponse.getErrorMessage()); + } + } diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlangtagapi/core/model/UnassignVlanTagRequestInputTest.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlangtagapi/core/model/UnassignVlanTagRequestInputTest.java index 6081d0b4..99498d6d 100644 --- a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlangtagapi/core/model/UnassignVlanTagRequestInputTest.java +++ b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlangtagapi/core/model/UnassignVlanTagRequestInputTest.java @@ -64,4 +64,12 @@ public class UnassignVlanTagRequestInputTest { } + @Test + public void testVlanTagKey() + { + unassignVlanTagRequestInput.vlanTagKey("testVlanTagKey"); + assertEquals("testVlanTagKey",unassignVlanTagRequestInput.getVlanTagKey()); + + } + } diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/ElementsTest.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/ElementsTest.java new file mode 100644 index 00000000..6d534ff0 --- /dev/null +++ b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/ElementsTest.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * 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.ms.vlantagapi.core.extinf.pm.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +public class ElementsTest { + private Elements elements; + + @Before + public void setUp() { + elements = new Elements(); + } + + @Test + public void testGetSetRecycleVlantagRange() { + elements.setRecycleVlantagRange("recycleVlantagRange"); + assertEquals("recycleVlantagRange", elements.getRecycleVlantagRange()); + } + + @Test + public void testGetSetOverwrite() { + elements.setOverwrite("overwrite"); + assertEquals("overwrite", elements.getOverwrite()); + } + + @Test + public void testGetSetElementVlanRole() { + elements.setElementVlanRole("elementVlanRole"); + assertEquals("elementVlanRole", elements.getElementVlanRole()); + } + + @Test + public void testToString() { + assertTrue(elements.toString() instanceof String); + } +} diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyConfigTest.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyConfigTest.java new file mode 100644 index 00000000..cf928ce0 --- /dev/null +++ b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyConfigTest.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * 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.ms.vlantagapi.core.extinf.pm.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +public class PolicyConfigTest { + + private PolicyConfig policyConfig; + + @Before + public void setUp() { + policyConfig = new PolicyConfig(); + } + + @Test + public void testGetSetConfigName() { + policyConfig.setConfigName("configName"); + assertEquals("configName", policyConfig.getConfigName()); + } + + @Test + public void testGetSetRiskLevel() { + policyConfig.setRiskLevel("RiskLevel"); + assertEquals("RiskLevel", policyConfig.getRiskLevel()); + } + + @Test + public void testGetSetPolicyName() { + policyConfig.setPolicyName("PolicyName"); + assertEquals("PolicyName", policyConfig.getPolicyName()); + } + + @Test + public void testGetSetPolicyScope() { + policyConfig.setPolicyScope("PolicyScope"); + assertEquals("PolicyScope", policyConfig.getPolicyScope()); + } + + @Test + public void testGetSetGuard() { + policyConfig.setGuard("Guard"); + assertEquals("Guard", policyConfig.getGuard()); + } + + @Test + public void testGetSetDescription() { + policyConfig.setDescription("Description"); + assertEquals("Description", policyConfig.getDescription()); + } + + @Test + public void testGetSetPriority() { + policyConfig.setPriority("Priority"); + assertEquals("Priority", policyConfig.getPriority()); + } + + @Test + public void testGetSetUuid() { + policyConfig.setUuid("Uuid"); + assertEquals("Uuid", policyConfig.getUuid()); + } + + @Test + public void testGetSetVersion() { + policyConfig.setVersion("Version"); + assertEquals("Version", policyConfig.getVersion()); + } + + @Test + public void testGetSetService() { + policyConfig.setService("Service"); + assertEquals("Service", policyConfig.getService()); + } + + @Test + public void testGetSetLocation() { + policyConfig.setLocation("Location"); + assertEquals("Location", policyConfig.getLocation()); + } + + @Test + public void testGetSetTemplateVersion() { + policyConfig.setTemplateVersion("TemplateVersion"); + assertEquals("TemplateVersion", policyConfig.getTemplateVersion()); + } + + @Test + public void testToString() + { + assertTrue(policyConfig.toString() instanceof String); + } + +}
\ No newline at end of file diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyContentTest.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyContentTest.java new file mode 100644 index 00000000..a0207238 --- /dev/null +++ b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyContentTest.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * 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.ms.vlantagapi.core.extinf.pm.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +public class PolicyContentTest { + + public PolicyContent policyContent; + + @Before + public void setUp() { + policyContent = new PolicyContent(); + } + + @Test + public void testGetSetPolicyInstanceName() { + policyContent.setPolicyInstanceName("policyInstanceName"); + assertEquals("policyInstanceName", policyContent.getPolicyInstanceName()); + } + + @Test + public void testToString() + { + assertTrue(policyContent.toString() instanceof String); + } + +} diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponseTest.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponseTest.java new file mode 100644 index 00000000..c6de216d --- /dev/null +++ b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/PolicyEngineResponseTest.java @@ -0,0 +1,112 @@ +/******************************************************************************* + * 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.ms.vlantagapi.core.extinf.pm.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Before; +import org.junit.Test; + +public class PolicyEngineResponseTest { + + private PolicyEngineResponse policyEngineResponse; + + @Before + public void setUp() + { + policyEngineResponse= new PolicyEngineResponse(); + } + + @Test + public void testGetSetPolicyConfigMessage() + { + policyEngineResponse.setPolicyConfigMessage("policyConfigMessage"); + assertEquals("policyConfigMessage", policyEngineResponse.getPolicyConfigMessage()); + } + + @Test + public void testGetSetPolicyConfigStatus() + { + policyEngineResponse.setPolicyConfigStatus("PolicyConfigStatus"); + assertEquals("PolicyConfigStatus", policyEngineResponse.getPolicyConfigStatus()); + } + + @Test + public void testGetSetType() + { + policyEngineResponse.setType("Type"); + assertEquals("Type", policyEngineResponse.getType()); + } + + @Test + public void testGetSetPolicyName() + { + policyEngineResponse.setPolicyName("PolicyName"); + assertEquals("PolicyName", policyEngineResponse.getPolicyName()); + } + + @Test + public void testGetSetPolicyType() + { + policyEngineResponse.setPolicyType("PolicyType"); + assertEquals("PolicyType", policyEngineResponse.getPolicyType()); + } + + @Test + public void testGetSetPolicyVersion() + { + policyEngineResponse.setPolicyVersion("PolicyVersion"); + assertEquals("PolicyVersion", policyEngineResponse.getPolicyVersion()); + } + + @Test + public void testGetSetMatchingConditions() + { + HashMap<String, String> test= new HashMap<>(); + policyEngineResponse.setMatchingConditions(test); + assertEquals(test, policyEngineResponse.getMatchingConditions()); + } + + + @Test + public void testGetSetResponseAttributes() + { + HashMap<String, String> test= new HashMap<>(); + policyEngineResponse.setResponseAttributes(test); + assertEquals(test, policyEngineResponse.getResponseAttributes()); + } + + @Test + public void testGetSetProperty() + { + policyEngineResponse.setProperty("Property"); + assertEquals("Property", policyEngineResponse.getProperty()); + } + + @Test + public void testToString() + { + assertTrue(policyEngineResponse.toString() instanceof String); + } + + +} diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/RequestObjectTest.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/RequestObjectTest.java new file mode 100644 index 00000000..1bc869eb --- /dev/null +++ b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/RequestObjectTest.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * 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.ms.vlantagapi.core.extinf.pm.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +public class RequestObjectTest { + public RequestObject requestObject; + + @Before + public void setUp() { + requestObject = new RequestObject(); + } + + @Test + public void testGetSetPolicyName() { + requestObject.setPolicyName("PolicyName"); + assertEquals("PolicyName", requestObject.getPolicyName()); + } + + @Test + public void testToString() { + assertTrue(requestObject.toString() instanceof String); + } +} diff --git a/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/ResourceModelTest.java b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/ResourceModelTest.java new file mode 100644 index 00000000..faff693f --- /dev/null +++ b/ms/vlantag-api/src/test/java/org/onap/ccsdk/apps/ms/vlantagapi/core/extinf/pm/model/ResourceModelTest.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * 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.ms.vlantagapi.core.extinf.pm.model; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +public class ResourceModelTest { + private ResourceModel resourceModel; + + @Before + public void setUp() + { + resourceModel= new ResourceModel(); + } + + @Test + public void testGetSetResourceName() { + resourceModel.setResourceName("ResourceName"); + assertEquals("ResourceName", resourceModel.getResourceName()); + } + + @Test + public void testGetSetDataStoreObject() { + resourceModel.setDataStoreObject("DataStoreObject"); + assertEquals("DataStoreObject", resourceModel.getDataStoreObject()); + } + + @Test + public void testGetSetKeyType() { + resourceModel.setKeyType("keyType"); + assertEquals("keyType", resourceModel.getKeyType()); + } + + @Test + public void testToString() { + assertTrue(resourceModel.toString() instanceof String); + } +} |