~ 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">
<parent>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
<artifactId>functions</artifactId>
<artifactId>jsch</artifactId>
<version>0.1.54</version>
</dependency>
- </dependencies>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
abstract class NetconfComponentFunction : AbstractComponentFunction() {
-
open fun resourceResolutionService(): ResourceResolutionService =
- functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+ functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
// Called from python script
fun initializeNetconfConnection(requirementName: String): NetconfDevice {
return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
}
+ fun getDynamicProperties(key: String): JsonNode {
+ return operationInputs["dynamic-properties"]!!.get(key)
+ }
+
+ fun resolveFromDatabase(resolutionKey: String, artifactName: String): String {
+ return resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
+ }
+
fun resolveAndGenerateMessage(artifactMapping: String, artifactTemplate: String): String {
return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
artifactMapping, artifactTemplate)
fun resolveAndGenerateMessage(artifactPrefix: String): String {
return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
- artifactPrefix)
+ artifactPrefix, mapOf())
}
private fun deviceProperties(requirementName: String): DeviceInfo {
import org.junit.Test
import org.junit.runner.RunWith
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionServiceImpl
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.putJsonElement
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class,
- BluePrintScriptsServiceImpl::class, ComponentFunctionScriptingService::class,
- ComponentNetconfExecutor::class, JsonParserService::class, ResourceResolutionServiceImpl::class])
+@EnableAutoConfiguration
+@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
+@DirtiesContext
@TestPropertySource(properties =
["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf,./../../../../components/scripts/python/ccsdk_blueprints",
- "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"])
+ "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"],
+ locations = ["classpath:application-test.properties"])
class ComponentNetconfExecutorTest {
@Autowired
fun testComponentNetconfExecutor() {
val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json",
- ExecutionServiceInput::class.java)!!
+ ExecutionServiceInput::class.java)!!
val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234",
- "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
+ "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration")
val executionContext = bluePrintRuntimeService.getExecutionContext()
--- /dev/null
+#
+# Copyright © 2017-2018 AT&T Intellectual Property.
+#
+# Modifications Copyright © 2019 IBM, Bell Canada.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
+blueprintsprocessor.db.primary.username=sa
+blueprintsprocessor.db.primary.password=
+blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.primary.hibernateDDLAuto=update
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
+# Controller Blueprints Core Configuration
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
+
+# Python executor
+blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
<description>Blueprints Processor Function - Resource Resolution</description>
<dependencies>
- <!--<dependency>
- <groupId>org.onap.ccsdk.apps.controllerblueprints</groupId>
- <artifactId>db-resources</artifactId>
- <version>${project.version}</version>
- </dependency>-->
+ <dependency>
+ <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId>
+ <artifactId>db-lib</artifactId>
+ </dependency>
<dependency>
<groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
<artifactId>python-executor</artifactId>
-/*\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
-package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution\r
-\r
-import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput\r
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
-import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
-import org.springframework.beans.factory.config.ConfigurableBeanFactory\r
-import org.springframework.context.annotation.Scope\r
-import org.springframework.stereotype.Component\r
-\r
-@Component("component-resource-resolution")\r
-@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)\r
-open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) : AbstractComponentFunction() {\r
-\r
- override fun process(executionRequest: ExecutionServiceInput) {\r
-\r
- val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)\r
-\r
- val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)\r
- ?: throw BluePrintProcessorException("couldn't transform ${artifactPrefixNamesNode.asText()} to string array")\r
-\r
- val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactPrefixNames)\r
-\r
- // Set Output Attributes\r
- bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,\r
- ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, resolvedParamContents.asJsonNode())\r
- }\r
-\r
- override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {\r
- TODO("not implemented") //To change body of created functions use File | Settings | File Templates.\r
- }\r
+/*
+ * 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.resource.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
+import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.springframework.beans.factory.config.ConfigurableBeanFactory
+import org.springframework.context.annotation.Scope
+import org.springframework.stereotype.Component
+
+@Component("component-resource-resolution")
+@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
+open class ResourceResolutionComponent(private val resourceResolutionService: ResourceResolutionService) :
+ AbstractComponentFunction() {
+
+ override fun process(executionRequest: ExecutionServiceInput) {
+
+ val properties: MutableMap<String, Any> = mutableMapOf()
+
+ try {
+ val key = getOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY)
+ val storeResult = getOperationInput(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY] = key.asText()
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] = storeResult.asBoolean()
+ } catch (e: BluePrintProcessorException) {
+ // NoOp - these property aren't mandatory, so don't fail the process if not provided.
+ }
+
+ val artifactPrefixNamesNode = getOperationInput(ResourceResolutionConstants.INPUT_ARTIFACT_PREFIX_NAMES)
+ val artifactPrefixNames = JacksonUtils.getListFromJsonNode(artifactPrefixNamesNode, String::class.java)
+
+ val resolvedParamContents = resourceResolutionService.resolveResources(bluePrintRuntimeService,
+ nodeTemplateName,
+ artifactPrefixNames,
+ properties)
+
+ // Set Output Attributes
+ bluePrintRuntimeService.setNodeTemplateAttributeValue(nodeTemplateName,
+ ResourceResolutionConstants.OUTPUT_ASSIGNMENT_PARAMS, resolvedParamContents.asJsonNode())
+ }
+
+ 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
class ResourceResolutionConstants {
companion object {
const val SERVICE_RESOURCE_RESOLUTION = "resource-resolution-service"
-
const val PREFIX_RESOURCE_RESOLUTION_PROCESSOR = "rr-processor-"
const val INPUT_ARTIFACT_PREFIX_NAMES = "artifact-prefix-names"
const val OUTPUT_ASSIGNMENT_PARAMS = "assignment-params"
const val FILE_NAME_RESOURCE_DEFINITION_TYPES = "resources_definition_types.json"
+ const val RESOURCE_RESOLUTION_INPUT_KEY = "resolution-key";
+ const val RESOURCE_RESOLUTION_INPUT_STORE_RESULT = "store-result";
}
}
\ No newline at end of file
-/*\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.functions.resource.resolution\r
-\r
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor\r
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants\r
-import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException\r
-import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow\r
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService\r
-import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService\r
-import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition\r
-import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils\r
-import org.slf4j.LoggerFactory\r
-import org.springframework.context.ApplicationContext\r
-import org.springframework.stereotype.Service\r
-import java.io.File\r
-\r
-interface ResourceResolutionService {\r
-\r
- fun registeredResourceSources(): List<String>\r
-\r
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
- artifactNames: List<String>): MutableMap<String, String>\r
-\r
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
- artifactPrefix: String): String\r
-\r
- fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
- artifactMapping: String, artifactTemplate: String?): String\r
-\r
- fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,\r
- resourceDictionaries: MutableMap<String, ResourceDefinition>,\r
- resourceAssignments: MutableList<ResourceAssignment>,\r
- identifierName: String)\r
-}\r
-\r
-@Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)\r
-open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext) :\r
- ResourceResolutionService {\r
-\r
- private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)\r
-\r
- override fun registeredResourceSources(): List<String> {\r
- return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)\r
- .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }\r
- .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }\r
- }\r
-\r
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
- artifactNames: List<String>): MutableMap<String, String> {\r
-\r
- val resolvedParams: MutableMap<String, String> = hashMapOf()\r
- artifactNames.forEach { artifactName ->\r
- val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName)\r
- resolvedParams[artifactName] = resolvedContent\r
- }\r
- return resolvedParams\r
- }\r
-\r
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
- artifactPrefix: String): String {\r
-\r
- // Velocity Artifact Definition Name\r
- val artifactTemplate = "$artifactPrefix-template"\r
- // Resource Assignment Artifact Definition Name\r
- val artifactMapping = "$artifactPrefix-mapping"\r
-\r
- return resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactMapping, artifactTemplate)\r
- }\r
-\r
-\r
- override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,\r
- artifactMapping: String, artifactTemplate: String?): String {\r
-\r
- var resolvedContent = ""\r
- log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")\r
-\r
- val identifierName = artifactTemplate ?: "no-template"\r
-\r
- val resourceAssignmentContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)\r
-\r
- val resourceAssignments: MutableList<ResourceAssignment> = JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)\r
- as? MutableList<ResourceAssignment>\r
- ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")\r
-\r
- // Get the Resource Dictionary Name\r
- val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)\r
- .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)\r
- .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DEFINITION_TYPES)\r
-\r
- val resourceDictionaries: MutableMap<String, ResourceDefinition> = JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)\r
- ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")\r
-\r
- // Resolve resources\r
- resolveResourceAssignments(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, identifierName)\r
-\r
- val resolvedParamJsonContent = ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())\r
-\r
- // Check Template is there\r
- if (artifactTemplate != null) {\r
- val templateContent = bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)\r
- resolvedContent = BluePrintTemplateService.generateContent(templateContent, resolvedParamJsonContent)\r
- } else {\r
- resolvedContent = resolvedParamJsonContent\r
- }\r
- return resolvedContent\r
- }\r
-\r
- /**\r
- * Iterate the Batch, get the Resource Assignment, dictionary Name, Look for the Resource definition for the\r
- * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the\r
- * request.\r
- */\r
- override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,\r
- resourceDictionaries: MutableMap<String, ResourceDefinition>,\r
- resourceAssignments: MutableList<ResourceAssignment>,\r
- identifierName: String) {\r
-\r
- val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)\r
- val resourceAssignmentRuntimeService = ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)\r
-\r
- bulkSequenced.map { batchResourceAssignments ->\r
- batchResourceAssignments.filter { it.name != "*" && it.name != "start" }\r
- .forEach { resourceAssignment ->\r
- val dictionaryName = resourceAssignment.dictionaryName\r
- val dictionarySource = resourceAssignment.dictionarySource\r
- /**\r
- * Get the Processor name\r
- */\r
- val processorName = processorName(dictionaryName!!, dictionarySource!!,\r
- resourceDictionaries)\r
-\r
- val resourceAssignmentProcessor = applicationContext.getBean(processorName) as? ResourceAssignmentProcessor\r
- ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +\r
- "for resource assignment(${resourceAssignment.name})")\r
- try {\r
- // Set BluePrint Runtime Service\r
- resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService\r
- // Set Resource Dictionaries\r
- resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries\r
- // Invoke Apply Method\r
- resourceAssignmentProcessor.apply(resourceAssignment)\r
- } catch (e: RuntimeException) {\r
- resourceAssignmentProcessor.recover(e, resourceAssignment)\r
- throw BluePrintProcessorException(e)\r
- }\r
- }\r
- }\r
- }\r
-\r
-\r
- /**\r
- * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can\r
- * derive the default input processor.\r
- */\r
- private fun processorName(dictionaryName: String, dictionarySource: String,\r
- resourceDictionaries: MutableMap<String, ResourceDefinition>): String {\r
- var processorName: String? = null\r
- when (dictionarySource) {\r
- "input" -> {\r
- processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"\r
- }\r
- "default" -> {\r
- processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"\r
- }\r
- else -> {\r
- val resourceDefinition = resourceDictionaries[dictionaryName]\r
- ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")\r
-\r
- val resourceSource = resourceDefinition.sources[dictionarySource]\r
- ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")\r
-\r
- processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR\r
- .plus(resourceSource.type)\r
- }\r
- }\r
- checkNotEmptyOrThrow(processorName,\r
- "couldn't get processor name for resource dictionary definition($dictionaryName) source" +\r
- "($dictionarySource)")\r
-\r
- return processorName\r
-\r
- }\r
-}\r
+/*
+ * 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.functions.resource.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.db.ResourceResolutionResultService
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintTemplateService
+import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceDefinition
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
+import org.slf4j.LoggerFactory
+import org.springframework.context.ApplicationContext
+import org.springframework.stereotype.Service
+import java.io.File
+
+interface ResourceResolutionService {
+
+ fun registeredResourceSources(): List<String>
+
+ fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
+ resolutionKey: String): String
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactNames: List<String>, properties: Map<String, Any>): MutableMap<String, String>
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactPrefix: String, properties: Map<String, Any>): String
+
+ fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactMapping: String, artifactTemplate: String?): String
+
+ fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ identifierName: String)
+}
+
+@Service(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
+open class ResourceResolutionServiceImpl(private var applicationContext: ApplicationContext,
+ private var resolutionResultService: ResourceResolutionResultService) :
+ ResourceResolutionService {
+
+ private val log = LoggerFactory.getLogger(ResourceResolutionService::class.java)
+
+ override fun registeredResourceSources(): List<String> {
+ return applicationContext.getBeanNamesForType(ResourceAssignmentProcessor::class.java)
+ .filter { it.startsWith(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ .map { it.substringAfter(ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR) }
+ }
+
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactNames: List<String>,
+ properties: Map<String, Any>): MutableMap<String, String> {
+
+ val resolvedParams: MutableMap<String, String> = hashMapOf()
+ artifactNames.forEach { artifactName ->
+ val resolvedContent = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactName, properties)
+ resolvedParams[artifactName] = resolvedContent
+ }
+ return resolvedParams
+ }
+
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactPrefix: String, properties: Map<String, Any>): String {
+
+ // Velocity Artifact Definition Name
+ val artifactTemplate = "$artifactPrefix-template"
+ // Resource Assignment Artifact Definition Name
+ val artifactMapping = "$artifactPrefix-mapping"
+
+ val result = resolveResources(bluePrintRuntimeService, nodeTemplateName, artifactMapping, artifactTemplate)
+
+ if (properties.containsKey(ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT)
+ && properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_STORE_RESULT] as Boolean) {
+ resolutionResultService.write(properties, result, bluePrintRuntimeService, artifactPrefix)
+ }
+
+ return result
+ }
+
+ override fun resolveFromDatabase(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactTemplate: String,
+ resolutionKey: String): String {
+ return resolutionResultService.read(bluePrintRuntimeService, artifactTemplate, resolutionKey)
+ }
+
+ override fun resolveResources(bluePrintRuntimeService: BluePrintRuntimeService<*>, nodeTemplateName: String,
+ artifactMapping: String, artifactTemplate: String?): String {
+
+ var resolvedContent = ""
+ log.info("Resolving resource for template artifact($artifactTemplate) with resource assignment artifact($artifactMapping)")
+
+ val identifierName = artifactTemplate ?: "no-template"
+
+ val resourceAssignmentContent =
+ bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactMapping)
+
+ val resourceAssignments: MutableList<ResourceAssignment> =
+ JacksonUtils.getListFromJson(resourceAssignmentContent, ResourceAssignment::class.java)
+ as? MutableList<ResourceAssignment>
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+
+ // Get the Resource Dictionary Name
+ val dictionaryFile = bluePrintRuntimeService.bluePrintContext().rootPath.plus(File.separator)
+ .plus(BluePrintConstants.TOSCA_DEFINITIONS_DIR).plus(File.separator)
+ .plus(ResourceResolutionConstants.FILE_NAME_RESOURCE_DEFINITION_TYPES)
+
+ val resourceDictionaries: MutableMap<String, ResourceDefinition> =
+ JacksonUtils.getMapFromFile(dictionaryFile, ResourceDefinition::class.java)
+ ?: throw BluePrintProcessorException("couldn't get Dictionary Definitions")
+
+ // Resolve resources
+ resolveResourceAssignments(bluePrintRuntimeService, resourceDictionaries, resourceAssignments, identifierName)
+
+ val resolvedParamJsonContent =
+ ResourceAssignmentUtils.generateResourceDataForAssignments(resourceAssignments.toList())
+
+ // Check Template is there
+ if (artifactTemplate != null) {
+ val templateContent =
+ bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactTemplate)
+ resolvedContent = BluePrintTemplateService.generateContent(templateContent, resolvedParamJsonContent)
+ } else {
+ resolvedContent = resolvedParamJsonContent
+ }
+
+ return resolvedContent
+ }
+
+ /**
+ * Iterate the Batch, get the Resource Assignment, dictionary Name, Look for the Resource definition for the
+ * name, then get the type of the Resource Definition, Get the instance for the Resource Type and process the
+ * request.
+ */
+ override fun resolveResourceAssignments(blueprintRuntimeService: BluePrintRuntimeService<*>,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>,
+ resourceAssignments: MutableList<ResourceAssignment>,
+ identifierName: String) {
+
+ val bulkSequenced = BulkResourceSequencingUtils.process(resourceAssignments)
+ val resourceAssignmentRuntimeService =
+ ResourceAssignmentUtils.transformToRARuntimeService(blueprintRuntimeService, identifierName)
+
+ bulkSequenced.map { batchResourceAssignments ->
+ batchResourceAssignments.filter { it.name != "*" && it.name != "start" }
+ .forEach { resourceAssignment ->
+ val dictionaryName = resourceAssignment.dictionaryName
+ val dictionarySource = resourceAssignment.dictionarySource
+ /**
+ * Get the Processor name
+ */
+ val processorName = processorName(dictionaryName!!, dictionarySource!!,
+ resourceDictionaries)
+
+ val resourceAssignmentProcessor =
+ applicationContext.getBean(processorName) as? ResourceAssignmentProcessor
+ ?: throw BluePrintProcessorException("failed to get resource processor for name($processorName) " +
+ "for resource assignment(${resourceAssignment.name})")
+ try {
+ // Set BluePrint Runtime Service
+ resourceAssignmentProcessor.raRuntimeService = resourceAssignmentRuntimeService
+ // Set Resource Dictionaries
+ resourceAssignmentProcessor.resourceDictionaries = resourceDictionaries
+ // Invoke Apply Method
+ resourceAssignmentProcessor.apply(resourceAssignment)
+ } catch (e: RuntimeException) {
+ resourceAssignmentProcessor.recover(e, resourceAssignment)
+ throw BluePrintProcessorException(e)
+ }
+ }
+ }
+ }
+
+
+ /**
+ * If the Source instance is "input", then it is not mandatory to have source Resource Definition, So it can
+ * derive the default input processor.
+ */
+ private fun processorName(dictionaryName: String, dictionarySource: String,
+ resourceDictionaries: MutableMap<String, ResourceDefinition>): String {
+ var processorName: String? = null
+ when (dictionarySource) {
+ "input" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-input"
+ }
+ "default" -> {
+ processorName = "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-default"
+ }
+ else -> {
+ val resourceDefinition = resourceDictionaries[dictionaryName]
+ ?: throw BluePrintProcessorException("couldn't get resource dictionary definition for $dictionaryName")
+
+ val resourceSource = resourceDefinition.sources[dictionarySource]
+ ?: throw BluePrintProcessorException("couldn't get resource definition $dictionaryName source($dictionarySource)")
+
+ processorName = ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR
+ .plus(resourceSource.type)
+ }
+ }
+ checkNotEmptyOrThrow(processorName,
+ "couldn't get processor name for resource dictionary definition($dictionaryName) source" +
+ "($dictionarySource)")
+
+ return processorName
+
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.db
+
+import org.springframework.data.jpa.repository.JpaRepository
+
+interface ResourceResolutionRepository : JpaRepository<ResourceResolutionResult, String> {
+
+ fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(key: String, blueprintName: String?,
+ blueprintVersion: String?,
+ artifactName: String): ResourceResolutionResult
+}
--- /dev/null
+/*
+ * Copyright © 2019 Bell Canada
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.db
+
+import com.fasterxml.jackson.annotation.JsonFormat
+import org.hibernate.annotations.Proxy
+import org.springframework.data.annotation.LastModifiedDate
+import org.springframework.data.jpa.domain.support.AuditingEntityListener
+import java.io.Serializable
+import java.util.*
+import javax.persistence.Column
+import javax.persistence.Entity
+import javax.persistence.EntityListeners
+import javax.persistence.Id
+import javax.persistence.Lob
+import javax.persistence.Table
+import javax.persistence.Temporal
+import javax.persistence.TemporalType
+
+@EntityListeners(AuditingEntityListener::class)
+@Entity
+@Table(name = "RESOURCE_RESOLUTION_RESULT")
+@Proxy(lazy = false)
+class ResourceResolutionResult : Serializable {
+
+ @Id
+ @Column(name = "resource_resolution_result_id")
+ var id: String? = null
+
+ @Column(name = "resolution_key", nullable = false)
+ var resolutionKey: String? = null
+
+ @Column(name = "blueprint_name", nullable = false)
+ var blueprintName: String? = null
+
+ @Column(name = "blueprint_version", nullable = false)
+ var blueprintVersion: String? = null
+
+ @Column(name = "artifact_name", nullable = false)
+ var artifactName: String? = null
+
+ @Lob
+ @Column(name = "result", nullable = false)
+ var result: String? = null
+
+ @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
+ @LastModifiedDate
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "creation_date")
+ var createdDate = Date()
+
+ companion object {
+ private const val serialVersionUID = 1L
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (C) 2019 Bell Canada.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.db
+
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintRuntimeService
+import org.springframework.dao.DataIntegrityViolationException
+import org.springframework.stereotype.Service
+import java.util.*
+
+@Service
+class ResourceResolutionResultService(private val resourceResolutionRepository: ResourceResolutionRepository) {
+
+ fun write(properties: Map<String, Any>, result: String, bluePrintRuntimeService: BluePrintRuntimeService<*>,
+ artifactPrefix: String) {
+
+ val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
+
+ val resourceResolutionResult = ResourceResolutionResult()
+ resourceResolutionResult.id = UUID.randomUUID().toString()
+ resourceResolutionResult.artifactName = artifactPrefix
+ resourceResolutionResult.blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
+ resourceResolutionResult.blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
+ resourceResolutionResult.resolutionKey =
+ properties[ResourceResolutionConstants.RESOURCE_RESOLUTION_INPUT_KEY].toString()
+ resourceResolutionResult.result = result
+
+ try {
+ resourceResolutionRepository.saveAndFlush(resourceResolutionResult)
+ } catch (ex: DataIntegrityViolationException) {
+ throw BluePrintException("Failed to store resource resolution result.", ex)
+ }
+ }
+
+ fun read(bluePrintRuntimeService: BluePrintRuntimeService<*>, artifactPrefix: String,
+ resolutionKey: String): String {
+
+ val metadata = bluePrintRuntimeService.bluePrintContext().metadata!!
+
+ val blueprintVersion = metadata[BluePrintConstants.METADATA_TEMPLATE_VERSION]
+ val blueprintName = metadata[BluePrintConstants.METADATA_TEMPLATE_NAME]
+
+ return resourceResolutionRepository.findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactName(
+ resolutionKey,
+ blueprintName,
+ blueprintVersion,
+ artifactPrefix).result!!
+ }
+}
\ No newline at end of file
import org.onap.ccsdk.apps.blueprintsprocessor.core.utils.PayloadUtils
import org.onap.ccsdk.apps.blueprintsprocessor.db.BluePrintDBLibConfiguration
import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.DBLibGenericService
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.*
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.CapabilityResourceResolutionProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.DatabaseResourceAssignmentProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.DefaultResourceResolutionProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.InputResourceResolutionProcessor
+import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor.RestResourceResolutionProcessor
import org.onap.ccsdk.apps.controllerblueprints.core.config.BluePrintLoadConfiguration
import org.onap.ccsdk.apps.controllerblueprints.core.utils.BluePrintMetadataUtils
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
// Prepare Inputs
PayloadUtils.prepareInputsFromWorkflowPayload(bluePrintRuntimeService, executionServiceInput.payload, "resource-assignment")
- resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig")
+ resourceResolutionService.resolveResources(bluePrintRuntimeService, "resource-assignment", "baseconfig", mapOf())
}
<groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId>
<artifactId>resource-resolution</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor
+import com.fasterxml.jackson.databind.JsonNode
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
import org.onap.ccsdk.apps.blueprintsprocessor.rest.RestLibConstants
return bluePrintRestLibPropertyService().blueprintWebClientService(selector)
}
+ fun getDynamicProperties(key: String): JsonNode {
+ return operationInputs["dynamic-properties"]!!.get(key)
+ }
+
+ fun resolveFromDatabase(resolutionKey: String, artifactName: String): String {
+ return resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
+ }
+
fun generateMessage(artifactName: String): String {
return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
}
fun resolveAndGenerateMessage(artifactPrefix: String): String {
return resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
- artifactPrefix)
+ artifactPrefix, mapOf())
}
}
\ No newline at end of file
import io.mockk.mockk
import org.junit.Test
import org.junit.runner.RunWith
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties
-import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ActionIdentifiers
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.CommonHeader
import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput
-import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.ResourceResolutionServiceImpl
-import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.ComponentFunctionScriptingService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.BlueprintJythonService
-import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.scripts.PythonExecutorProperty
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonNode
import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive
import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext
import org.onap.ccsdk.apps.controllerblueprints.core.service.DefaultBluePrintRuntimeService
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
-import org.onap.ccsdk.apps.controllerblueprints.scripts.BluePrintScriptsServiceImpl
import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.test.context.ContextConfiguration
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration
+import org.springframework.context.annotation.ComponentScan
+import org.springframework.test.annotation.DirtiesContext
import org.springframework.test.context.TestPropertySource
import org.springframework.test.context.junit4.SpringRunner
import kotlin.test.assertNotNull
-
@RunWith(SpringRunner::class)
-@ContextConfiguration(classes = [RestconfExecutorConfiguration::class, ComponentRestconfExecutor::class,
- BlueprintJythonService::class, PythonExecutorProperty::class, BluePrintRestLibPropertyService::class,
- BlueprintPropertyConfiguration::class, BluePrintProperties::class, BluePrintScriptsServiceImpl::class,
- ResourceResolutionServiceImpl::class, ComponentFunctionScriptingService::class])
+@EnableAutoConfiguration
+@ComponentScan(basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor", "org.onap.ccsdk.apps.controllerblueprints"])
+@DirtiesContext
@TestPropertySource(properties =
["server.port=9111",
"blueprintsprocessor.restconfEnabled=true",
"blueprintsprocessor.restclient.odlPrimary.type=basic-auth",
"blueprintsprocessor.restclient.odlPrimary.url=http://127.0.0.1:9111",
"blueprintsprocessor.restclient.odlPrimary.userId=sampleuser",
- "blueprintsprocessor.restclient.odlPrimary.token=sampletoken"])
+ "blueprintsprocessor.restclient.odlPrimary.token=sampletoken"],
+ locations = ["classpath:application-test.properties"])
class ComponentRestconfExecutorTest {
@Autowired
operationInputs[BluePrintConstants.PROPERTY_CURRENT_INTERFACE] = "interfaceName".asJsonPrimitive()
operationInputs[BluePrintConstants.PROPERTY_CURRENT_OPERATION] = "operationName".asJsonPrimitive()
operationInputs[ComponentRestconfExecutor.SCRIPT_TYPE] = BluePrintConstants.SCRIPT_INTERNAL.asJsonPrimitive()
- operationInputs[ComponentRestconfExecutor.SCRIPT_CLASS_REFERENCE] = "InternalSimpleRestconf_cba\$TestRestconfConfigure".asJsonPrimitive()
+ operationInputs[ComponentRestconfExecutor.SCRIPT_CLASS_REFERENCE] =
+ "InternalSimpleRestconf_cba\$TestRestconfConfigure".asJsonPrimitive()
operationInputs[ComponentRestconfExecutor.INSTANCE_DEPENDENCIES] = JacksonUtils.jsonNode("[]") as ArrayNode
val blueprintContext = mockk<BluePrintContext>()
every { bluePrintRuntime.get("sample-step-step-inputs") } returns operationInputs.asJsonNode()
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationInputs("activate-restconf",
- "interfaceName", "operationName")
+ "interfaceName", "operationName")
} returns operationInputs
val operationOutputs = hashMapOf<String, JsonNode>()
every {
bluePrintRuntime.resolveNodeTemplateInterfaceOperationOutputs("activate-restconf",
- "interfaceName", "operationName")
+ "interfaceName", "operationName")
} returns operationOutputs
every { bluePrintRuntime.put("sample-step-step-outputs", any()) } returns Unit
--- /dev/null
+#
+# Copyright © 2017-2018 AT&T Intellectual Property.
+#
+# Modifications Copyright © 2019 IBM, Bell Canada.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+blueprintsprocessor.db.primary.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
+blueprintsprocessor.db.primary.username=sa
+blueprintsprocessor.db.primary.password=
+blueprintsprocessor.db.primary.driverClassName=org.h2.Driver
+blueprintsprocessor.db.primary.hibernateHbm2ddlAuto=create-drop
+blueprintsprocessor.db.primary.hibernateDDLAuto=update
+blueprintsprocessor.db.primary.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
+blueprintsprocessor.db.primary.hibernateDialect=org.hibernate.dialect.H2Dialect
+# Controller Blueprints Core Configuration
+blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
+blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
+
+# Python executor
+blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
+blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
@Configuration
@EnableJpaRepositories(
- basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor.db.primary"],
- entityManagerFactoryRef = "primaryEntityManager",
- transactionManagerRef = "primaryTransactionManager"
+ basePackages = ["org.onap.ccsdk.apps.blueprintsprocessor.*"],
+ entityManagerFactoryRef = "primaryEntityManager",
+ transactionManagerRef = "primaryTransactionManager"
)
open class PrimaryDatabaseConfiguration(private val primaryDataSourceProperties: PrimaryDataSourceProperties) {
val log = LoggerFactory.getLogger(PrimaryDatabaseConfiguration::class.java)!!
open fun primaryEntityManager(): LocalContainerEntityManagerFactoryBean {
val em = LocalContainerEntityManagerFactoryBean()
em.dataSource = primaryDataSource()
- em.setPackagesToScan("org.onap.ccsdk.apps.blueprintsprocessor.db.primary")
-
- val vendorAdapter = HibernateJpaVendorAdapter()
- em.jpaVendorAdapter = vendorAdapter
+ em.setPackagesToScan("org.onap.ccsdk.apps.blueprintsprocessor.*")
+ em.jpaVendorAdapter = HibernateJpaVendorAdapter()
val properties = HashMap<String, Any>()
properties["hibernate.hbm2ddl.auto"] = primaryDataSourceProperties.hibernateHbm2ddlAuto
properties["hibernate.dialect"] = primaryDataSourceProperties.hibernateDialect