import org.junit.Test;\r
import org.junit.runner.RunWith;\r
import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.boot.test.context.SpringBootTest;\r
import org.springframework.context.ApplicationContext;\r
import org.springframework.test.context.ContextConfiguration;\r
import org.springframework.test.context.junit4.SpringRunner;\r
\r
@RunWith(SpringRunner.class)\r
@ContextConfiguration(classes = BlueprintProcessorApplication.class)\r
-//@SpringBootTest(classes = BlueprintProcessorApplication.class,\r
-// webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\r
+@SpringBootTest(classes = BlueprintProcessorApplication.class,\r
+ webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)\r
public class BlueprintProcessorApplicationTest {\r
\r
@Autowired\r
}\r
\r
@Test\r
- public void testSample(){\r
+ public void testSample() {\r
Assert.assertNotNull("Failed to create Application Context ", context);\r
}\r
\r
--- /dev/null
+#
+# 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.
+#
+blueprintsprocessor.blueprint-deploy-path=/opt
+blueprintsprocessor.blueprint-archive-path=/opt
\ No newline at end of file
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")
+ metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, "activate-jython")
+
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-jython")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "JythonExecutorComponent")
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process")
+ metaData.putJsonElement("activate-jython-step-inputs", stepMetaData)
executionServiceInput.metadata = metaData
componentJythonExecutor.apply(executionServiceInput)
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
* @author Brinda Santh DATE : 8/15/2018
*/
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [ResourceResolutionService::class, ResourceAssignmentProcessorFactory::class,
+@ContextConfiguration(classes = [ResourceResolutionService::class,
InputResourceAssignmentProcessor::class, DefaultResourceAssignmentProcessor::class,
DataBaseResourceAssignmentProcessor::class, SimpleRestResourceAssignmentProcessor::class])
class ResourceResolutionServiceTest {
--- /dev/null
+/*
+ * 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
+
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.context.annotation.Configuration
+
+
+@Configuration
+open class BluePrintCoreConfiguration {
+
+ @Value("\${blueprintsprocessor.blueprint-deploy-path}")
+ lateinit var deployPath: String
+
+ @Value("\${blueprintsprocessor.blueprint-archive-path}")
+ lateinit var archivePath: String
+
+}
\ No newline at end of file
+++ /dev/null
-/*\r
- * Copyright © 2017-2018 AT&T Intellectual Property.\r
- * Modifications Copyright © 2018 IBM.\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-package org.onap.ccsdk.apps.blueprintsprocessor.core.factory\r
-\r
-import com.att.eelf.configuration.EELFManager\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor\r
-import org.springframework.context.ApplicationContext\r
-import org.springframework.context.ApplicationContextAware\r
-import org.springframework.context.annotation.Configuration\r
-\r
-/**\r
- * ResourceAssignmentProcessorFactory\r
- *\r
- * @author Brinda Santh\r
- */\r
-@Configuration\r
-open class ResourceAssignmentProcessorFactory : ApplicationContextAware {\r
-\r
- private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java)\r
-\r
- var resourceAssignmentProcessors: MutableMap<String, ResourceAssignmentProcessor> = hashMapOf()\r
-\r
- fun getInstance(instanceName: String): ResourceAssignmentProcessor? {\r
- log.trace("looking for Resource Assignment Processor : {}", instanceName)\r
- return resourceAssignmentProcessors.get(instanceName)\r
- }\r
-\r
- fun injectInstance(instanceName: String, resourceAssignmentProcessor: ResourceAssignmentProcessor) {\r
- this.resourceAssignmentProcessors[instanceName] = resourceAssignmentProcessor\r
- }\r
-\r
- override fun setApplicationContext(context: ApplicationContext) {\r
- resourceAssignmentProcessors = context.getBeansOfType(ResourceAssignmentProcessor::class.java)\r
- log.info("Injected Resource Assignment Processor : {}", resourceAssignmentProcessors)\r
- }\r
-}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.interfaces
+
+interface BluePrintCatalogService {
+ /**
+ * Get the Blueprint from Data Base and Download it under working directory and return the path path
+ */
+ fun prepareBluePrint(name: String, version: String): String
+}
\ No newline at end of file
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</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>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito2</artifactId>
+ </dependency>
</dependencies>
</project>
--- /dev/null
+/*
+ * 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.selfservice.api
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintCoreConfiguration
+import org.onap.ccsdk.apps.blueprintsprocessor.core.interfaces.BluePrintCatalogService
+import org.springframework.stereotype.Service
+import java.io.File
+
+@Service
+class BluePrintCatalogServiceImpl(private val bluePrintCoreConfiguration: BluePrintCoreConfiguration) : BluePrintCatalogService {
+
+ override fun prepareBluePrint(name: String, version: String): String {
+ //TODO("Get the Blueprint from the DB")
+ return bluePrintCoreConfiguration.deployPath.plus(File.separator).plus(name).plus(File.separator).plus(version)
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.selfservice.api
+
+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.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.slf4j.LoggerFactory
+import org.springframework.stereotype.Service
+
+@Service
+class ExecutionServiceHandler(private val bluePrintCatalogService: BluePrintCatalogService,
+ private val blueprintDGExecutionService: BlueprintDGExecutionService) {
+
+ private val log = LoggerFactory.getLogger(ExecutionServiceHandler::class.toString())
+
+ fun process(executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+ val requestId = executionServiceInput.commonHeader.requestId
+ log.info("processing request id $requestId")
+
+ val actionIdentifiers = executionServiceInput.actionIdentifiers
+
+ val blueprintName = actionIdentifiers.blueprintName
+ val blueprintVersion = actionIdentifiers.blueprintVersion
+
+ val basePath = bluePrintCatalogService.prepareBluePrint(blueprintName, blueprintVersion)
+ log.info("blueprint base path $basePath")
+
+ val blueprintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime(requestId, basePath)
+
+ return blueprintDGExecutionService.executeDirectedGraph(blueprintRuntimeService, executionServiceInput)
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.selfservice.api
+
+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.selfservice.api.mock.MockBluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.selfservice.api.mock.MockBlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.test.context.ContextConfiguration
+import org.springframework.test.context.junit4.SpringRunner
+
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [MockBluePrintCatalogService::class,
+ MockBlueprintDGExecutionService::class, ExecutionServiceHandler::class])
+class ExecutionServiceHandlerTest {
+
+ @Autowired
+ lateinit var executionServiceHandler: ExecutionServiceHandler
+
+ @Test
+ fun testProcess() {
+ 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)!!
+ executionServiceHandler.process(executionServiceInput)
+
+ }
+
+}
+
+
--- /dev/null
+/*
+ * 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.selfservice.api.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.core.interfaces.BluePrintCatalogService
+import org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.BlueprintDGExecutionService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.stereotype.Service
+import kotlin.test.assertNotNull
+
+@Service
+class MockBlueprintDGExecutionService : BlueprintDGExecutionService {
+ override fun executeDirectedGraph(bluePrintRuntimeService: BluePrintRuntimeService<*>, executionServiceInput: ExecutionServiceInput): ExecutionServiceOutput {
+
+ assertNotNull(executionServiceInput, "failed to get executionServiceInput")
+
+ val executionServiceOutput = ExecutionServiceOutput()
+ executionServiceOutput.commonHeader = executionServiceInput.commonHeader
+ return executionServiceOutput
+ }
+}
+
+@Service
+class MockBluePrintCatalogService : BluePrintCatalogService {
+ override fun prepareBluePrint(name: String, version: String): String {
+ assertNotNull(name, "failed to get blueprint Name")
+ assertNotNull(version, "failed to get blueprint version")
+ return "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration"
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "activate",
+ "mode": "sync"
+ },
+ "payload": {
+ "activate-request": {
+ "activate-properties": {
+ "request-id": "1234",
+ "action-name": "activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ },
+ "metadata": {
+ "current-node-template": "resource-assignment-py",
+ "current-step": "resource-assignment-py",
+ "current-operation": "process",
+ "current-interface": "ResourceAssignmentComponent"
+ }
+}
\ No newline at end of file
--- /dev/null
+<!--\r
+ ~ Copyright © 2017-2018 AT&T Intellectual Property.\r
+ ~\r
+ ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+ ~ you may not use this file except in compliance with the License.\r
+ ~ You may obtain a copy of the License at\r
+ ~\r
+ ~ http://www.apache.org/licenses/LICENSE-2.0\r
+ ~\r
+ ~ Unless required by applicable law or agreed to in writing, software\r
+ ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ ~ See the License for the specific language governing permissions and\r
+ ~ limitations under the License.\r
+ -->\r
+\r
+<configuration>\r
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+ <!-- encoders are assigned the type\r
+ ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->\r
+ <encoder>\r
+ <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>\r
+ </encoder>\r
+ </appender>\r
+\r
+\r
+ <logger name="org.springframework" level="warn"/>\r
+ <logger name="org.hibernate" level="info"/>\r
+ <logger name="org.onap.ccsdk.apps.blueprintsprocessor" level="info"/>\r
+\r
+ <root level="warn">\r
+ <appender-ref ref="STDOUT"/>\r
+ </root>\r
+\r
+</configuration>\r
package org.onap.ccsdk.apps.blueprintsprocessor.services.execution\r
\r
\r
+import com.fasterxml.jackson.databind.JsonNode\r
+import com.fasterxml.jackson.databind.node.JsonNodeFactory\r
+import com.fasterxml.jackson.databind.node.NullNode\r
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput\r
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.Status\r
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
import org.onap.ccsdk.apps.controllerblueprints.core.getAsString\r
import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BlueprintFunctionNode\r
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement\r
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
import org.slf4j.LoggerFactory\r
\r
* @author Brinda Santh\r
*/\r
abstract class AbstractComponentFunction : BlueprintFunctionNode<ExecutionServiceInput, ExecutionServiceOutput> {\r
+ @Transient\r
private val log = LoggerFactory.getLogger(AbstractComponentFunction::class.java)\r
\r
var executionServiceInput: ExecutionServiceInput? = null\r
var interfaceName: String = ""\r
var operationName: String = ""\r
var nodeTemplateName: String = ""\r
+ var operationInputs: MutableMap<String, JsonNode> = hashMapOf()\r
\r
\r
override fun prepareRequest(executionServiceInput: ExecutionServiceInput): ExecutionServiceInput {\r
+ checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
\r
- this.executionServiceInput = this.executionServiceInput\r
+ this.executionServiceInput = executionServiceInput\r
\r
processId = executionServiceInput.commonHeader.requestId\r
workflowName = executionServiceInput.actionIdentifiers.actionName\r
\r
val metadata = executionServiceInput.metadata\r
stepName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_STEP)\r
- nodeTemplateName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)\r
- interfaceName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)\r
- operationName = metadata.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
+ log.info("preparing request id($processId) for workflow($workflowName) step($stepName)")\r
+\r
+ val operationInputs = metadata.get("$stepName-step-inputs") ?: JsonNodeFactory.instance.objectNode()\r
+\r
+ operationInputs.fields().forEach {\r
+ this.operationInputs[it.key] = it.value\r
+ }\r
+\r
+ nodeTemplateName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE)\r
+ interfaceName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_INTERFACE)\r
+ operationName = this.operationInputs.getAsString(BluePrintConstants.PROPERTY_CURRENT_OPERATION)\r
+\r
+\r
+ val operationResolvedProperties = bluePrintRuntimeService!!.resolveNodeTemplateInterfaceOperationInputs(nodeTemplateName, interfaceName, operationName)\r
+\r
+ this.operationInputs.putAll(operationResolvedProperties)\r
+\r
\r
- checkNotNull(bluePrintRuntimeService) { "failed to prepare blueprint runtime" }\r
\r
- log.info("prepareRequest...")\r
return executionServiceInput\r
}\r
\r
override fun prepareResponse(): ExecutionServiceOutput {\r
log.info("Preparing Response...")\r
+ executionServiceOutput.commonHeader = executionServiceInput!!.commonHeader\r
+\r
+ // Resolve the Output Expression\r
+ val operationResolvedProperties = bluePrintRuntimeService!!\r
+ .resolveNodeTemplateInterfaceOperationOutputs(nodeTemplateName, interfaceName, operationName)\r
+\r
+ val metadata = executionServiceOutput.metadata\r
+ metadata.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, stepName)\r
+ metadata.putJsonElement("$stepName-step-outputs", operationResolvedProperties)\r
+\r
+ // Populate Status\r
+ val status = Status()\r
+ status.eventType = "EVENT-COMPONENT-EXECUTED"\r
+ status.code = 200\r
+ status.message = BluePrintConstants.STATUS_SUCCESS\r
+ executionServiceOutput.status = status\r
return this.executionServiceOutput\r
}\r
\r
process(executionServiceInput)\r
return prepareResponse()\r
}\r
+\r
+ fun getOperationInput(key: String): JsonNode {\r
+ return operationInputs.get(key) ?: NullNode.instance\r
+ }\r
}
\ No newline at end of file
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
WorkflowServiceConstants.ARTIFACT_TYPE_DIRECTED_GRAPH)
// Populate the DG Path
- val dgFilePath = bluePrintRuntimeService.getAsString(BluePrintConstants.PROPERTY_BLUEPRINT_BASE_PATH)
- .plus(File.separator).plus(artifactDefinition.file)
+ val dgFilePath = bluePrintContext.rootPath.plus(File.separator).plus(artifactDefinition.file)
log.info("Executing directed graph ($dgFilePath)")
// Create DG instance
val graph = SvcGraphUtils.getSvcGraphFromFile(dgFilePath)
+ // Assign Workflow inputs
+ val input = executionServiceInput.payload.get("$workflowName-request")
+ bluePrintRuntimeService.assignWorkflowInputs(workflowName, input)
+
// Execute the DG
return blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput) as ExecutionServiceOutput
package org.onap.ccsdk.apps.blueprintsprocessor.services.workflow.executor
+import com.fasterxml.jackson.databind.JsonNode
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.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
import org.onap.ccsdk.sli.core.sli.SvcLogicContext
import org.onap.ccsdk.sli.core.sli.SvcLogicException
import org.onap.ccsdk.sli.core.sli.SvcLogicNode
// 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)")
+ val interfaceName = blueprintContext.nodeTemplateFirstInterfaceName(nodeTemplateName)
+
+ val operationName = blueprintContext.nodeTemplateFirstInterfaceFirstOperationName(nodeTemplateName)
+
+ log.info("executing node template($nodeTemplateName) component($componentName) interface($interfaceName) operation($operationName)")
// Get the Component Instance
val plugin = this.getComponentFunction(componentName)
// Set the Blueprint Service
plugin.bluePrintRuntimeService = ctx.getBluePrintService()
val executionInput = ctx.getRequest() as ExecutionServiceInput
+
+ val metaData = executionInput.metadata
+ metaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_STEP, nodeTemplateName)
+ // Populate Step Meta Data
+ val stepMetaData: MutableMap<String, JsonNode> = hashMapOf()
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, nodeTemplateName)
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, interfaceName)
+ stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, operationName)
+
+ metaData.putJsonElement("$nodeTemplateName-step-inputs", stepMetaData)
// Get the Request from the Context and Set to the Function Input and Invoke the function
val executionOutput = plugin.apply(executionInput)
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)!!
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
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
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
+ lateinit var blueprintDGExecutionService: BlueprintDGExecutionService
@Test
fun testExecuteGraphWithSingleComponent() {
- val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/one-component.xml")
- blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/resource-assignment-input.json", ExecutionServiceInput::class.java)!!
+
+
+ blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
}
@Test
fun testExecuteGraphWithMultipleComponents() {
- val graph = SvcGraphUtils.getSvcGraphFromClassPathFile("service-logic/two-component.xml")
- blueprintSvcLogicService.execute(graph, bluePrintRuntimeService, executionServiceInput)
+
+ val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
+ "./../../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration")
+
+ val executionServiceInput = JacksonUtils.readValueFromClassPathFile("execution-input/assign-activate-input.json", ExecutionServiceInput::class.java)!!
+
+ blueprintDGExecutionService.executeDirectedGraph(bluePrintRuntimeService, executionServiceInput)
}
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.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
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"])
+ @Bean(name = ["component-resource-assignment", "component-netconf-executor", "component-jython-executor"])
open fun createComponentFunction(): AbstractComponentFunction {
return MockComponentFunction()
}
class MockComponentFunction : AbstractComponentFunction() {
- private val log = LoggerFactory.getLogger(ComponentExecuteNodeExecutor::class.java)
+ private val log = LoggerFactory.getLogger(MockComponentFunction::class.java)
override fun process(executionRequest: ExecutionServiceInput) {
- log.info("Processing component..")
+ log.info("Processing component : ${operationInputs}")
- this.executionServiceOutput = ExecutionServiceOutput()
+ bluePrintRuntimeService!!.setNodeTemplateAttributeValue(nodeTemplateName,
+ "assignment-params", "params".asJsonPrimitive())
}
override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {
--- /dev/null
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "assign-activate",
+ "mode": "sync"
+ },
+ "payload": {
+ "assign-activate-request": {
+ "assign-activate-properties": {
+ "request-id": "1234",
+ "action-name": "assign-activate",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-{
- "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
--- /dev/null
+{
+ "commonHeader": {
+ "originatorId": "System",
+ "requestId": "1234",
+ "subRequestId": "1234-12234"
+ },
+ "actionIdentifiers": {
+ "blueprintName": "baseconfiguration",
+ "blueprintVersion": "1.0.0",
+ "actionName": "resource-assignment",
+ "mode": "sync"
+ },
+ "payload": {
+ "resource-assignment-request": {
+ "resource-assignment-properties": {
+ "request-id": "1234",
+ "action-name": "resource-assignment",
+ "scope-type": "vnf-type",
+ "hostname": "localhost"
+ }
+ }
+ }
+}
\ No newline at end of file
+++ /dev/null
-<!--
- ~ 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
+++ /dev/null
-<!--
- ~ 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