5e0b4a11754b1bf4f0af4ab2d55abf2f902372fe
[ccsdk/cds.git] / ms / blueprintsprocessor / functions / netconf-executor / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / functions / netconf / executor / NetconfComponentFunction.kt
1 /*
2  *  Copyright © 2018-2019 IBM, Bell Canada.
3  *  Modifications Copyright © 2019 IBM.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  */
17
18 package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor
19
20 import kotlinx.coroutines.runBlocking
21 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants
22 import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionService
23 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
24
25 @Deprecated("Methods defined as extension function of AbstractComponentFunction")
26 abstract class NetconfComponentFunction : AbstractScriptComponentFunction() {
27
28     @Deprecated(" Use resourceResolutionService method directly",
29             replaceWith = ReplaceWith("resourceResolutionService()",
30                     "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resourceResolutionService"))
31     open fun resourceResolutionService(): ResourceResolutionService =
32             functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
33
34     // Called from python script
35     @Deprecated(" Use netconfDeviceInfo method directly",
36             replaceWith = ReplaceWith("netconfDeviceInfo(requirementName)",
37                     "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.netconfDeviceInfo"))
38     fun initializeNetconfConnection(requirementName: String): NetconfDevice {
39         val deviceInfo = netconfDeviceInfo(requirementName)
40         return NetconfDevice(deviceInfo)
41     }
42
43     @Deprecated(" Use artifactContent method directly",
44             replaceWith = ReplaceWith("artifactContent(artifactName)",
45                     "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.artifactContent"))
46     fun generateMessage(artifactName: String): String {
47         return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
48     }
49
50     @Deprecated(" Use storedContentFromResolvedArtifact method directly",
51             replaceWith = ReplaceWith("storedContentFromResolvedArtifact(resolutionKey, artifactName)",
52                     "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifact"))
53     fun resolveFromDatabase(resolutionKey: String, artifactName: String): String = runBlocking {
54         resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
55     }
56
57     @Deprecated(" Use contentFromResolvedArtifact method directly",
58             replaceWith = ReplaceWith("resolveAndGenerateMessage(artifactPrefix)",
59                     "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resolveAndGenerateMessage"))
60     fun resolveAndGenerateMessage(artifactPrefix: String): String = runBlocking {
61         resourceResolutionService().resolveResources(bluePrintRuntimeService, nodeTemplateName,
62                 artifactPrefix, mapOf())
63     }
64 }