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() {
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)
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)
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)
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)
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())