2 * Copyright © 2018-2019 IBM, Bell Canada.
3 * Modifications Copyright © 2019 IBM.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor
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
25 @Deprecated("Methods defined as extension function of AbstractComponentFunction")
26 abstract class NetconfComponentFunction : AbstractScriptComponentFunction() {
29 " Use resourceResolutionService method directly",
30 replaceWith = ReplaceWith(
31 "resourceResolutionService()",
32 "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resourceResolutionService"
35 open fun resourceResolutionService(): ResourceResolutionService =
36 functionDependencyInstanceAsType(ResourceResolutionConstants.SERVICE_RESOURCE_RESOLUTION)
38 // Called from python script
40 " Use netconfDeviceInfo method directly",
41 replaceWith = ReplaceWith(
42 "netconfDeviceInfo(requirementName)",
43 "org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.netconfDeviceInfo"
46 fun initializeNetconfConnection(requirementName: String): NetconfDevice {
47 val deviceInfo = netconfDeviceInfo(requirementName)
48 return NetconfDevice(deviceInfo)
52 " Use artifactContent method directly",
53 replaceWith = ReplaceWith(
54 "artifactContent(artifactName)",
55 "org.onap.ccsdk.cds.blueprintsprocessor.services.execution.artifactContent"
58 fun generateMessage(artifactName: String): String {
59 return bluePrintRuntimeService.resolveNodeTemplateArtifact(nodeTemplateName, artifactName)
63 " Use storedContentFromResolvedArtifact method directly",
64 replaceWith = ReplaceWith(
65 "storedContentFromResolvedArtifact(resolutionKey, artifactName)",
66 "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.storedContentFromResolvedArtifact"
69 fun resolveFromDatabase(resolutionKey: String, artifactName: String): String = runBlocking {
70 resourceResolutionService().resolveFromDatabase(bluePrintRuntimeService, artifactName, resolutionKey)
74 " Use contentFromResolvedArtifact method directly",
75 replaceWith = ReplaceWith(
76 "resolveAndGenerateMessage(artifactPrefix)",
77 "org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.resolveAndGenerateMessage"
80 fun resolveAndGenerateMessage(artifactPrefix: String): String = runBlocking {
81 resourceResolutionService().resolveResources(
82 bluePrintRuntimeService, nodeTemplateName,
83 artifactPrefix, mapOf()