aboutsummaryrefslogtreecommitdiffstats
path: root/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin
diff options
context:
space:
mode:
authorMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-11-15 08:36:28 -0500
committerMuthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>2018-11-15 08:36:28 -0500
commitec92866fa0bc8d8cd7a6ce4d5d5fd014d8eacef1 (patch)
treea9f5e6a735f2d87524d1d08ce00efe524e4c53c2 /ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin
parentee9f70f704e978c2119a5e8f38ed98a8a1b70590 (diff)
Blueprints Processor Microservice
Refactor functon module as seperate module project. Change-Id: I392fc62e6dfb6c5f38f478c00e46460d5084f85c Issue-ID: CCSDK-688 Signed-off-by: Muthuramalingam, Brinda Santh(bs2796) <bs2796@att.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin')
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt39
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt79
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt49
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt49
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt48
-rw-r--r--ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt50
6 files changed, 314 insertions, 0 deletions
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
new file mode 100644
index 00000000..ff1a01d5
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionComponent.kt
@@ -0,0 +1,39 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+
+import org.onap.ccsdk.apps.blueprintsprocessor.core.factory.ComponentNode
+import org.springframework.stereotype.Component
+
+@Component("component-resource-resolution")
+open class ResourceResolutionComponent : ComponentNode {
+ override fun validate(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun process(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun errorHandle(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+
+ override fun reTrigger(context: MutableMap<String, Any>, componentContext: MutableMap<String, Any?>) {
+ TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
new file mode 100644
index 00000000..3ee7e41f
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/ResourceResolutionService.kt
@@ -0,0 +1,79 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution
+
+import 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.blueprintsprocessor.core.factory.ResourceAssignmentProcessorFactory
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment
+import org.onap.ccsdk.apps.controllerblueprints.resource.dict.utils.BulkResourceSequencingUtils
+import org.springframework.stereotype.Service
+
+/**
+ * ResourceResolutionService
+ * @author Brinda Santh
+ * 8/14/2018
+ */
+
+@Service
+class ResourceResolutionService(private val resourceAssignmentProcessorFactory: ResourceAssignmentProcessorFactory) {
+
+ fun resolveResource(resourceResolutionInput: ResourceResolutionInput): ResourceResolutionOutput {
+ val resourceResolutionOutput = ResourceResolutionOutput()
+ resourceResolutionOutput.actionIdentifiers = resourceResolutionInput.actionIdentifiers
+ resourceResolutionOutput.commonHeader = resourceResolutionInput.commonHeader
+ resourceResolutionOutput.resourceAssignments = resourceResolutionInput.resourceAssignments
+
+ val context = hashMapOf<String, Any>()
+
+ process(resourceResolutionOutput.resourceAssignments, context)
+
+ val status = Status()
+ status.code = 200
+ status.message = "Success"
+ resourceResolutionOutput.status = status
+
+ return resourceResolutionOutput
+ }
+
+ fun process(resourceAssignments: MutableList<ResourceAssignment>, context: MutableMap<String, Any>): 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("failed to get resource processor for instance name($processorInstanceName) " +
+ "for resource assignment(${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/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..9580ca49
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/DefaultResourceAssignmentProcessor.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.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 {
+ private val log = EELFManager.getInstance().getLogger(DefaultResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Processing Resource Assignments")
+ }
+
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
+ }
+
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..05f7d5cd
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/InputResourceAssignmentProcessor.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onap.ccsdk.apps.blueprintsprocessor.services.resolution.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 {
+ private val log = EELFManager.getInstance().getLogger(InputResourceAssignmentProcessor::class.java)
+
+ override fun validate(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Validation Resource Assignments")
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Processing Resource Assignments")
+ }
+
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
+ }
+
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/MDSALResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..9d54cd46
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/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<String, Any>) {
+ log.info("Validation Resource Assignments")
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Processing Resource Assignments")
+ }
+
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
+ }
+
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
+ }
+} \ No newline at end of file
diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/services/resolution/processor/SdncResourceAssignmentProcessor.kt
new file mode 100644
index 00000000..4b11f580
--- /dev/null
+++ b/ms/blueprintsprocessor/functions/resource-resolution/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<String, Any>) {
+ log.info("Validation Resource Assignments")
+ }
+
+ override fun process(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Processing Resource Assignments")
+ }
+
+ override fun errorHandle(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("ErrorHandle Resource Assignments")
+ }
+
+ override fun reTrigger(resourceAssignment: ResourceAssignment, context: MutableMap<String, Any>) {
+ log.info("Re Trigger Resource Assignments")
+ }
+
+} \ No newline at end of file