2 * Copyright © 2019 IBM.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package cba.capability.cli
19 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTemplateComponentScriptExecutor
20 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.nodeTypeComponentScriptExecutor
21 import org.onap.ccsdk.cds.blueprintsprocessor.ssh.relationshipTemplateSshClient
22 import org.onap.ccsdk.cds.blueprintsprocessor.ssh.relationshipTypeConnectsToSshClient
23 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
24 import org.onap.ccsdk.cds.controllerblueprints.core.data.ServiceTemplate
25 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.artifactTypeTemplateVelocity
26 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getAttribute
27 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.getInput
28 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.nodeTypeComponent
29 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.relationshipTypeConnectsTo
30 import org.onap.ccsdk.cds.controllerblueprints.core.dsl.serviceTemplate
31 import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.AbstractBluePrintDefinitions
33 class CapabilityCliDefinitions : AbstractBluePrintDefinitions() {
35 override fun serviceTemplate(): ServiceTemplate {
36 return defaultServiceTemplate()
40 fun CapabilityCliDefinitions.defaultServiceTemplate() =
42 name = "capability-cli",
44 author = "Brinda Santh Muthuramalingam",
45 tags = "brinda, tosca"
48 workflow(id = "check", description = "CLI Check Workflow") {
50 property(id = "hostname", type = "string", required = true, description = "")
51 property(id = "username", type = "string", required = true, description = "")
52 property(id = "password", type = "string", required = true, description = "")
53 property(id = "data", type = "json", required = true, description = "")
56 property(id = "status", required = true, type = "string", description = "") {
60 step(id = "check", target = "check", description = "Calling check script node")
63 /** Check component Node Template */
64 nodeTemplateComponentScriptExecutor(id = "check", description = "") {
65 definedOperation(description = "") {
67 type(BluePrintConstants.SCRIPT_KOTLIN)
68 scriptClassReference(Check::class)
71 status(getAttribute("status"))
72 responseData("""{ "data" : "Here I am "}""")
76 id = "command-template",
77 type = "artifact-template-velocity",
78 file = "Templates/check-command-template.vtl"
82 /** Connection Configuration through Relationship **/
83 relationshipTemplateSshClient("ssh-connection-config", "Device connection config") {
85 host(getInput("hostname"))
86 password(getInput("password"))
87 username(getInput("username"))
93 artifactTypeTemplateVelocity()
96 nodeTypeComponentScriptExecutor()
97 /** Relationship Types */
98 relationshipTypeConnectsToSshClient()
99 relationshipTypeConnectsTo()