From 1e162f0f179b73834cf66bd8607e3ac705c47b9c Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Tue, 11 Sep 2018 20:55:46 -0400 Subject: Blueprints Processor Service Add Input, default, mdsal and sdnc db resource processor prototype. Change-Id: I1ad8c4ea5d7cdf5793af23ac52b7152d1a58b762 Issue-ID: CCSDK-548 Signed-off-by: Brinda Santh --- .../core/api/data/BlueprintProcessorData.kt | 21 ++------- .../core/factory/ComponentNodeFactory.kt | 15 +++++-- .../factory/ResourceAssignmentProcessorFactory.kt | 10 +++-- .../execution/JavaScriptExecuteComponent.kt | 45 +++++++++++++++++++ .../services/execution/PythonExecuteComponent.kt | 44 +++++++++++++++++++ .../resolution/ResourceResolutionService.kt | 36 +++++++++++++++- .../DefaultResourceAssignmentProcessor.kt | 23 +++++++--- .../processor/InputResourceAssignmentProcessor.kt | 23 +++++++--- .../processor/MDSALResourceAssignmentProcessor.kt | 48 +++++++++++++++++++++ .../processor/SdncResourceAssignmentProcessor.kt | 50 ++++++++++++++++++++++ .../resolution/ResourceResolutionServiceTest.java | 20 ++++++--- .../mapping/db/resource-assignments-simple.json | 30 ++++++++----- 12 files changed, 310 insertions(+), 55 deletions(-) create mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt create mode 100644 ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt create mode 100644 ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt create mode 100644 ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt (limited to 'ms/blueprintsprocessor/modules') 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 4836cd243..6fed53e6f 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 @@ -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. @@ -21,22 +22,6 @@ import com.fasterxml.jackson.databind.node.ObjectNode import io.swagger.annotations.ApiModelProperty import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment -/* - * 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. - */ - /** * BlueprintProcessorData * @author Brinda Santh @@ -49,7 +34,7 @@ open class ResourceResolutionInput { @get:ApiModelProperty(required=true) lateinit var actionIdentifiers: ActionIdentifiers @get:ApiModelProperty(required=true) - lateinit var resourceAssignments: List + lateinit var resourceAssignments: MutableList @get:ApiModelProperty(required=true ) lateinit var payload: ObjectNode } @@ -62,7 +47,7 @@ open class ResourceResolutionOutput { @get:ApiModelProperty(required=true) lateinit var status: Status @get:ApiModelProperty(required=true) - lateinit var resourceAssignments: List + lateinit var resourceAssignments: MutableList } open class ExecutionServiceInput { 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 f42613cc0..feacbcab7 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 @@ -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. @@ -18,12 +19,15 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.factory import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException -import org.slf4j.Logger -import org.slf4j.LoggerFactory import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware import org.springframework.stereotype.Service +/** + * ComponentNode + * + * @author Brinda Santh + */ interface ComponentNode { @Throws(BluePrintProcessorException::class) @@ -39,8 +43,13 @@ interface ComponentNode { fun reTrigger(context: MutableMap, componentContext: MutableMap) } +/** + * ComponentNodeFactory + * + * @author Brinda Santh + */ @Service -class ComponentNodeFactory : ApplicationContextAware { +open class ComponentNodeFactory : ApplicationContextAware { private val log = EELFManager.getInstance().getLogger(ComponentNodeFactory::class.java) var componentNodes: MutableMap = hashMapOf() 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 8104c104b..01a110d59 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 @@ -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. @@ -18,14 +19,17 @@ package org.onap.ccsdk.apps.blueprintsprocessor.core.factory import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignmentProcessor -import org.slf4j.Logger -import org.slf4j.LoggerFactory import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware import org.springframework.stereotype.Service +/** + * ResourceAssignmentProcessorFactory + * + * @author Brinda Santh + */ @Service -class ResourceAssignmentProcessorFactory : ApplicationContextAware { +open class ResourceAssignmentProcessorFactory : ApplicationContextAware { private val log = EELFManager.getInstance().getLogger(ResourceAssignmentProcessorFactory::class.java) 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 new file mode 100644 index 000000000..427dc873a --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/JavaScriptExecuteComponent.kt @@ -0,0 +1,45 @@ +/* + * 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, componentContext: MutableMap) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(context: MutableMap, componentContext: MutableMap) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun errorHandle(context: MutableMap, componentContext: MutableMap) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun reTrigger(context: MutableMap, componentContext: MutableMap) { + 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 new file mode 100644 index 000000000..59be1f517 --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/execution/PythonExecuteComponent.kt @@ -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.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, componentContext: MutableMap) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun process(context: MutableMap, componentContext: MutableMap) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun errorHandle(context: MutableMap, componentContext: MutableMap) { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + + override fun reTrigger(context: MutableMap, componentContext: MutableMap) { + 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/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt index 14ab7842e..d442c96be 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt @@ -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,9 +17,14 @@ 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.resource.dict.ResourceAssignment +import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils import org.springframework.stereotype.Service /** @@ -28,7 +34,7 @@ import org.springframework.stereotype.Service */ @Service -class ResourceResolutionService { +class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) { fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput { val resourceResolutionOutput = ResourceResolutionOutput() @@ -36,6 +42,10 @@ class ResourceResolutionService { resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments + val context = hashMapOf() + + process(resourceResolutionOutput.resourceAssignments, context) + val status = Status() status.code = 200 status.message = "Success" @@ -43,4 +53,28 @@ class ResourceResolutionService { return resourceResolutionOutput } + + fun process(resourceAssignments: MutableList, context: MutableMap): Unit { + + 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) + } + + } + } + } } 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/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt index 396ca1d79..9580ca49a 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt @@ -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,25 +17,33 @@ 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 +/** + * DefaultResourceAssignmentProcessor + * + * @author Brinda Santh + */ @Service("resource-assignment-processor-default") open class DefaultResourceAssignmentProcessor : ResourceAssignmentProcessor { - override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java) + + override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("Validation Resource Assignments") } override fun process(resourceAssignment: ResourceAssignment, context: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + log.info("Processing Resource Assignments") } - override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("ErrorHandle Resource Assignments") } - override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap) { + 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/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt index 9d0734e6b..05f7d5cdd 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt @@ -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,25 +17,33 @@ 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 +/** + * InputResourceAssignmentProcessor + * + * @author Brinda Santh + */ @Service("resource-assignment-processor-input") open class InputResourceAssignmentProcessor : ResourceAssignmentProcessor { - override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java) + + override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("Validation Resource Assignments") } override fun process(resourceAssignment: ResourceAssignment, context: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + log.info("Processing Resource Assignments") } - override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("ErrorHandle Resource Assignments") } - override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap) { - TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap) { + 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/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt new file mode 100644 index 000000000..9d54cd46a --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt @@ -0,0 +1,48 @@ +/* + * 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.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 + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-mdsal") +open class MDSALResourceAssignmentProcessor : ResourceAssignmentProcessor { + private val log = EELFManager.getInstance().getLogger(MDSALResourceAssignmentProcessor::class.java) + + override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("Validation Resource Assignments") + } + + override fun process(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("Processing Resource Assignments") + } + + override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("ErrorHandle Resource Assignments") + } + + override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap) { + 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/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt new file mode 100644 index 000000000..4b11f580e --- /dev/null +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt @@ -0,0 +1,50 @@ +/* + * 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.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 + * + * @author Brinda Santh + */ +@Service("resource-assignment-processor-db") +open class SdncResourceAssignmentProcessor : ResourceAssignmentProcessor { + + private val log = EELFManager.getInstance().getLogger(SdncResourceAssignmentProcessor::class.java) + + override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("Validation Resource Assignments") + } + + override fun process(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("Processing Resource Assignments") + } + + override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("ErrorHandle Resource Assignments") + } + + override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap) { + log.info("Re Trigger Resource Assignments") + } + +} \ 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 index 633599082..0768c6099 100644 --- 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 @@ -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. @@ -24,6 +25,11 @@ 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; @@ -42,7 +48,9 @@ import java.util.List; * @author Brinda Santh DATE : 8/15/2018 */ @RunWith(SpringRunner.class) -@ContextConfiguration(classes = ResourceResolutionService.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); @@ -57,8 +65,8 @@ public class ResourceResolutionServiceTest { 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); + 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()); @@ -68,13 +76,13 @@ public class ResourceResolutionServiceTest { 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); + 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); + Assert.assertNotNull("failed to populate output", resourceResolutionOutput); } } diff --git a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json index 02ce68be4..ddcf32eed 100644 --- a/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json +++ b/ms/blueprintsprocessor/modules/services/resolution-service/src/test/resources/mapping/db/resource-assignments-simple.json @@ -1,12 +1,22 @@ [ - { - "name": "country", - "input-param": true, - "property": { - "type": "string" - }, - "dictionary-name": "country", - "dictionary-source": "db", - "dependencies": [] - } + { + "name": "country", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "country", + "dictionary-source": "db", + "dependencies": ["state"] + }, + { + "name": "state", + "input-param": true, + "property": { + "type": "string" + }, + "dictionary-name": "state", + "dictionary-source": "input", + "dependencies": [] + } ] -- cgit 1.2.3-korg